From 8b071c26f69bb6421d71fc77f75389d91eb52020 Mon Sep 17 00:00:00 2001 From: Roberto Valentini Date: Thu, 27 Jun 2024 17:21:47 +0200 Subject: [PATCH 1/7] Change manage_startup_script default to false Set manage_startup_script to false on OS that provide correct systemd unit in package --- manifests/params.pp | 13 ++++---- spec/classes/agent_spec.rb | 51 ++++++++++++++++------------- spec/classes/server_spec.rb | 32 +++++++++--------- spec/defines/userparameters_spec.rb | 4 +-- 4 files changed, 54 insertions(+), 46 deletions(-) diff --git a/manifests/params.pp b/manifests/params.pp index 7b2c0c9b5..98ecd4162 100755 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -20,6 +20,7 @@ $server_zabbix_user = 'zabbix' $zabbix_package_provider = undef $agent_loadmodulepath = '/usr/lib/modules' + $manage_startup_script = false } 'AIX': { $manage_repo = false @@ -32,6 +33,7 @@ $agent_config_group = 'zabbix' $agent_pidfile = '/var/run/zabbix/zabbix_agentd.pid' $agent_servicename = 'zabbix-agent' + $manage_startup_script = true } 'Archlinux': { $server_fpinglocation = '/usr/bin/fping' @@ -51,6 +53,7 @@ $server_zabbix_user = 'zabbix-server' $zabbix_package_provider = undef $agent_loadmodulepath = '/usr/lib/modules' + $manage_startup_script = false } 'FreeBSD': { $manage_repo = false @@ -66,6 +69,7 @@ $server_zabbix_user = 'zabbix' $zabbix_package_provider = undef $agent_loadmodulepath = '/usr/local/lib/zabbix/modules' + $manage_startup_script = false } 'Gentoo': { $server_fpinglocation = '/usr/sbin/fping' @@ -85,6 +89,7 @@ $server_zabbix_user = 'zabbix' $zabbix_package_provider = undef $agent_loadmodulepath = '/usr/lib/modules' + $manage_startup_script = false } 'windows': { $manage_repo = false @@ -99,6 +104,7 @@ $agent_servicename = 'Zabbix Agent' $agent_include = 'C:/ProgramData/zabbix/zabbix_agentd.d' $agent_loadmodulepath = undef + $manage_startup_script = false } default : { $server_fpinglocation = '/usr/sbin/fping' @@ -118,6 +124,7 @@ $server_zabbix_user = 'zabbix' $zabbix_package_provider = undef $agent_loadmodulepath = '/usr/lib/modules' + $manage_startup_script = false } } @@ -129,12 +136,6 @@ $zabbix_version = '6.0' } - $manage_startup_script = downcase($facts['kernel']) ? { - 'windows' => false, - 'FreeBSD' => false, - default => true, - } - $zabbix_package_state = 'present' $zabbix_proxy = 'localhost' $zabbix_proxy_ip = '127.0.0.1' diff --git a/spec/classes/agent_spec.rb b/spec/classes/agent_spec.rb index 856c3c954..edae4c834 100644 --- a/spec/classes/agent_spec.rb +++ b/spec/classes/agent_spec.rb @@ -86,11 +86,10 @@ is_expected.to contain_service(service_name). with_ensure('running'). with_enable(true). - with_service_provider(facts[:os]['family'] == 'AIX' ? 'init' : nil). - that_requires(["Package[#{package_name}]", "Zabbix::Startup[#{service_name}]"]) + with_service_provider(facts[:os]['family'] == 'AIX' ? 'init' : nil) end - it { is_expected.to contain_zabbix__startup(service_name).that_requires("Package[#{package_name}]") } + it { is_expected.not_to contain_zabbix__startup(service_name) } it { is_expected.to compile.with_all_deps } it { is_expected.to contain_class('zabbix::params') } end @@ -218,29 +217,37 @@ it { is_expected.not_to contain_firewall('150 zabbix-agent from 10.11.12.13') } end - context 'it creates a startup script' do - if facts[:kernel] == 'Linux' - case facts[:os]['family'] - when 'Archlinux', 'Debian', 'Gentoo', 'RedHat' - it { is_expected.to contain_file("/etc/init.d/#{service_name}").with_ensure('absent') } - it { is_expected.to contain_file("/etc/systemd/system/#{service_name}.service").with_ensure('file') } - when 'windows' - it { is_expected.to contain_exec("install_agent_#{service_name}") } - else - it { is_expected.to contain_file("/etc/init.d/#{service_name}").with_ensure('file') } - it { is_expected.not_to contain_file("/etc/systemd/system/#{service_name}.service") } - end - end - end - - context 'when declaring manage_startup_script is false' do + context 'when declaring manage_startup_script is true' do let :params do { - manage_startup_script: false + manage_startup_script: true } end - it { is_expected.not_to contain_zabbix__startup(service_name) } + context 'it creates a startup script' do + if facts[:kernel] == 'Linux' + case facts[:os]['family'] + when 'Archlinux', 'Debian', 'Gentoo', 'RedHat' + it { is_expected.to contain_file("/etc/init.d/#{service_name}").with_ensure('absent') } + it { is_expected.to contain_file("/etc/systemd/system/#{service_name}.service").with_ensure('file') } + when 'windows' + it { is_expected.to contain_exec("install_agent_#{service_name}") } + else + it { is_expected.to contain_file("/etc/init.d/#{service_name}").with_ensure('file') } + it { is_expected.not_to contain_file("/etc/systemd/system/#{service_name}.service") } + end + end + end + + it do + is_expected.to contain_service(service_name). + with_ensure('running'). + with_enable(true). + with_service_provider(facts[:os]['family'] == 'AIX' ? 'init' : nil). + that_requires(["Package[#{package_name}]", "Zabbix::Startup[#{service_name}]"]) + end + + it { is_expected.to contain_zabbix__startup(service_name).that_requires("Package[#{package_name}]") } end context 'when declaring zabbix_alias' do @@ -460,7 +467,7 @@ end end - describe 'with systemd active' do + describe 'with systemd active', skip: 'user package provided instead systemd::unit_file ' do if facts[:kernel] == 'Linux' let :facts do super().merge(systemd: true) diff --git a/spec/classes/server_spec.rb b/spec/classes/server_spec.rb index 6de4ba196..0d343037a 100644 --- a/spec/classes/server_spec.rb +++ b/spec/classes/server_spec.rb @@ -25,7 +25,7 @@ it { is_expected.to contain_class('zabbix::repo') } it { is_expected.to contain_class('zabbix::params') } it { is_expected.to contain_service('zabbix-server').with_ensure('running') } - it { is_expected.to contain_zabbix__startup('zabbix-server') } + 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' @@ -159,26 +159,26 @@ it { is_expected.not_to contain_firewall('151 zabbix-server') } end - context 'it creates a startup script' do - case facts[:os]['family'] - when 'Archlinux', 'Debian', 'Gentoo', 'RedHat' - it { is_expected.to contain_file('/etc/init.d/zabbix-server').with_ensure('absent') } - it { is_expected.to contain_file('/etc/systemd/system/zabbix-server.service').with_ensure('file') } - it { is_expected.to contain_systemd__unit_file('zabbix-server.service') } - else - it { is_expected.to contain_file('/etc/init.d/zabbix-server').with_ensure('file') } - it { is_expected.not_to contain_file('/etc/systemd/system/zabbix-server.service') } - end - end - - context 'when declaring manage_startup_script is false' do + context 'when declaring manage_startup_script is true' do let :params do { - manage_startup_script: false + manage_startup_script: true } end - it { is_expected.not_to contain_zabbix__startup('zabbix-server') } + context 'it creates a startup script' do + case facts[:os]['family'] + when 'Archlinux', 'Debian', 'Gentoo', 'RedHat' + it { is_expected.to contain_file('/etc/init.d/zabbix-server').with_ensure('absent') } + it { is_expected.to contain_file('/etc/systemd/system/zabbix-server.service').with_ensure('file') } + it { is_expected.to contain_systemd__unit_file('zabbix-server.service') } + else + it { is_expected.to contain_file('/etc/init.d/zabbix-server').with_ensure('file') } + it { is_expected.not_to contain_file('/etc/systemd/system/zabbix-server.service') } + end + end + + it { is_expected.to contain_zabbix__startup('zabbix-server') } end # If manage_service is true (default), it should create a service diff --git a/spec/defines/userparameters_spec.rb b/spec/defines/userparameters_spec.rb index 8baef3f1c..a49949a4e 100644 --- a/spec/defines/userparameters_spec.rb +++ b/spec/defines/userparameters_spec.rb @@ -22,12 +22,12 @@ it { is_expected.to contain_class('zabbix::params') } it { is_expected.to contain_class('zabbix::repo') } it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_file("/etc/init.d/#{service}") } + it { is_expected.not_to contain_file("/etc/init.d/#{service}") } it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.conf') } it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.d') } it { is_expected.to contain_package(package) } it { is_expected.to contain_service(service) } - it { is_expected.to contain_zabbix__startup(service) } + it { is_expected.not_to contain_zabbix__startup(service) } end context 'with ensure => absent' do From 7f1df97d70f45f3c6e508f6c084f06dbdad68acf Mon Sep 17 00:00:00 2001 From: Roberto Valentini Date: Thu, 27 Jun 2024 14:22:21 +0200 Subject: [PATCH 2/7] Remove VirtuozzoLinux from supported OS --- metadata.json | 6 ------ spec/classes/web_spec.rb | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/metadata.json b/metadata.json index 38cd6ae87..90099b8e6 100644 --- a/metadata.json +++ b/metadata.json @@ -135,12 +135,6 @@ "12" ] }, - { - "operatingsystem": "VirtuozzoLinux", - "operatingsystemrelease": [ - "7" - ] - }, { "operatingsystem": "Archlinux" }, diff --git a/spec/classes/web_spec.rb b/spec/classes/web_spec.rb index 101b47bb3..645021c5c 100644 --- a/spec/classes/web_spec.rb +++ b/spec/classes/web_spec.rb @@ -91,7 +91,7 @@ class { 'apache': packages = if facts[:os]['family'] == 'RedHat' if facts[:os]['release']['major'].to_i == 7 && - !%w[VirtuozzoLinux OracleLinux Scientific].include?(facts[:os]['name']) + !%w[OracleLinux Scientific].include?(facts[:os]['name']) %w[zabbix-web-pgsql-scl zabbix-web] else %w[zabbix-web-pgsql zabbix-web] From f61c84bbc0da0ca96a7acd81ec976844b9cea4f2 Mon Sep 17 00:00:00 2001 From: Roberto Valentini Date: Thu, 27 Jun 2024 14:22:39 +0200 Subject: [PATCH 3/7] Remove XenServer from supported OS --- metadata.json | 6 ------ 1 file changed, 6 deletions(-) diff --git a/metadata.json b/metadata.json index 90099b8e6..973b52949 100644 --- a/metadata.json +++ b/metadata.json @@ -115,12 +115,6 @@ "8" ] }, - { - "operatingsystem": "XenServer", - "operatingsystemrelease": [ - "6" - ] - }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ From c011f23401e1b8e3648b616424b6bc047a1bd223 Mon Sep 17 00:00:00 2001 From: Roberto Valentini Date: Thu, 27 Jun 2024 14:22:45 +0200 Subject: [PATCH 4/7] Remove CloudLinux from supported OS --- metadata.json | 7 ------- 1 file changed, 7 deletions(-) diff --git a/metadata.json b/metadata.json index 973b52949..aeb485889 100644 --- a/metadata.json +++ b/metadata.json @@ -108,13 +108,6 @@ "9" ] }, - { - "operatingsystem": "CloudLinux", - "operatingsystemrelease": [ - "7", - "8" - ] - }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ From 1456de4a13fd3f8353b71eb92d5488529d71058c Mon Sep 17 00:00:00 2001 From: Roberto Valentini Date: Thu, 27 Jun 2024 14:22:49 +0200 Subject: [PATCH 5/7] Remove Scientific from supported OS --- metadata.json | 7 ------- spec/classes/web_spec.rb | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/metadata.json b/metadata.json index aeb485889..a68262671 100644 --- a/metadata.json +++ b/metadata.json @@ -79,13 +79,6 @@ "9" ] }, - { - "operatingsystem": "Scientific", - "operatingsystemrelease": [ - "7", - "8" - ] - }, { "operatingsystem": "CentOS", "operatingsystemrelease": [ diff --git a/spec/classes/web_spec.rb b/spec/classes/web_spec.rb index 645021c5c..6fee84aff 100644 --- a/spec/classes/web_spec.rb +++ b/spec/classes/web_spec.rb @@ -91,7 +91,7 @@ class { 'apache': packages = if facts[:os]['family'] == 'RedHat' if facts[:os]['release']['major'].to_i == 7 && - !%w[OracleLinux Scientific].include?(facts[:os]['name']) + !%w[OracleLinux].include?(facts[:os]['name']) %w[zabbix-web-pgsql-scl zabbix-web] else %w[zabbix-web-pgsql zabbix-web] From f096892b5adfa4515150ad929d4ec175ce2987ba Mon Sep 17 00:00:00 2001 From: Roberto Valentini Date: Thu, 27 Jun 2024 14:22:58 +0200 Subject: [PATCH 6/7] Remove Amazon from supported OS --- manifests/repo.pp | 12 +----------- metadata.json | 7 ------- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/manifests/repo.pp b/manifests/repo.pp index 4a7674566..41b88b015 100644 --- a/manifests/repo.pp +++ b/manifests/repo.pp @@ -18,19 +18,9 @@ String[1] $zabbix_version = $zabbix::params::zabbix_version, ) inherits zabbix::params { if $manage_repo { - case $facts['os']['name'] { - 'PSBM': { - $majorrelease = '6' - } - 'Amazon': { - $majorrelease = '6' - } - default: { - $majorrelease = $facts['os']['release']['major'] - } - } case $facts['os']['family'] { 'RedHat': { + $majorrelease = $facts['os']['release']['major'] if (versioncmp(fact('os.release.major'), '7') >= 0 and $zabbix_version == '7.0') { $gpgkey_zabbix = 'https://repo.zabbix.com/RPM-GPG-KEY-ZABBIX-B5333005' $gpgkey_nonsupported = 'https://repo.zabbix.com/RPM-GPG-KEY-ZABBIX-B5333005' diff --git a/metadata.json b/metadata.json index a68262671..dd7f39050 100644 --- a/metadata.json +++ b/metadata.json @@ -64,13 +64,6 @@ "9" ] }, - { - "operatingsystem": "Amazon", - "operatingsystemrelease": [ - "7", - "8" - ] - }, { "operatingsystem": "OracleLinux", "operatingsystemrelease": [ From f00c8c9ad65554053111d342aaa6dc4519c8cd77 Mon Sep 17 00:00:00 2001 From: Roberto Valentini Date: Thu, 27 Jun 2024 14:23:03 +0200 Subject: [PATCH 7/7] Remove Centos 8 from supported OS --- metadata.json | 1 - spec/spec_helper_methods.rb | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/metadata.json b/metadata.json index dd7f39050..315f8ac89 100644 --- a/metadata.json +++ b/metadata.json @@ -76,7 +76,6 @@ "operatingsystem": "CentOS", "operatingsystemrelease": [ "7", - "8", "9" ] }, diff --git a/spec/spec_helper_methods.rb b/spec/spec_helper_methods.rb index 5b3e02063..30ad7aaa8 100644 --- a/spec/spec_helper_methods.rb +++ b/spec/spec_helper_methods.rb @@ -5,7 +5,7 @@ def baseline_os_hash supported_os: [ { 'operatingsystem' => 'CentOS', - 'operatingsystemrelease' => %w[7 8] + 'operatingsystemrelease' => %w[7] }, { 'operatingsystem' => 'Debian',