From 586d6fe89c133edfd6188a96c5799d10d0e2ba84 Mon Sep 17 00:00:00 2001 From: Evgeni Golov Date: Tue, 7 Nov 2023 09:13:55 +0100 Subject: [PATCH] remove old version comparison guards for Zabbix pre 5.0 we don't support 4.x anymore, so anything that's checking for versions before 5.0 can be safely removed --- manifests/params.pp | 5 +---- manifests/repo.pp | 2 +- manifests/web.pp | 28 +++++++++------------------- spec/classes/web_spec.rb | 5 ++--- templates/zabbix_agentd.conf.erb | 14 -------------- templates/zabbix_proxy.conf.erb | 6 ------ templates/zabbix_server.conf.erb | 6 ------ 7 files changed, 13 insertions(+), 53 deletions(-) diff --git a/manifests/params.pp b/manifests/params.pp index f7567935d..0023e8e29 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -466,10 +466,7 @@ $proxy_zabbix_server_host = undef $proxy_zabbix_server_port = '10051' $proxy_zbx_templates = ['Template App Zabbix Proxy'] - $proxy_socketdir = versioncmp($zabbix_version, '5.0') ? { - -1 => undef, - default => '/var/run/zabbix', - } + $proxy_socketdir = '/var/run/zabbix' # Java Gateway specific params $javagateway_listenip = '0.0.0.0' diff --git a/manifests/repo.pp b/manifests/repo.pp index b0a176d82..1bf0b4b2d 100644 --- a/manifests/repo.pp +++ b/manifests/repo.pp @@ -87,7 +87,7 @@ } } - if ($facts['os']['release']['major'] == '7' and versioncmp($zabbix_version, '5.0') >= 0) { + if ($facts['os']['release']['major'] == '7') { case $facts['os']['name'] { 'CentOS': { $scl_package_name = 'centos-release-scl' diff --git a/manifests/web.pp b/manifests/web.pp index 18116e556..ae0f575de 100644 --- a/manifests/web.pp +++ b/manifests/web.pp @@ -149,14 +149,6 @@ fail("${facts['os']['family']} is currently not supported for zabbix::web") } - # zabbix frontend 5.x is not supported, among others, on stretch and xenial. - # https://www.zabbix.com/documentation/current/manual/installation/frontend/frontend_on_debian - if $facts['os']['name'] in ['ubuntu', 'debian'] and versioncmp($zabbix_version, '5') >= 0 { - if versioncmp($facts['os']['release']['major'], '9') == 0 { - fail("${facts['os']['family']} ${$facts['os']['release']['major']} is not supported for zabbix::web") - } - } - # Only include the repo class if it has not yet been included unless defined(Class['Zabbix::Repo']) { class { 'zabbix::repo': @@ -231,7 +223,7 @@ } 'RedHat': { $zabbix_web_package = 'zabbix-web' - if ($facts['os']['release']['major'] == '7' and versioncmp($zabbix_version, '5.0') >= 0) { + if ($facts['os']['release']['major'] == '7') { package { "zabbix-web-${db}-scl": ensure => $zabbix_package_state, before => Package[$zabbix_web_package], @@ -285,22 +277,20 @@ } # For API to work on Zabbix 5.x zabbix.conf.php needs to be in the root folder. - if versioncmp($zabbix_version, '5') >= 0 { - file { '/etc/zabbix/zabbix.conf.php': - ensure => link, - target => '/etc/zabbix/web/zabbix.conf.php', - owner => $web_config_owner, - group => $web_config_group, - mode => '0640', - } + file { '/etc/zabbix/zabbix.conf.php': + ensure => link, + target => '/etc/zabbix/web/zabbix.conf.php', + owner => $web_config_owner, + group => $web_config_group, + mode => '0640', } # Is set to true, it will create the apache vhost. if $manage_vhost { include apache include apache::mod::dir - if $facts['os']['family'] == 'RedHat' and versioncmp($facts['os']['release']['major'], '7') >= 0 and versioncmp($zabbix_version, '5') >= 0 { - if versioncmp($facts['os']['release']['major'], '7') == 0 { + if $facts['os']['family'] == 'RedHat' { + if $facts['os']['release']['major'] == '7' { $fpm_service = 'rh-php72-php-fpm' # PHP parameters are moved to /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf per package zabbix-web-deps-scl $fpm_scl_prefix = '/opt/rh/rh-php72' diff --git a/spec/classes/web_spec.rb b/spec/classes/web_spec.rb index babbb0bd0..2ee26d1c9 100644 --- a/spec/classes/web_spec.rb +++ b/spec/classes/web_spec.rb @@ -50,7 +50,7 @@ class { 'apache': it { is_expected.to contain_package('zabbix-required-scl-repo') } if facts[:os]['family'] == 'RedHat' && facts[:os]['release']['major'] == '7' it { is_expected.to contain_service('rh-php72-php-fpm') } if facts[:os]['family'] == 'RedHat' && facts[:os]['release']['major'] == '7' it { is_expected.to contain_file('/etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf') } if facts[:os]['family'] == 'RedHat' && facts[:os]['release']['major'] == '7' - it { is_expected.to contain_file('/etc/zabbix/zabbix.conf.php') } if facts[:os]['family'] == 'RedHat' && facts[:os]['release']['major'] == '7' && Puppet::Util::Package.versioncmp(zabbix_version, '5.0') >= 0 + it { is_expected.to contain_file('/etc/zabbix/zabbix.conf.php') } if facts[:os]['family'] == 'RedHat' && facts[:os]['release']['major'] == '7' it { is_expected.to contain_service('php-fpm') } if facts[:os]['family'] == 'RedHat' && facts[:os]['release']['major'] >= '8' it { is_expected.to contain_file('/etc/php-fpm.d/zabbix.conf') } if facts[:os]['family'] == 'RedHat' && facts[:os]['release']['major'] >= '8' end @@ -91,8 +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']) && - Puppet::Util::Package.versioncmp(zabbix_version, '5.0') >= 0 + !%w[VirtuozzoLinux OracleLinux Scientific].include?(facts[:os]['name']) %w[zabbix-web-pgsql-scl zabbix-web] else %w[zabbix-web-pgsql zabbix-web] diff --git a/templates/zabbix_agentd.conf.erb b/templates/zabbix_agentd.conf.erb index 91334e985..db7b0d1c0 100644 --- a/templates/zabbix_agentd.conf.erb +++ b/templates/zabbix_agentd.conf.erb @@ -48,7 +48,6 @@ DebugLevel=<%= @debuglevel %> # <% if @sourceip %>SourceIP=<%= @sourceip %><% end %> -<% if @zabbix_version.to_f >= 5.0 %> ### Option: AllowKey # Allow execution of item keys matching pattern. # Multiple keys matching rules may be defined in combination with DenyKey. @@ -72,16 +71,6 @@ DebugLevel=<%= @debuglevel %> # Mandatory: no # Default: <% if @denykey %>DenyKey=<%= @denykey -%><% end %> -<% end %> - -<% if @zabbix_version.to_f < 5.0 %> -### Option: EnableRemoteCommands -# Whether remote commands from Zabbix server are allowed. -# 0 - not allowed -# 1 - allowed -# -EnableRemoteCommands=<%= @enableremotecommands %> -<% end %> ### Option: LogRemoteCommands # Enable logging of executed shell commands as warnings. @@ -375,7 +364,6 @@ LoadModulePath=<%= @loadmodulepath %> # TLSPSKFile= <% if @tlspskfile %>TLSPSKFile=<%= @tlspskfile %><% end %> -<% if @zabbix_version.to_f >= 5.0 %> ### Option: TLSCipherCert13 # Cipher string for OpenSSL 1.1.1 or newer in TLS 1.3. # Override the default ciphersuite selection criteria for certificate-based encryption. @@ -439,5 +427,3 @@ LoadModulePath=<%= @loadmodulepath %> # Mandatory: no # Default: <% if @tlscipherall %>TLSCipherAll=<%= @tlscipherall %><% end %> - -<% end %> diff --git a/templates/zabbix_proxy.conf.erb b/templates/zabbix_proxy.conf.erb index 97c46f365..610d0aeed 100644 --- a/templates/zabbix_proxy.conf.erb +++ b/templates/zabbix_proxy.conf.erb @@ -85,7 +85,6 @@ DebugLevel=<%= @debuglevel %> # PidFile=<%= @pidfile %> -<% if @zabbix_version.to_f >= 5.0 %> ### Option: SocketDir # IPC socket directory. # Directory to store IPC sockets used by internal Zabbix services. @@ -94,7 +93,6 @@ PidFile=<%= @pidfile %> # Default: <% if @socketdir %>SocketDir=<%= @socketdir %><% end %> -<% end %> ### Option: DBHost # Database host name. @@ -516,7 +514,6 @@ LoadModulePath=<%= @loadmodulepath %> <% if @tlspskfile %>TLSPSKFile=<%= @tlspskfile %><% end %> ####### For advanced users - TLS ciphersuite selection criteria ####### -<% if @zabbix_version.to_f >= 5.0 %> ### Option: DBTLSConnect # Setting this option enforces to use TLS connection to database. # required - connect using TLS @@ -572,9 +569,7 @@ LoadModulePath=<%= @loadmodulepath %> # Mandatory no # Default: <% if @database_tlscipher13 %>DBTLSCipher13=<%= @database_tlscipher13 %><% end %> -<% end %> -<% if @zabbix_version.to_f >= 5.0 %> ### Option: TLSCipherCert13 # Cipher string for OpenSSL 1.1.1 or newer in TLS 1.3. # Override the default ciphersuite selection criteria for certificate-based encryption. @@ -644,7 +639,6 @@ LoadModulePath=<%= @loadmodulepath %> # Default: # TLSCipherAll13= <% if @tlscipherall %>TLSCipherAll=<%= @tlscipherall %><% end %> -<% end %> <% if @zabbix_version.to_f >= 5.2 %> ### Option: VaultToken diff --git a/templates/zabbix_server.conf.erb b/templates/zabbix_server.conf.erb index 169076f69..e0f14d32c 100644 --- a/templates/zabbix_server.conf.erb +++ b/templates/zabbix_server.conf.erb @@ -384,7 +384,6 @@ ProxyConfigFrequency=<%= @proxyconfigfrequency %> # ProxyDataFrequency=<%= @proxydatafrequency %> -<% if @zabbix_version.to_f >= 5.0 %> ### Option: StartLLDProcessors # Number of pre-forked instances of low level discovery processors. # @@ -393,7 +392,6 @@ ProxyDataFrequency=<%= @proxydatafrequency %> # Default: # StartLLDProcessors=2 <% if @startlldprocessors %>StartLLDProcessors=<%= @startlldprocessors -%><% end %> -<% end %> ### Option: AllowRoot # Allow the server to run as 'root'. If disabled and the server is started by 'root', the server @@ -490,7 +488,6 @@ LoadModulePath=<%= @loadmodulepath %> <% if @tlskeyfile %>TLSKeyFile=<%= @tlskeyfile %><% end %> ####### For advanced users - TLS ciphersuite selection criteria ####### -<% if @zabbix_version.to_f >= 5.0 %> ### Option: DBTLSConnect # Setting this option enforces to use TLS connection to database. # required - connect using TLS @@ -546,9 +543,7 @@ LoadModulePath=<%= @loadmodulepath %> # Mandatory no # Default: <% if @database_tlscipher13 %>DBTLSCipher13=<%= @database_tlscipher13 %><% end %> -<% end %> -<% if @zabbix_version.to_f >= 5.0 %> ### Option: TLSCipherCert13 # Cipher string for OpenSSL 1.1.1 or newer in TLS 1.3. # Override the default ciphersuite selection criteria for certificate-based encryption. @@ -618,7 +613,6 @@ LoadModulePath=<%= @loadmodulepath %> # Default: # TLSCipherAll13= <% if @tlscipherall %>TLSCipherAll=<%= @tlscipherall %><% end %> -<% end %> <% if @zabbix_version.to_f >= 5.2 %> ### Option: VaultToken