Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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
12 changes: 7 additions & 5 deletions spec/classes/agent_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require 'spec_helper'
Package = Puppet::Util::Package
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line looks rather odd and I doubt that it's required

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That kind of hackish addition was just to keep the code under a reasonable number of characters per line but i guess after the changes to make the linter happy that ship has sailed anyway.


describe 'zabbix::agent' do
let :node do
Expand Down Expand Up @@ -65,11 +66,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' && Package.versioncmp(facts[:os]['release']['major'], '12') < 0) || (facts[:os]['name'] == 'Ubuntu' && Package.versioncmp(facts[:os]['release']['major'], '22.04') < 0)
it { is_expected.to contain_apt__key('zabbix-FBABD5F') } if (facts[:os]['name'] == 'Debian' && Package.versioncmp(facts[:os]['release']['major'], '12') < 0) || (facts[:os]['name'] == 'Ubuntu' && 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' && Package.versioncmp(facts[:os]['release']['major'], '12') >= 0) || (facts[:os]['name'] == 'Ubuntu' && 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
8 changes: 5 additions & 3 deletions spec/classes/javagateway_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require 'spec_helper'
Package = Puppet::Util::Package

describe 'zabbix::javagateway' do
let :node do
Expand All @@ -27,10 +28,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' && Package.versioncmp(facts[:os]['release']['major'], '12') < 0) || (facts[:os]['name'] == 'Ubuntu' && Package.versioncmp(facts[:os]['release']['major'], '22.04') < 0)
it { is_expected.to contain_apt__key('zabbix-FBABD5F') } if (facts[:os]['name'] == 'Debian' && Package.versioncmp(facts[:os]['release']['major'], '12') < 0) || (facts[:os]['name'] == 'Ubuntu' && 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' && Package.versioncmp(facts[:os]['release']['major'], '12') >= 0) || (facts[:os]['name'] == 'Ubuntu' && Package.versioncmp(facts[:os]['release']['major'], '22.04') >= 0)
end

context 'when declaring manage_repo is true' do
Expand Down
6 changes: 4 additions & 2 deletions spec/classes/repo_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

require 'deep_merge'
require 'spec_helper'
Package = Puppet::Util::Package

describe 'zabbix::repo' do
on_supported_os.each do |os, facts|
Expand All @@ -20,8 +21,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' && Package.versioncmp(facts[:os]['release']['major'], '12') < 0) || (facts[:os]['name'] == 'Ubuntu' && Package.versioncmp(facts[:os]['release']['major'], '22.04') < 0)
it { is_expected.to contain_apt__key('zabbix-FBABD5F') } if (facts[:os]['name'] == 'Debian' && Package.versioncmp(facts[:os]['release']['major'], '12') < 0) || (facts[:os]['name'] == 'Ubuntu' && 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' && Package.versioncmp(facts[:os]['release']['major'], '12') >= 0) || (facts[:os]['name'] == 'Ubuntu' && Package.versioncmp(facts[:os]['release']['major'], '22.04') >= 0)

context 'when repo_location is "https://example.com/foo"' do
let :params do
Expand Down
7 changes: 5 additions & 2 deletions spec/classes/sender_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require 'spec_helper'
Package = Puppet::Util::Package

describe 'zabbix::sender' do
let :node do
Expand Down Expand Up @@ -53,8 +54,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' && Package.versioncmp(facts[:os]['release']['major'], '12') < 0) || (facts[:os]['name'] == 'Ubuntu' && Package.versioncmp(facts[:os]['release']['major'], '22.04') < 0)
it { is_expected.to contain_apt__key('zabbix-FBABD5F') } if (facts[:os]['name'] == 'Debian' && Package.versioncmp(facts[:os]['release']['major'], '12') < 0) || (facts[:os]['name'] == 'Ubuntu' && 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' && Package.versioncmp(facts[:os]['release']['major'], '12') >= 0) || (facts[:os]['name'] == 'Ubuntu' && Package.versioncmp(facts[:os]['release']['major'], '22.04') >= 0)
end
end
end
Expand Down
8 changes: 5 additions & 3 deletions spec/classes/server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

require 'spec_helper'
require 'deep_merge'
Package = Puppet::Util::Package

describe 'zabbix::server' do
let :node do
Expand All @@ -27,9 +28,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' && Package.versioncmp(facts[:os]['release']['major'], '12') < 0) || (facts[:os]['name'] == 'Ubuntu' && Package.versioncmp(facts[:os]['release']['major'], '22.04') < 0)
it { is_expected.to contain_apt__key('zabbix-FBABD5F') } if (facts[:os]['name'] == 'Debian' && Package.versioncmp(facts[:os]['release']['major'], '12') < 0) || (facts[:os]['name'] == 'Ubuntu' && 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' && Package.versioncmp(facts[:os]['release']['major'], '12') >= 0) || (facts[:os]['name'] == 'Ubuntu' && Package.versioncmp(facts[:os]['release']['major'], '22.04') >= 0)
end

if facts[:os]['family'] == 'RedHat'
Expand Down
6 changes: 4 additions & 2 deletions spec/classes/web_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

require 'spec_helper'
require 'deep_merge'
Package = Puppet::Util::Package

describe 'zabbix::web' do
let :node do
Expand Down Expand Up @@ -40,8 +41,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' && Package.versioncmp(facts[:os]['release']['major'], '12') < 0) || (facts[:os]['name'] == 'Ubuntu' && Package.versioncmp(facts[:os]['release']['major'], '22.04') < 0)
it { is_expected.to contain_apt__key('zabbix-FBABD5F') } if (facts[:os]['name'] == 'Debian' && Package.versioncmp(facts[:os]['release']['major'], '12') < 0) || (facts[:os]['name'] == 'Ubuntu' && 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' && Package.versioncmp(facts[:os]['release']['major'], '12') >= 0) || (facts[:os]['name'] == 'Ubuntu' && 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