Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

repo.pp: use apt::keyring on distros where using keys stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg) is deprecated #975

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 36 additions & 23 deletions manifests/repo.pp
Original file line number Diff line number Diff line change
Expand Up @@ -124,34 +124,47 @@
default => $repo_location,
}

apt::key { 'zabbix-FBABD5F':
id => 'FBABD5FB20255ECAB22EE194D13D58E479EA5ED4',
source => 'https://repo.zabbix.com/zabbix-official-repo.key',
}
apt::key { 'zabbix-A1848F5':
id => 'A1848F5352D022B9471D83D0082AB56BA14FE591',
source => 'https://repo.zabbix.com/zabbix-official-repo.key',
}
apt::key { 'zabbix-4C3D6F2':
id => '4C3D6F2CC75F5146754FC374D913219AB5333005',
source => 'https://repo.zabbix.com/zabbix-official-repo.key',
}

# Debian 11 provides Zabbix 5.0 by default. This can cause problems for 4.0 versions
$pinpriority = $facts['os']['release']['major'] ? {
'11' => 1000,
default => undef,
}
apt::source { 'zabbix':
location => $_repo_location,
repos => 'main',
release => $releasename,
pin => $pinpriority,
require => [
Apt_key['zabbix-FBABD5F'],
Apt_key['zabbix-A1848F5'],
Apt_key['zabbix-4C3D6F2'],
],

if (fact('os.name') == 'Ubuntu' and versioncmp(fact('os.release.major'), '22.04') >= 0 or fact('os.name') == 'Debian' and versioncmp(fact('os.release.major'), '12') >= 0) {
apt::source { 'zabbix':
location => $_repo_location,
repos => 'main',
release => $releasename,
pin => $pinpriority,
key => {
name => 'zabbix-official-repo.asc',
source => 'https://repo.zabbix.com/zabbix-official-repo.key',
},
}
} else {
apt::key { 'zabbix-FBABD5F':
id => 'FBABD5FB20255ECAB22EE194D13D58E479EA5ED4',
source => 'https://repo.zabbix.com/zabbix-official-repo.key',
}
apt::key { 'zabbix-A1848F5':
id => 'A1848F5352D022B9471D83D0082AB56BA14FE591',
source => 'https://repo.zabbix.com/zabbix-official-repo.key',
}
apt::key { 'zabbix-4C3D6F2':
id => '4C3D6F2CC75F5146754FC374D913219AB5333005',
source => 'https://repo.zabbix.com/zabbix-official-repo.key',
}
apt::source { 'zabbix':
location => $_repo_location,
repos => 'main',
release => $releasename,
pin => $pinpriority,
require => [
Apt::Key['zabbix-FBABD5F'],
Apt::Key['zabbix-A1848F5'],
Apt::Key['zabbix-4C3D6F2'],
],
}
}

Apt::Source['zabbix'] -> Package<|tag == 'zabbix'|>
Expand Down
11 changes: 6 additions & 5 deletions spec/classes/agent_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,12 @@
# service = facts[:os]['family'] == 'Gentoo' ? 'zabbix-agentd' : 'zabbix-agent'

context 'with all defaults' do
it { is_expected.to contain_selinux__module('zabbix-agent') } if facts[:os]['family'] == 'RedHat'
it { is_expected.to contain_yumrepo('zabbix-frontend') } if facts[:os]['family'] == 'RedHat' && facts[:os]['release']['major'] == '7'
it { is_expected.to contain_package('zabbix-required-scl-repo') } if facts[:os]['family'] == 'RedHat' && facts[:os]['release']['major'] == '7' && %w[OracleLinux CentOS].include?(facts[:os]['name'])
it { is_expected.to contain_apt__key('zabbix-A1848F5') } if facts[:os]['family'] == 'Debian'
it { is_expected.to contain_apt__key('zabbix-FBABD5F') } if facts[:os]['family'] == 'Debian'
it { is_expected.to contain_selinux__module('zabbix-agent') } if facts[:os]['family'] == 'RedHat'
it { is_expected.to contain_yumrepo('zabbix-frontend') } if facts[:os]['family'] == 'RedHat' && facts[:os]['release']['major'] == '7'
it { is_expected.to contain_package('zabbix-required-scl-repo') } if facts[:os]['family'] == 'RedHat' && facts[:os]['release']['major'] == '7' && %w[OracleLinux CentOS].include?(facts[:os]['name'])
it { is_expected.to contain_apt__key('zabbix-A1848F5') } if (facts[:os]['name'] == 'Debian' && Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '12') < 0) || (facts[:os]['name'] == 'Ubuntu' && Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '22.04') < 0)
it { is_expected.to contain_apt__key('zabbix-FBABD5F') } if (facts[:os]['name'] == 'Debian' && Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '12') < 0) || (facts[:os]['name'] == 'Ubuntu' && Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '22.04') < 0)
it { is_expected.to contain_apt__keyring('zabbix-official-repo.asc') } if (facts[:os]['name'] == 'Debian' && Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '12') >= 0) || (facts[:os]['name'] == 'Ubuntu' && Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '22.04') >= 0)
it { is_expected.to contain_file(include_dir).with_ensure('directory') }

