Puppet Class: elasticsearch::repo
- Defined in:
- manifests/repo.pp
Overview
Class: elasticsearch::repo
This class exists to install and manage yum and apt repositories that contain elasticsearch official elasticsearch packages
Parameters
This class does not provide any parameters.
Examples
This class may be imported by other classes to use its functionality:
class { 'elasticsearch::repo': }
It is not intended to be used directly by external resources like node definitions or other modules.
Authors
-
Phil Fenstermacher <phillip.fenstermacher@gmail.com>
-
Richard Pijnenburg <richard.pijnenburg@elasticsearch.com>
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'manifests/repo.pp', line 26
class elasticsearch::repo {
Exec {
path => [ '/bin', '/usr/bin', '/usr/local/bin' ],
cwd => '/',
}
if $elasticsearch::ensure == 'present' {
if versioncmp($elasticsearch::repo_version, '5.0') >= 0 {
$_repo_url = 'https://artifacts.elastic.co/packages'
case $::osfamily {
'Debian': {
$_repo_path = 'apt'
}
default: {
$_repo_path = 'yum'
}
}
} else {
$_repo_url = 'http://packages.elastic.co/elasticsearch'
case $::osfamily {
'Debian': {
$_repo_path = 'debian'
}
default: {
$_repo_path = 'centos'
}
}
}
$_baseurl = "${_repo_url}/${elasticsearch::repo_version}/${_repo_path}"
} else {
case $::osfamily {
'Debian': {
$_baseurl = undef
}
default: {
$_baseurl = 'absent'
}
}
}
case $::osfamily {
'Debian': {
include ::apt
Class['apt::update'] -> Package[$elasticsearch::package_name]
apt::source { 'elasticsearch':
ensure => $elasticsearch::ensure,
location => $_baseurl,
release => 'stable',
repos => 'main',
key => {
'id' => $::elasticsearch::repo_key_id,
'source' => $::elasticsearch::repo_key_source,
},
include => {
'src' => false,
'deb' => true,
},
pin => $elasticsearch::repo_priority,
}
}
'RedHat', 'Linux': {
# Versions prior to 3.5.1 have issues with this param
# See: https://tickets.puppetlabs.com/browse/PUP-2163
if versioncmp($::puppetversion, '3.5.1') >= 0 {
Yumrepo['elasticsearch'] {
ensure => $elasticsearch::ensure,
}
}
yumrepo { 'elasticsearch':
descr => 'elasticsearch repo',
baseurl => $_baseurl,
gpgcheck => 1,
gpgkey => $::elasticsearch::repo_key_source,
enabled => 1,
proxy => $::elasticsearch::repo_proxy,
priority => $elasticsearch::repo_priority,
} ~>
exec { 'elasticsearch_yumrepo_yum_clean':
command => 'yum clean metadata expire-cache --disablerepo="*" --enablerepo="elasticsearch"',
refreshonly => true,
returns => [0, 1],
}
}
'Suse': {
if $::operatingsystem == 'SLES' and versioncmp($::operatingsystemmajrelease, '11') <= 0 {
# Older versions of SLES do not ship with rpmkeys
$_import_cmd = "rpm --import ${::elasticsearch::repo_key_source}"
} else {
$_import_cmd = "rpmkeys --import ${::elasticsearch::repo_key_source}"
}
exec { 'elasticsearch_suse_import_gpg':
command => $_import_cmd,
unless =>
"test $(rpm -qa gpg-pubkey | grep -i 'D88E42B4' | wc -l) -eq 1",
notify => Zypprepo['elasticsearch'],
}
zypprepo { 'elasticsearch':
baseurl => $_baseurl,
enabled => 1,
autorefresh => 1,
name => 'elasticsearch',
gpgcheck => 1,
gpgkey => $::elasticsearch::repo_key_source,
type => 'yum',
} ~>
exec { 'elasticsearch_zypper_refresh_elasticsearch':
command => 'zypper refresh elasticsearch',
refreshonly => true,
}
}
default: {
fail("\"${module_name}\" provides no repository information for OSfamily \"${::osfamily}\"")
}
}
}
|