Skip to content

Commit

Permalink
Merge pull request #891 from voxpupuli/drop-zabbix-4.0
Browse files Browse the repository at this point in the history
Drop support for Zabbix 4.0
  • Loading branch information
evgeni committed Oct 4, 2023
2 parents 23a8236 + 94ca591 commit 51527a0
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 174 deletions.
3 changes: 0 additions & 3 deletions manifests/web.pp
Expand Up @@ -188,9 +188,6 @@
if $manage_resources {
# Determine correct zabbixapi version.
case $zabbix_version {
'4.0': {
$zabbixapi_version = '4.2.0'
}
/^[56]\.[024]/: {
$zabbixapi_version = '5.0.0-alpha1'
}
Expand Down
2 changes: 0 additions & 2 deletions spec/acceptance/zabbix_application_spec.rb
Expand Up @@ -9,8 +9,6 @@
next if zabbix_version >= '5.4'

template = case zabbix_version
when '4.0'
'Template OS Linux'
when '5.0'
'Template OS Linux by Zabbix agent'
else
Expand Down
188 changes: 88 additions & 100 deletions spec/acceptance/zabbix_host_spec.rb
Expand Up @@ -14,17 +14,13 @@
# use for custom type tests

template = case zabbix_version
when '4.0'
['Template OS Linux', 'Template Module ICMP Ping']
when '5.0'
['Template OS Linux by Zabbix agent', 'Template Module ICMP Ping']
else
['Linux by Zabbix agent', 'ICMP Ping']
end

template_snmp = case zabbix_version
when '4.0'
['Template OS Linux SNMPv2']
when '5.0'
['Template OS Linux SNMP']
else
Expand Down Expand Up @@ -96,36 +92,33 @@ class { 'zabbix':
apply_manifest(pp2, catch_changes: true)
end

# Zabbix version 4.0 doesn't support interface details hash
if zabbix_version != '4.0'
pp3 = <<-EOS
zabbix_host { 'test3.example.com':
ipaddress => '127.0.0.3',
use_ip => false,
port => 161,
groups => ['Virtual machines'],
templates => #{template_snmp},
macros => [],
interfacetype => 2,
interfacedetails => {"version" => "2", "bulk" => "0", "community" => "public"},
}
zabbix_host { 'test4.example.com':
ipaddress => '127.0.0.4',
use_ip => false,
port => 161,
groups => ['Virtual machines'],
templates => #{template},
macros => [],
}
EOS
pp3 = <<-EOS
zabbix_host { 'test3.example.com':
ipaddress => '127.0.0.3',
use_ip => false,
port => 161,
groups => ['Virtual machines'],
templates => #{template_snmp},
macros => [],
interfacetype => 2,
interfacedetails => {"version" => "2", "bulk" => "0", "community" => "public"},
}
zabbix_host { 'test4.example.com':
ipaddress => '127.0.0.4',
use_ip => false,
port => 161,
groups => ['Virtual machines'],
templates => #{template},
macros => [],
}
EOS

it 'creates hosts with SNMP interface and details without errors' do
apply_manifest(pp3, catch_failures: true)
end
it 'creates hosts with SNMP interface and details without errors' do
apply_manifest(pp3, catch_failures: true)
end

it 'creates hosts with SNMP interface and details without changes' do
apply_manifest(pp3, catch_changes: true)
end
it 'creates hosts with SNMP interface and details without changes' do
apply_manifest(pp3, catch_changes: true)
end

it_behaves_like 'an idempotent resource' do
Expand Down Expand Up @@ -240,97 +233,92 @@ class { 'zabbix':
end
end

# Zabbix version 4.0 doesn't support interface details hash
if zabbix_version != '4.0'

context 'test3.example.com' do
let(:test3) { result_hosts.select { |h| h['host'] == 'test3.example.com' }.first }
context 'test3.example.com' do
let(:test3) { result_hosts.select { |h| h['host'] == 'test3.example.com' }.first }

it 'is created' do
expect(test3['host']).to eq('test3.example.com')
end

it 'is in group Virtual machines' do
expect(test3['groups'].map { |g| g['name'] }).to eq(['Virtual machines'])
end
it 'is created' do
expect(test3['host']).to eq('test3.example.com')
end

it 'has a correct interface dns configured' do
expect(test3['interfaces'][0]['dns']).to eq('test3.example.com')
end
it 'is in group Virtual machines' do
expect(test3['groups'].map { |g| g['name'] }).to eq(['Virtual machines'])
end

it 'has a correct interface ip configured' do
expect(test3['interfaces'][0]['ip']).to eq('127.0.0.3')
end
it 'has a correct interface dns configured' do
expect(test3['interfaces'][0]['dns']).to eq('test3.example.com')
end

it 'has a correct interface main configured' do
expect(test3['interfaces'][0]['main']).to eq('1')
end
it 'has a correct interface ip configured' do
expect(test3['interfaces'][0]['ip']).to eq('127.0.0.3')
end

it 'has a correct interface port configured' do
expect(test3['interfaces'][0]['port']).to eq('161')
end
it 'has a correct interface main configured' do
expect(test3['interfaces'][0]['main']).to eq('1')
end

it 'has a correct interface type configured' do
expect(test3['interfaces'][0]['type']).to eq('2')
end
it 'has a correct interface port configured' do
expect(test3['interfaces'][0]['port']).to eq('161')
end

it 'has a correct interface details configured' do
expect(test3['interfaces'][0]['details']).to eq('version' => '2', 'bulk' => '0', 'community' => 'public')
end
it 'has a correct interface type configured' do
expect(test3['interfaces'][0]['type']).to eq('2')
end

it 'has a correct interface useip configured' do
expect(test3['interfaces'][0]['useip']).to eq('0')
end
it 'has a correct interface details configured' do
expect(test3['interfaces'][0]['details']).to eq('version' => '2', 'bulk' => '0', 'community' => 'public')
end

it 'has templates attached' do
expect(test3['parentTemplates'].map { |t| t['host'] }.sort).to eq(template_snmp.sort)
end
it 'has a correct interface useip configured' do
expect(test3['interfaces'][0]['useip']).to eq('0')
end

context 'test4.example.com' do
let(:test4) { result_hosts.select { |h| h['host'] == 'test4.example.com' }.first }
it 'has templates attached' do
expect(test3['parentTemplates'].map { |t| t['host'] }.sort).to eq(template_snmp.sort)
end
end

it 'is created' do
expect(test4['host']).to eq('test4.example.com')
end
context 'test4.example.com' do
let(:test4) { result_hosts.select { |h| h['host'] == 'test4.example.com' }.first }

it 'is in group Virtual machines' do
expect(test4['groups'].map { |g| g['name'] }).to eq(['Virtual machines'])
end
it 'is created' do
expect(test4['host']).to eq('test4.example.com')
end

it 'has a correct interface dns configured' do
expect(test4['interfaces'][0]['dns']).to eq('test4.example.com')
end
it 'is in group Virtual machines' do
expect(test4['groups'].map { |g| g['name'] }).to eq(['Virtual machines'])
end

it 'has a correct interface ip configured' do
expect(test4['interfaces'][0]['ip']).to eq('127.0.0.4')
end
it 'has a correct interface dns configured' do
expect(test4['interfaces'][0]['dns']).to eq('test4.example.com')
end

it 'has a correct interface main configured' do
expect(test4['interfaces'][0]['main']).to eq('1')
end
it 'has a correct interface ip configured' do
expect(test4['interfaces'][0]['ip']).to eq('127.0.0.4')
end

it 'has a correct interface port configured' do
expect(test4['interfaces'][0]['port']).to eq('161')
end
it 'has a correct interface main configured' do
expect(test4['interfaces'][0]['main']).to eq('1')
end

it 'has a correct interface type configured' do
expect(test4['interfaces'][0]['type']).to eq('1')
end
it 'has a correct interface port configured' do
expect(test4['interfaces'][0]['port']).to eq('161')
end

it 'has a correct interface details configured' do
expect(test4['interfaces'][0]['details']).to eq([])
end
it 'has a correct interface type configured' do
expect(test4['interfaces'][0]['type']).to eq('1')
end

it 'has a correct interface useip configured' do
expect(test4['interfaces'][0]['useip']).to eq('0')
end
it 'has a correct interface details configured' do
expect(test4['interfaces'][0]['details']).to eq([])
end

it 'has templates attached' do
expect(test4['parentTemplates'].map { |t| t['host'] }.sort).to eq(template.sort)
end
it 'has a correct interface useip configured' do
expect(test4['interfaces'][0]['useip']).to eq('0')
end

it 'has templates attached' do
expect(test4['parentTemplates'].map { |t| t['host'] }.sort).to eq(template.sort)
end
end

context 'test5.example.com' do
Expand Down
2 changes: 0 additions & 2 deletions spec/acceptance/zabbix_template_host_spec.rb
Expand Up @@ -12,8 +12,6 @@

context "create zabbix_template_host resources with zabbix version #{zabbix_version}" do
template = case zabbix_version
when '4.0'
'Template OS Linux'
when '5.0'
'Template OS Linux by Zabbix agent'
else
Expand Down
39 changes: 0 additions & 39 deletions spec/classes/proxy_spec.rb
Expand Up @@ -53,18 +53,6 @@
it { is_expected.to contain_yumrepo('zabbix') }
end

describe 'when manage_repo is true and zabbix version is 4.0' do
let :params do
{
manage_repo: true,
zabbix_version: '4.0'
}
end

it { is_expected.to contain_class('zabbix::repo').with_zabbix_version('4.0') }
it { is_expected.to contain_package('zabbix-proxy-pgsql').with_require('Class[Zabbix::Repo]') }
end

describe 'with enabled selinux' do
let :facts do
super().merge(selinux: true)
Expand Down Expand Up @@ -362,33 +350,6 @@
it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSCipherAll13=EECDH\+aRSA\+AES128:RSA\+aRSA\+AES128:kECDHEPSK\+AES128:kPSK\+AES128$} }
end

context 'with zabbix_proxy.conf and version 4.0' do
let :params do
{
tlsaccept: 'cert',
tlscafile: '/etc/zabbix/keys/zabbix-server.ca',
tlscrlfile: '/etc/zabbix/keys/zabbix-server.crl',
tlscertfile: '/etc/zabbix/keys/zabbix-server.crt',
tlskeyfile: '/etc/zabbix/keys/zabbix-server.key',
tlsservercertissuer: 'Zabbix.Com',
tlsservercertsubject: 'MyZabbix',
tlspskidentity: '/etc/zabbix/keys/identity.file',
tlspskfile: '/etc/zabbix/keys/file.key',
zabbix_version: '4.0'
}
end

it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSAccept=cert$} }
it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSCAFile=/etc/zabbix/keys/zabbix-server.ca$} }
it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSCRLFile=/etc/zabbix/keys/zabbix-server.crl$} }
it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSCertFile=/etc/zabbix/keys/zabbix-server.crt$} }
it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSKeyFile=/etc/zabbix/keys/zabbix-server.key$} }
it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSServerCertIssuer=Zabbix.Com$} }
it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSServerCertSubject=MyZabbix$} }
it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSPSKIdentity=/etc/zabbix/keys/identity.file$} }
it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSPSKFile=/etc/zabbix/keys/file.key$} }
end