# Make sure package will be installed, service running and ensure of directory.
Expand Down Expand Up @@ -492,7 +493,7 @@
super().merge(systemd: true)
end

it { is_expected.to contain_systemd__unit_file('zabbix-agent.service') }

Check warning on line 496 in spec/classes/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

zabbix::agent on gentoo-2-x86_64 with systemd active Skipped: user package provided instead systemd::unit_file

Check warning on line 496 in spec/classes/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

zabbix::agent on almalinux-8-x86_64 with systemd active Skipped: user package provided instead systemd::unit_file

Check warning on line 496 in spec/classes/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

zabbix::agent on almalinux-9-x86_64 with systemd active Skipped: user package provided instead systemd::unit_file

Check warning on line 496 in spec/classes/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

zabbix::agent on archlinux-rolling-x86_64 with systemd active Skipped: user package provided instead systemd::unit_file

Check warning on line 496 in spec/classes/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

zabbix::agent on centos-7-x86_64 with systemd active Skipped: user package provided instead systemd::unit_file

Check warning on line 496 in spec/classes/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

zabbix::agent on centos-9-x86_64 with systemd active Skipped: user package provided instead systemd::unit_file

Check warning on line 496 in spec/classes/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

zabbix::agent on debian-11-x86_64 with systemd active Skipped: user package provided instead systemd::unit_file

Check warning on line 496 in spec/classes/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

zabbix::agent on debian-12-x86_64 with systemd active Skipped: user package provided instead systemd::unit_file

Check warning on line 496 in spec/classes/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

zabbix::agent on oraclelinux-7-x86_64 with systemd active Skipped: user package provided instead systemd::unit_file

Check warning on line 496 in spec/classes/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

zabbix::agent on oraclelinux-8-x86_64 with systemd active Skipped: user package provided instead systemd::unit_file

Check warning on line 496 in spec/classes/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

zabbix::agent on gentoo-2-x86_64 with systemd active Skipped: user package provided instead systemd::unit_file

Check warning on line 496 in spec/classes/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

zabbix::agent on almalinux-8-x86_64 with systemd active Skipped: user package provided instead systemd::unit_file

Check warning on line 496 in spec/classes/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

zabbix::agent on almalinux-9-x86_64 with systemd active Skipped: user package provided instead systemd::unit_file

Check warning on line 496 in spec/classes/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

zabbix::agent on archlinux-rolling-x86_64 with systemd active Skipped: user package provided instead systemd::unit_file

Check warning on line 496 in spec/classes/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

zabbix::agent on centos-7-x86_64 with systemd active Skipped: user package provided instead systemd::unit_file

Check warning on line 496 in spec/classes/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

zabbix::agent on centos-9-x86_64 with systemd active Skipped: user package provided instead systemd::unit_file

Check warning on line 496 in spec/classes/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

