-
-
Notifications
You must be signed in to change notification settings - Fork 299
/
repo.pp
81 lines (75 loc) · 2.4 KB
/
repo.pp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
# This class manages package repositories for Logstash.
#
# It is usually used only by the top-level `logstash` class. It's unlikely
# that you will need to declare this class yourself.
#
# @example Include this class to ensure its resources are available.
# include logstash::repo
#
# @author https://github.com/elastic/puppet-logstash/graphs/contributors
#
class logstash::repo {
$version = $logstash::repo_version
$repo_name = "elastic-${version}"
$url_root = "https://artifacts.elastic.co/packages/${version}"
$gpg_key_url = 'https://artifacts.elastic.co/GPG-KEY-elasticsearch'
$gpg_key_id = '46095ACC8548582C1A2699A9D27D666CD88E42B4'
Exec {
path => [ '/bin', '/usr/bin', '/usr/local/bin' ],
cwd => '/',
}
case $::osfamily {
'Debian': {
include apt
apt::source { $repo_name:
location => "${url_root}/apt",
release => 'stable',
repos => 'main',
key => {
'id' => $gpg_key_id,
'source' => $gpg_key_url,
},
include => {
'src' => false,
},
notify => [
Class['apt::update'],
Exec['apt_update'],
],
}
}
'RedHat': {
yumrepo { $repo_name:
descr => 'Logstash Centos Repo',
baseurl => "${url_root}/yum",
gpgcheck => 1,
gpgkey => $gpg_key_url,
enabled => 1,
}
Yumrepo[$repo_name] -> Package<|tag == 'logstash'|>
}
'Suse' : {
zypprepo { $repo_name:
baseurl => "${url_root}/yum",
enabled => 1,
autorefresh => 1,
name => 'logstash',
gpgcheck => 1,
gpgkey => $gpg_key_url,
type => 'yum',
}
# Workaround until zypprepo allows the adding of the keys
# https://github.com/deadpoint/puppet-zypprepo/issues/4
exec { 'logstash_suse_import_gpg':
command => "wget -q -O /tmp/RPM-GPG-KEY-elasticsearch ${gpg_key_url}; \
rpm --import /tmp/RPM-GPG-KEY-elasticsearch; \
rm /tmp/RPM-GPG-KEY-elasticsearch",
unless => "test $(rpm -qa gpg-pubkey | grep -i \"${gpg_key_id}\" | wc -l) -eq 1 ",
}
Exec['logstash_suse_import_gpg'] ~> Zypprepo['logstash'] -> Package<|tag == 'logstash'|>
}
default: {
fail("\"${module_name}\" provides no repository information for OSfamily \"${::osfamily}\"")
}
}
}