context 'with zabbix_proxy.conf and version 5.0' do
let :params do
{
Expand Down
26 changes: 0 additions & 26 deletions spec/classes/repo_spec.rb
Expand Up @@ -31,17 +31,6 @@

case facts[:os]['release']['major']
when '10'
context 'on Debian 10 and Zabbix 4.0' do
let :params do
{
zabbix_version: '4.0',
manage_repo: true
}
end

it { is_expected.to contain_apt__source('zabbix').with_location('http://repo.zabbix.com/zabbix/4.0/debian/') }
end

context 'on Debian 10 and Zabbix 5.0' do
let :params do
{
Expand Down Expand Up @@ -82,21 +71,6 @@

case facts[:os]['release']['major']
when '7'

context 'on RedHat 7 and Zabbix 4.0' do
let :params do
{
zabbix_version: '4.0',
manage_repo: true
}
end

it { is_expected.to contain_yumrepo('zabbix').with_baseurl('https://repo.zabbix.com/zabbix/4.0/rhel/7/$basearch/') }
it { is_expected.to contain_yumrepo('zabbix').with_gpgkey('https://repo.zabbix.com/RPM-GPG-KEY-ZABBIX-A14FE591') }
it { is_expected.to contain_yumrepo('zabbix-nonsupported').with_baseurl('https://repo.zabbix.com/non-supported/rhel/7/$basearch/') }
it { is_expected.to contain_yumrepo('zabbix-nonsupported').with_gpgkey('https://repo.zabbix.com/RPM-GPG-KEY-ZABBIX-79EA5ED4') }
end

context 'on RedHat 7 and Zabbix 5.0' do
let :params do
{
Expand Down
2 changes: 1 addition & 1 deletion spec/classes/web_spec.rb
Expand Up @@ -179,7 +179,7 @@
zabbix_server: 'localhost',
zabbix_listenport: '3306',
zabbix_server_name: 'localhost',
zabbix_version: '4.0'
zabbix_version: '6.0'
)
end

Expand Down
2 changes: 1 addition & 1 deletion spec/support/acceptance/supported_versions.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true

def supported_versions
%w[4.0 5.0 6.0]
%w[5.0 6.0]
end

0 comments on commit 51527a0

Please sign in to comment.