zabbix::agent on debian-11-x86_64 with systemd active Skipped: user package provided instead systemd::unit_file

Check warning on line 496 in spec/classes/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

zabbix::agent on debian-12-x86_64 with systemd active Skipped: user package provided instead systemd::unit_file

Check warning on line 496 in spec/classes/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

zabbix::agent on oraclelinux-7-x86_64 with systemd active Skipped: user package provided instead systemd::unit_file

Check warning on line 496 in spec/classes/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

zabbix::agent on oraclelinux-8-x86_64 with systemd active Skipped: user package provided instead systemd::unit_file
end
end

Expand Down
7 changes: 4 additions & 3 deletions spec/classes/javagateway_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@
it { is_expected.to contain_service('zabbix-java-gateway').with_enable('true') }
it { is_expected.to contain_service('zabbix-java-gateway').with_require(['Package[zabbix-java-gateway]', 'File[/etc/zabbix/zabbix_java_gateway.conf]']) }

it { is_expected.to contain_yumrepo('zabbix-frontend') } if facts[:os]['family'] == 'RedHat' && facts[:os]['release']['major'] == '7'
it { is_expected.to contain_yumrepo('zabbix-frontend') } if facts[:os]['family'] == 'RedHat' && facts[:os]['release']['major'] == '7'
it { is_expected.to contain_package('zabbix-required-scl-repo') } if facts[:os]['family'] == 'RedHat' && facts[:os]['release']['major'] == '7' && %w[OracleLinux CentOS].include?(facts[:os]['name'])
it { is_expected.to contain_apt__key('zabbix-A1848F5') } if facts[:os]['family'] == 'Debian'
it { is_expected.to contain_apt__key('zabbix-FBABD5F') } if facts[:os]['family'] == 'Debian'
it { is_expected.to contain_apt__key('zabbix-A1848F5') } if (facts[:os]['name'] == 'Debian' && Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '12') < 0) || (facts[:os]['name'] == 'Ubuntu' && Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '22.04') < 0)
it { is_expected.to contain_apt__key('zabbix-FBABD5F') } if (facts[:os]['name'] == 'Debian' && Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '12') < 0) || (facts[:os]['name'] == 'Ubuntu' && Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '22.04') < 0)
it { is_expected.to contain_apt__keyring('zabbix-official-repo.asc') } if (facts[:os]['name'] == 'Debian' && Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '12') >= 0) || (facts[:os]['name'] == 'Ubuntu' && Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '22.04') >= 0)
end

context 'when declaring manage_repo is true' do
Expand Down
5 changes: 3 additions & 2 deletions spec/classes/repo_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
it { is_expected.to contain_class('zabbix::params') }
it { is_expected.to contain_class('zabbix::repo') }

it { is_expected.to contain_apt__key('zabbix-A1848F5') } if facts[:os]['family'] == 'Debian'
it { is_expected.to contain_apt__key('zabbix-FBABD5F') } if facts[:os]['family'] == 'Debian'
it { is_expected.to contain_apt__key('zabbix-A1848F5') } if (facts[:os]['name'] == 'Debian' && Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '12') < 0) || (facts[:os]['name'] == 'Ubuntu' && Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '22.04') < 0)
it { is_expected.to contain_apt__key('zabbix-FBABD5F') } if (facts[:os]['name'] == 'Debian' && Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '12') < 0) || (facts[:os]['name'] == 'Ubuntu' && Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '22.04') < 0)
it { is_expected.to contain_apt__keyring('zabbix-official-repo.asc') } if (facts[:os]['name'] == 'Debian' && Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '12') >= 0) || (facts[:os]['name'] == 'Ubuntu' && Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '22.04') >= 0)

context 'when repo_location is "https://example.com/foo"' do
let :params do
Expand Down
6 changes: 4 additions & 2 deletions spec/classes/sender_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@
it { is_expected.to contain_package('zabbix-required-scl-repo') } if facts[:os]['release']['major'] == '7' && %w[OracleLinux CentOS].include?(facts[:os]['name'])
when 'Debian'
it { is_expected.to contain_apt__source('zabbix') }
it { is_expected.to contain_apt__key('zabbix-A1848F5') }
it { is_expected.to contain_apt__key('zabbix-FBABD5F') }

