dev/provisioning/modules/elasticsearch/manifests/package/pin.pp
changeset 406 cf0f23803a53
equal deleted inserted replaced
405:f239c8c5bb94 406:cf0f23803a53
       
     1 # == Class: elasticsearch::package::pin
       
     2 #
       
     3 # Controls package pinning for the Elasticsearch package.
       
     4 #
       
     5 # === Parameters
       
     6 #
       
     7 # This class does not provide any parameters.
       
     8 #
       
     9 # === Examples
       
    10 #
       
    11 # This class may be imported by other classes to use its functionality:
       
    12 #   class { 'elasticsearch::package::pin': }
       
    13 #
       
    14 # It is not intended to be used directly by external resources like node
       
    15 # definitions or other modules.
       
    16 #
       
    17 # === Authors
       
    18 #
       
    19 # * Tyler Langlois <mailto:tyler@elastic.co>
       
    20 #
       
    21 class elasticsearch::package::pin {
       
    22 
       
    23   Exec {
       
    24     path => [ '/bin', '/usr/bin', '/usr/local/bin' ],
       
    25     cwd  => '/',
       
    26   }
       
    27 
       
    28   case $::osfamily {
       
    29     'Debian': {
       
    30       include ::apt
       
    31 
       
    32       if ($elasticsearch::ensure == 'absent') {
       
    33         apt::pin { $elasticsearch::package_name:
       
    34           ensure => $elasticsearch::ensure,
       
    35         }
       
    36       } elsif ($elasticsearch::version != false) {
       
    37         apt::pin { $elasticsearch::package_name:
       
    38           ensure   => $elasticsearch::ensure,
       
    39           packages => $elasticsearch::package_name,
       
    40           version  => $elasticsearch::version,
       
    41           priority => 1000,
       
    42         }
       
    43       }
       
    44 
       
    45     }
       
    46     'RedHat', 'Linux': {
       
    47 
       
    48       if ($elasticsearch::ensure == 'absent') {
       
    49         $_versionlock = '/etc/yum/pluginconf.d/versionlock.list'
       
    50         $_lock_line = '0:elasticsearch-'
       
    51         exec { 'elasticsearch_purge_versionlock.list':
       
    52           command => "sed -i '/${_lock_line}/d' ${_versionlock}",
       
    53           onlyif  => [
       
    54             "test -f ${_versionlock}",
       
    55             "grep -F '${_lock_line}' ${_versionlock}",
       
    56           ],
       
    57         }
       
    58       } elsif ($elasticsearch::version != false) {
       
    59         yum::versionlock {
       
    60           "0:elasticsearch-${elasticsearch::pkg_version}.noarch":
       
    61             ensure => $elasticsearch::ensure,
       
    62         }
       
    63       }
       
    64 
       
    65     }
       
    66     default: {
       
    67       warning("Unable to pin package for OSfamily \"${::osfamily}\".")
       
    68     }
       
    69   }
       
    70 }