Skip to content

Commit 4933c16

Browse files
authored
Merge branch 'voxpupuli:master' into master
2 parents b761133 + 383c15e commit 4933c16

File tree

4 files changed

+92
-18
lines changed

4 files changed

+92
-18
lines changed

REFERENCE.md

+18
Original file line numberDiff line numberDiff line change
@@ -3592,8 +3592,10 @@ The following parameters are available in the `zabbix::repo` class:
35923592
* [`manage_apt`](#-zabbix--repo--manage_apt)
35933593
* [`zabbix_version`](#-zabbix--repo--zabbix_version)
35943594
* [`repo_location`](#-zabbix--repo--repo_location)
3595+
* [`repo_gpg_key_location`](#-zabbix--repo--repo_gpg_key_location)
35953596
* [`frontend_repo_location`](#-zabbix--repo--frontend_repo_location)
35963597
* [`unsupported_repo_location`](#-zabbix--repo--unsupported_repo_location)
3598+
* [`unsupported_repo_gpg_key_location`](#-zabbix--repo--unsupported_repo_gpg_key_location)
35973599

35983600
##### <a name="-zabbix--repo--manage_repo"></a>`manage_repo`
35993601

@@ -3627,6 +3629,14 @@ A custom repo location (e.g. your own mirror)
36273629

36283630
Default value: `$zabbix::params::repo_location`
36293631

3632+
##### <a name="-zabbix--repo--repo_gpg_key_location"></a>`repo_gpg_key_location`
3633+
3634+
Data type: `Optional[Stdlib::HTTPUrl]`
3635+
3636+
A custom repo GPG key location (e.g. an airlocked copy of the gpg key)
3637+
3638+
Default value: `$zabbix::params::repo_gpg_key_location`
3639+
36303640
##### <a name="-zabbix--repo--frontend_repo_location"></a>`frontend_repo_location`
36313641

36323642
Data type: `Optional[Stdlib::HTTPUrl]`
@@ -3644,6 +3654,14 @@ Currently only supported under RedHat based systems.
36443654

36453655
Default value: `$zabbix::params::unsupported_repo_location`
36463656

3657+
##### <a name="-zabbix--repo--unsupported_repo_gpg_key_location"></a>`unsupported_repo_gpg_key_location`
3658+
3659+
Data type: `Optional[Stdlib::HTTPUrl]`
3660+
3661+
A custom repo GPG key location (e.g. an airlocked copy of the gpg key)
3662+
3663+
Default value: `$zabbix::params::unsupported_repo_gpg_key_location`
3664+
36473665
### <a name="zabbix--resources--agent"></a>`zabbix::resources::agent`
36483666

36493667
This will create resources into puppetdb for automatically configuring agent into zabbix front-end.

manifests/params.pp

+2
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,9 @@
150150
$manage_firewall = false
151151
$manage_apt = true
152152
$repo_location = undef
153+
$repo_gpg_key_location = undef
153154
$unsupported_repo_location = undef
155+
$unsupported_repo_gpg_key_location = undef
154156
$frontend_repo_location = undef
155157
$manage_resources = false
156158
$manage_vhost = true

manifests/repo.pp

+50-18
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,64 @@
33
# @param manage_apt Whether the module should manage apt repositories for Debian based systems.
44
# @param zabbix_version This is the zabbix version.
55
# @param repo_location A custom repo location (e.g. your own mirror)
6+
# @param repo_gpg_key_location
7+
# A custom repo GPG key location (e.g. an airlocked copy of the gpg key)
68
# @param frontend_repo_location A custom repo location for frontend package.
79
# @param unsupported_repo_location
810
# A custom repo location for unsupported content (e.g. your own mirror)
911
# Currently only supported under RedHat based systems.
12+
# @param unsupported_repo_gpg_key_location
13+
# A custom repo GPG key location (e.g. an airlocked copy of the gpg key)
1014
# @author Werner Dijkerman <[email protected]>
1115
# @author Tim Meusel <[email protected]>
1216
class zabbix::repo (
13-
Boolean $manage_repo = $zabbix::params::manage_repo,
14-
Boolean $manage_apt = $zabbix::params::manage_apt,
15-
Optional[Stdlib::HTTPUrl] $repo_location = $zabbix::params::repo_location,
16-
Optional[Stdlib::HTTPUrl] $frontend_repo_location = $zabbix::params::frontend_repo_location,
17-
Optional[Stdlib::HTTPUrl] $unsupported_repo_location = $zabbix::params::unsupported_repo_location,
18-
String[1] $zabbix_version = $zabbix::params::zabbix_version,
17+
Boolean $manage_repo = $zabbix::params::manage_repo,
18+
Boolean $manage_apt = $zabbix::params::manage_apt,
19+
Optional[Stdlib::HTTPUrl] $repo_location = $zabbix::params::repo_location,
20+
Optional[Stdlib::HTTPUrl] $repo_gpg_key_location = $zabbix::params::repo_gpg_key_location,
21+
Optional[Stdlib::HTTPUrl] $frontend_repo_location = $zabbix::params::frontend_repo_location,
22+
Optional[Stdlib::HTTPUrl] $unsupported_repo_location = $zabbix::params::unsupported_repo_location,
23+
Optional[Stdlib::HTTPUrl] $unsupported_repo_gpg_key_location = $zabbix::params::unsupported_repo_gpg_key_location,
24+
String[1] $zabbix_version = $zabbix::params::zabbix_version,
1925
) inherits zabbix::params {
2026
if $manage_repo {
2127
case $facts['os']['family'] {
2228
'RedHat': {
2329
$majorrelease = $facts['os']['release']['major']
2430
if versioncmp($zabbix_version, '7.0') >= 0 {
25-
$gpgkey_zabbix = 'https://repo.zabbix.com/RPM-GPG-KEY-ZABBIX-B5333005'
31+
$_gpgkey_zabbix = $repo_gpg_key_location ? {
32+
undef => 'https://repo.zabbix.com/RPM-GPG-KEY-ZABBIX-B5333005',
33+
default => "${repo_gpg_key_location}/RPM-GPG-KEY-ZABBIX-B5333005",
34+
}
2635
if versioncmp(fact('os.release.major'), '9') >= 0 {
27-
$gpgkey_nonsupported = 'https://repo.zabbix.com/RPM-GPG-KEY-ZABBIX-08EFA7DD'
36+
$_gpgkey_nonsupported = $unsupported_repo_gpg_key_location ? {
37+
undef => 'https://repo.zabbix.com/RPM-GPG-KEY-ZABBIX-08EFA7DD',
38+
default => "${unsupported_repo_gpg_key_location}/RPM-GPG-KEY-ZABBIX-08EFA7DD",
39+
}
2840
} else {
29-
$gpgkey_nonsupported = 'https://repo.zabbix.com/RPM-GPG-KEY-ZABBIX-B5333005'
41+
$_gpgkey_nonsupported = $unsupported_repo_gpg_key_location ? {
42+
undef => 'https://repo.zabbix.com/RPM-GPG-KEY-ZABBIX-B5333005',
43+
default => "${unsupported_repo_gpg_key_location}/RPM-GPG-KEY-ZABBIX-B5333005",
44+
}
3045
}
3146
} elsif versioncmp(fact('os.release.major'), '9') >= 0 {
32-
$gpgkey_zabbix = 'https://repo.zabbix.com/RPM-GPG-KEY-ZABBIX-08EFA7DD'
33-
$gpgkey_nonsupported = 'https://repo.zabbix.com/RPM-GPG-KEY-ZABBIX-08EFA7DD'
47+
$_gpgkey_zabbix = $repo_gpg_key_location ? {
48+
undef => 'https://repo.zabbix.com/RPM-GPG-KEY-ZABBIX-08EFA7DD',
49+
default => "${repo_gpg_key_location}/RPM-GPG-KEY-ZABBIX-08EFA7DD",
50+
}
51+
$_gpgkey_nonsupported = $unsupported_repo_gpg_key_location ? {
52+
undef => 'https://repo.zabbix.com/RPM-GPG-KEY-ZABBIX-08EFA7DD',
53+
default => "${unsupported_repo_gpg_key_location}/RPM-GPG-KEY-ZABBIX-08EFA7DD",
54+
}
3455
} else {
35-
$gpgkey_zabbix = 'https://repo.zabbix.com/RPM-GPG-KEY-ZABBIX-A14FE591'
36-
$gpgkey_nonsupported = 'https://repo.zabbix.com/RPM-GPG-KEY-ZABBIX-79EA5ED4'
56+
$_gpgkey_zabbix = $repo_gpg_key_location ? {
57+
undef => 'https://repo.zabbix.com/RPM-GPG-KEY-ZABBIX-A14FE591',
58+
default => "${repo_gpg_key_location}/RPM-GPG-KEY-ZABBIX-A14FE591",
59+
}
60+
$_gpgkey_nonsupported = $unsupported_repo_gpg_key_location ? {
61+
undef => 'https://repo.zabbix.com/RPM-GPG-KEY-ZABBIX-79EA5ED4',
62+
default => "${unsupported_repo_gpg_key_location}/RPM-GPG-KEY-ZABBIX-79EA5ED4",
63+
}
3764
}
3865

3966
$_repo_location = $repo_location ? {
@@ -46,7 +73,7 @@
4673
descr => "Zabbix_${majorrelease}_${facts['os']['architecture']}",
4774
baseurl => $_repo_location,
4875
gpgcheck => '1',
49-
gpgkey => $gpgkey_zabbix,
76+
gpgkey => $_gpgkey_zabbix,
5077
priority => '1',
5178
}
5279

@@ -60,7 +87,7 @@
6087
descr => "Zabbix_nonsupported_${majorrelease}_${facts['os']['architecture']}",
6188
baseurl => $_unsupported_repo_location,
6289
gpgcheck => '1',
63-
gpgkey => $gpgkey_nonsupported,
90+
gpgkey => $_gpgkey_nonsupported,
6491
priority => '1',
6592
}
6693
}
@@ -91,17 +118,22 @@
91118
default => $repo_location,
92119
}
93120

121+
$_gpgkey_zabbix = $repo_gpg_key_location ? {
122+
undef => 'https://repo.zabbix.com/zabbix-official-repo.key',
123+
default => "${repo_gpg_key_location}/zabbix-official-repo.key",
124+
}
125+
94126
apt::key { 'zabbix-FBABD5F':
95127
id => 'FBABD5FB20255ECAB22EE194D13D58E479EA5ED4',
96-
source => 'https://repo.zabbix.com/zabbix-official-repo.key',
128+
source => $_gpgkey_zabbix,
97129
}
98130
apt::key { 'zabbix-A1848F5':
99131
id => 'A1848F5352D022B9471D83D0082AB56BA14FE591',
100-
source => 'https://repo.zabbix.com/zabbix-official-repo.key',
132+
source => $_gpgkey_zabbix,
101133
}
102134
apt::key { 'zabbix-4C3D6F2':
103135
id => '4C3D6F2CC75F5146754FC374D913219AB5333005',
104-
source => 'https://repo.zabbix.com/zabbix-official-repo.key',
136+
source => $_gpgkey_zabbix,
105137
}
106138

107139
# Debian 11 provides Zabbix 5.0 by default. This can cause problems for 4.0 versions

spec/classes/repo_spec.rb

+22
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,17 @@
7373
it { is_expected.to contain_yumrepo('zabbix').with_baseurl('https://example.com/foo') }
7474
end
7575

76+
context 'when repo_gpg_key_location is "https://example.com/bar"' do
77+
let :params do
78+
{
79+
repo_gpg_key_location: 'https://example.com/bar'
80+
}
81+
end
82+
83+
it { is_expected.to contain_yumrepo('zabbix').with_gpgkey('https://example.com/bar/RPM-GPG-KEY-ZABBIX-A14FE591') } if facts[:os]['release']['major'].to_i < 9
84+
it { is_expected.to contain_yumrepo('zabbix').with_gpgkey('https://example.com/bar/RPM-GPG-KEY-ZABBIX-08EFA7DD') } if facts[:os]['release']['major'].to_i >= 9
85+
end
86+
7687
context 'when unsupported_repo_location is "https://example.com/foo"' do
7788
let :params do
7889
{
@@ -83,6 +94,17 @@
8394
it { is_expected.to contain_yumrepo('zabbix-nonsupported').with_baseurl('https://example.com/foo') }
8495
end
8596

97+
context 'when unsupported_repo_gpg_key_location is "https://example.com/bar"' do
98+
let :params do
99+
{
100+
unsupported_repo_gpg_key_location: 'https://example.com/bar'
101+
}
102+
end
103+
104+
it { is_expected.to contain_yumrepo('zabbix-nonsupported').with_gpgkey('https://example.com/bar/RPM-GPG-KEY-ZABBIX-79EA5ED4') } if facts[:os]['release']['major'].to_i < 9
105+
it { is_expected.to contain_yumrepo('zabbix-nonsupported').with_gpgkey('https://example.com/bar/RPM-GPG-KEY-ZABBIX-08EFA7DD') } if facts[:os]['release']['major'].to_i >= 9
106+
end
107+
86108
major = facts[:os]['release']['major']
87109
context "on RedHat #{major} and Zabbix 5.0" do
88110
let :params do

0 commit comments

Comments
 (0)