dev/provisioning/modules/elasticsearch/manifests/repo.pp
changeset 28 b0b56e0f8c7f
child 406 cf0f23803a53
equal deleted inserted replaced
27:a2342f26c9de 28:b0b56e0f8c7f
       
     1 # == Class: elasticsearch::repo
       
     2 #
       
     3 # This class exists to install and manage yum and apt repositories
       
     4 # that contain elasticsearch official elasticsearch packages
       
     5 #
       
     6 #
       
     7 # === Parameters
       
     8 #
       
     9 # This class does not provide any parameters.
       
    10 #
       
    11 #
       
    12 # === Examples
       
    13 #
       
    14 # This class may be imported by other classes to use its functionality:
       
    15 #   class { 'elasticsearch::repo': }
       
    16 #
       
    17 # It is not intended to be used directly by external resources like node
       
    18 # definitions or other modules.
       
    19 #
       
    20 #
       
    21 # === Authors
       
    22 #
       
    23 # * Phil Fenstermacher <mailto:phillip.fenstermacher@gmail.com>
       
    24 # * Richard Pijnenburg <mailto:richard.pijnenburg@elasticsearch.com>
       
    25 #
       
    26 class elasticsearch::repo {
       
    27 
       
    28   Exec {
       
    29     path      => [ '/bin', '/usr/bin', '/usr/local/bin' ],
       
    30     cwd       => '/',
       
    31   }
       
    32 
       
    33   case $::osfamily {
       
    34     'Debian': {
       
    35       include ::apt
       
    36       Class['apt::update'] -> Package[$elasticsearch::package_name]
       
    37 
       
    38       apt::source { 'elasticsearch':
       
    39         location    => "http://packages.elastic.co/elasticsearch/${elasticsearch::repo_version}/debian",
       
    40         release     => 'stable',
       
    41         repos       => 'main',
       
    42         key         => $::elasticsearch::repo_key_id,
       
    43         key_source  => $::elasticsearch::repo_key_source,
       
    44         include_src => false,
       
    45       }
       
    46     }
       
    47     'RedHat', 'Linux': {
       
    48       yumrepo { 'elasticsearch':
       
    49         descr    => 'elasticsearch repo',
       
    50         baseurl  => "http://packages.elastic.co/elasticsearch/${elasticsearch::repo_version}/centos",
       
    51         gpgcheck => 1,
       
    52         gpgkey   => $::elasticsearch::repo_key_source,
       
    53         enabled  => 1,
       
    54       }
       
    55     }
       
    56     'Suse': {
       
    57       exec { 'elasticsearch_suse_import_gpg':
       
    58         command => "rpmkeys --import ${::elasticsearch::repo_key_source}",
       
    59         unless  => "test $(rpm -qa gpg-pubkey | grep -i '${::elasticsearch::repo_key_id}' | wc -l) -eq 1 ",
       
    60         notify  => [ Zypprepo['elasticsearch'] ],
       
    61       }
       
    62 
       
    63       zypprepo { 'elasticsearch':
       
    64         baseurl     => "http://packages.elastic.co/elasticsearch/${elasticsearch::repo_version}/centos",
       
    65         enabled     => 1,
       
    66         autorefresh => 1,
       
    67         name        => 'elasticsearch',
       
    68         gpgcheck    => 1,
       
    69         gpgkey      => $::elasticsearch::repo_key_source,
       
    70         type        => 'yum',
       
    71       }
       
    72     }
       
    73     default: {
       
    74       fail("\"${module_name}\" provides no repository information for OSfamily \"${::osfamily}\"")
       
    75     }
       
    76   }
       
    77 
       
    78   # Package pinning
       
    79 
       
    80     case $::osfamily {
       
    81       'Debian': {
       
    82         include ::apt
       
    83 
       
    84         if ($elasticsearch::package_pin == true and $elasticsearch::version != false) {
       
    85           apt::pin { $elasticsearch::package_name:
       
    86             ensure   => 'present',
       
    87             packages => $elasticsearch::package_name,
       
    88             version  => $elasticsearch::version,
       
    89             priority => 1000,
       
    90           }
       
    91         }
       
    92 
       
    93       }
       
    94       'RedHat', 'Linux': {
       
    95 
       
    96         if ($elasticsearch::package_pin == true and $elasticsearch::version != false) {
       
    97           yum::versionlock { "0:elasticsearch-${elasticsearch::pkg_version}.noarch":
       
    98             ensure => 'present',
       
    99           }
       
   100         }
       
   101       }
       
   102       default: {
       
   103         warning("Unable to pin package for OSfamily \"${::osfamily}\".")
       
   104       }
       
   105     }
       
   106 }