Skip to content

Commit

Permalink
Merge pull request #751 from bastelfreak/zabbix5
Browse files Browse the repository at this point in the history
Bump default Zabbix version on linux 3.4->5.0
  • Loading branch information
bastelfreak authored Mar 23, 2021
2 parents d6ec11b + 1ffa3dd commit 3dad872
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 94 deletions.
4 changes: 1 addition & 3 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,8 @@

if downcase($facts['kernel']) == 'windows' {
$zabbix_version = '4.4.5'
} elsif $facts['os']['name'] == 'Debian' and Integer($facts['os']['release']['major']) == 10 {
$zabbix_version = '4.0'
} else {
$zabbix_version = '3.4'
$zabbix_version = '5.0'
}

$manage_startup_script = downcase($facts['kernel']) ? {
Expand Down
7 changes: 2 additions & 5 deletions spec/classes/agent_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,8 @@
else
'/etc/zabbix/zabbix_agentd.d'
end
zabbix_version = if facts[:os]['name'] == 'Debian' && facts[:os]['release']['major'].to_i == 10
'4.0'
else
'3.4'
end
zabbix_version = '5.0'

let :facts do
facts.merge(systemd_fact)
end
Expand Down
34 changes: 9 additions & 25 deletions spec/classes/proxy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
let :params do
{
zabbix_server_host: '192.168.1.1',
zabbix_version: '2.4'
}
end

Expand All @@ -45,23 +44,22 @@
}
end

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

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

it { is_expected.to contain_class('zabbix::repo').with_zabbix_version('2.4') }
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]') }
it { is_expected.to contain_package('zabbix-proxy').with_ensure('present') }
end

describe 'with enabled selinux' do
Expand Down Expand Up @@ -117,7 +115,7 @@
end

it { is_expected.to contain_class('zabbix::database::postgresql').with_zabbix_type('proxy') }
it { is_expected.to contain_class('zabbix::database::postgresql').with_zabbix_version('3.4') }
it { is_expected.to contain_class('zabbix::database::postgresql').with_zabbix_version('5.0') }
it { is_expected.to contain_class('zabbix::database::postgresql').with_database_name('zabbix_proxy') }
it { is_expected.to contain_class('zabbix::database::postgresql').with_database_user('zabbix-proxy') }
it { is_expected.to contain_class('zabbix::database::postgresql').with_database_password('zabbix-proxy') }
Expand All @@ -137,7 +135,7 @@
end

it { is_expected.to contain_class('zabbix::database::mysql').with_zabbix_type('proxy') }
it { is_expected.to contain_class('zabbix::database::mysql').with_zabbix_version('3.4') }
it { is_expected.to contain_class('zabbix::database::mysql').with_zabbix_version('5.0') }
it { is_expected.to contain_class('zabbix::database::mysql').with_database_name('zabbix_proxy') }
it { is_expected.to contain_class('zabbix::database::mysql').with_database_user('zabbix-proxy') }
it { is_expected.to contain_class('zabbix::database::mysql').with_database_password('zabbix-proxy') }
Expand Down Expand Up @@ -267,7 +265,7 @@
vmwarefrequency: '60',
zabbix_server_host: '192.168.1.1',
zabbix_server_port: '10051',
zabbix_version: '2.2'
zabbix_version: '5.0'
}
end

Expand Down Expand Up @@ -310,7 +308,6 @@
it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^CacheSize=8M$} }
it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartDBSyncers=4$} }
it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^HistoryCacheSize=16M$} }
it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^HistoryTextCacheSize=8M$} }
it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^Timeout=20$} }
it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TrapperTimeout=16$} }
it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^UnreachablePeriod=45$} }
Expand All @@ -328,7 +325,7 @@
it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^LoadModule=pizza$} }
end

context 'with zabbix_proxy.conf and version 3.0' do
context 'with zabbix_proxy.conf and version 4.0' do
let :params do
{
tlsaccept: 'cert',
Expand All @@ -340,7 +337,7 @@
tlsservercertsubject: 'MyZabbix',
tlspskidentity: '/etc/zabbix/keys/identity.file',
tlspskfile: '/etc/zabbix/keys/file.key',
zabbix_version: '3.0'
zabbix_version: '4.0'
}
end

Expand All @@ -355,19 +352,6 @@
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 3.4' do
let :params do
{
enableremotecommands: 1,
logremotecommands: 1,
zabbix_version: '3.4'
}
end

it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^EnableRemoteCommands=1$} }
it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^LogRemoteCommands=1$} }
end