it { is_expected.to contain_apt__key('zabbix-A1848F5') } if (facts[:os]['name'] == 'Debian' && Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '12') < 0) || (facts[:os]['name'] == 'Ubuntu' && Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '22.04') < 0)
it { is_expected.to contain_apt__key('zabbix-FBABD5F') } if (facts[:os]['name'] == 'Debian' && Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '12') < 0) || (facts[:os]['name'] == 'Ubuntu' && Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '22.04') < 0)
it { is_expected.to contain_apt__keyring('zabbix-official-repo.asc') } if (facts[:os]['name'] == 'Debian' && Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '12') >= 0) || (facts[:os]['name'] == 'Ubuntu' && Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '22.04') >= 0)
end
end
end
Expand Down
7 changes: 4 additions & 3 deletions spec/classes/server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@
it { is_expected.to contain_service('zabbix-server').with_ensure('running') }
it { is_expected.not_to contain_zabbix__startup('zabbix-server') }

it { is_expected.to contain_apt__source('zabbix') } if facts[:os]['family'] == 'Debian'
it { is_expected.to contain_apt__key('zabbix-A1848F5') } if facts[:os]['family'] == 'Debian'
it { is_expected.to contain_apt__key('zabbix-FBABD5F') } if facts[:os]['family'] == 'Debian'
it { is_expected.to contain_apt__source('zabbix') } if facts[:os]['family'] == 'Debian'
it { is_expected.to contain_apt__key('zabbix-A1848F5') } if (facts[:os]['name'] == 'Debian' && Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '12') < 0) || (facts[:os]['name'] == 'Ubuntu' && Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '22.04') < 0)
it { is_expected.to contain_apt__key('zabbix-FBABD5F') } if (facts[:os]['name'] == 'Debian' && Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '12') < 0) || (facts[:os]['name'] == 'Ubuntu' && Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '22.04') < 0)
it { is_expected.to contain_apt__keyring('zabbix-official-repo.asc') } if (facts[:os]['name'] == 'Debian' && Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '12') >= 0) || (facts[:os]['name'] == 'Ubuntu' && Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '22.04') >= 0)
end

if facts[:os]['family'] == 'RedHat'
Expand Down
5 changes: 3 additions & 2 deletions spec/classes/web_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ class { 'apache':
it { is_expected.to contain_class('Zabbix::Repo') }
it { is_expected.to contain_file('/etc/zabbix/web').with_ensure('directory') }

it { is_expected.to contain_apt__key('zabbix-A1848F5') } if facts[:os]['family'] == 'Debian'
it { is_expected.to contain_apt__key('zabbix-FBABD5F') } if facts[:os]['family'] == 'Debian'
it { is_expected.to contain_apt__key('zabbix-A1848F5') } if (facts[:os]['name'] == 'Debian' && Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '12') < 0) || (facts[:os]['name'] == 'Ubuntu' && Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '22.04') < 0)
it { is_expected.to contain_apt__key('zabbix-FBABD5F') } if (facts[:os]['name'] == 'Debian' && Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '12') < 0) || (facts[:os]['name'] == 'Ubuntu' && Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '22.04') < 0)
it { is_expected.to contain_apt__keyring('zabbix-official-repo.asc') } if (facts[:os]['name'] == 'Debian' && Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '12') >= 0) || (facts[:os]['name'] == 'Ubuntu' && Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '22.04') >= 0)
it { is_expected.to contain_apt__source('zabbix') } if facts[:os]['family'] == 'Debian'
it { is_expected.to contain_yumrepo('zabbix') } if facts[:os]['family'] == 'RedHat'
it { is_expected.to contain_yumrepo('zabbix-nonsupported') } if facts[:os]['family'] == 'RedHat'
Expand Down
Loading