context 'with zabbix_proxy.conf and version 5.0' do
let :params do
{
Expand Down
8 changes: 4 additions & 4 deletions spec/classes/repo_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@
end

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

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

when '7'
Expand Down
7 changes: 1 addition & 6 deletions spec/classes/sender_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,7 @@
if %w[Archlinux Gentoo].include?(facts[:osfamily])
it { is_expected.not_to compile.with_all_deps }
else
zabbix_version = if facts[:os]['name'] == 'Debian' && facts[:os]['release']['major'].to_i == 10
'4.0'
else
'3.4'
end
it { is_expected.to contain_class('zabbix::repo').with_zabbix_version(zabbix_version) }
it { is_expected.to contain_class('zabbix::repo').with_zabbix_version('5.0') }
it { is_expected.to contain_package('zabbix-sender').with_require('Class[Zabbix::Repo]') }
end

Expand Down
6 changes: 1 addition & 5 deletions spec/classes/server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@
facts.merge(systemd_fact)
end

zabbix_version = if facts[:os]['name'] == 'Debian' && facts[:os]['release']['major'].to_i == 10
'4.0'
else
'3.4'
end
zabbix_version = '5.0'

describe 'with default settings' do
it { is_expected.to contain_class('zabbix::repo') }
Expand Down
90 changes: 44 additions & 46 deletions spec/classes/web_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@
end

on_supported_os.each do |os, facts|
next if facts[:os]['name'] == 'windows'
context "on #{os} " do
let :facts do
facts
end

if facts[:osfamily] == 'Archlinux' || facts[:osfamily] == 'Gentoo'
context 'with all defaults' do
it { is_expected.not_to compile }
%w[4.0 5.0].each do |zabbix_version|
next if facts[:os]['name'] == 'windows'
next if facts[:os]['name'] == 'Archlinux'
next if facts[:os]['name'] == 'Gentoo'
next if facts[:os]['name'] == 'Debian' and facts[:os]['release']['major'] == '9'
next if facts[:os]['name'] == 'Ubuntu' and facts[:os]['release']['major'] == '16.04'

context "on #{os} " do
let :facts do
facts
end
else

context 'with all defaults' do
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_file('/etc/zabbix/web').with_ensure('directory') }
Expand Down Expand Up @@ -53,52 +54,48 @@
it { is_expected.not_to contain_selboolean('httpd_can_connect_zabbix') }
end

%w[4.4 5.0].each do |zabbix_version|
describe "with database_type as postgresql and zabbix_version #{zabbix_version}" do
next if zabbix_version == '5.0' and %w[Debian Ubuntu].include?(facts[:osfamily]) and
%w[16.04 9].include?(facts[:operatingsystemmajrelease])
let :params do
super().merge(database_type: 'postgresql')
super().merge(zabbix_version: zabbix_version)
end

pgsqlpackage = case facts[:operatingsystem]
when 'Ubuntu'
if facts[:operatingsystemmajrelease] >= '16.04'
'php-pgsql'
else
'php5-pgsql'
end
when 'Debian'
if facts[:operatingsystemmajrelease].to_i >= 9
'php-pgsql'
else
'php5-pgsql'
end
describe "with database_type as postgresql and zabbix_version #{zabbix_version}" do
let :params do
super().merge(database_type: 'postgresql')
super().merge(zabbix_version: zabbix_version)
end

pgsqlpackage = case facts[:operatingsystem]
when 'Ubuntu'
if facts[:operatingsystemmajrelease] >= '16.04'
'php-pgsql'
else
'php5-pgsql'
end
when 'Debian'
if facts[:operatingsystemmajrelease].to_i >= 9
'php-pgsql'
else
'php5-pgsql'
end

packages = if facts[:osfamily] == 'RedHat'
if facts[:operatingsystemmajrelease].to_i == 7 &&
!%w[VirtuozzoLinux OracleLinux Scientific].include?(facts[:os]['name']) &&
zabbix_version == '5.0'
['zabbix-web-pgsql-scl', 'zabbix-web']
else
['zabbix-web-pgsql', 'zabbix-web']
'php5-pgsql'
end

packages = if facts[:osfamily] == 'RedHat'
if facts[:operatingsystemmajrelease].to_i == 7 &&
!%w[VirtuozzoLinux OracleLinux Scientific].include?(facts[:os]['name']) &&
zabbix_version == '5.0'
['zabbix-web-pgsql-scl', 'zabbix-web']
else
['zabbix-frontend-php', pgsqlpackage]
['zabbix-web-pgsql', 'zabbix-web']
end
else
['zabbix-frontend-php', pgsqlpackage]
end

packages.each do |package|
it { is_expected.to contain_package(package) }
end
it { is_expected.to contain_file('/etc/zabbix/web/zabbix.conf.php').with_content(%r{^\$DB\['TYPE'\] = 'POSTGRESQL'}) }
packages.each do |package|
it { is_expected.to contain_package(package) }
end
it { is_expected.to contain_file('/etc/zabbix/web/zabbix.conf.php').with_content(%r{^\$DB\['TYPE'\] = 'POSTGRESQL'}) }
end

describe 'with database_type as mysql' do
describe 'with database_type as mysql', if: facts[:os]['release']['major'] != '7' && facts[:os]['family'] != 'RedHat' do
let :params do
super().merge(database_type: 'mysql')
end
Expand Down Expand Up @@ -201,7 +198,8 @@
database_password: 'zabbix-server',
zabbix_server: 'localhost',
zabbix_listenport: '3306',
zabbix_server_name: 'localhost'
zabbix_server_name: 'localhost',
zabbix_version: '4.0'
)
end

Expand Down

0 comments on commit 3dad872

Please sign in to comment.