diff --git a/README.md b/README.md index da76f8488..ffe9dc3ba 100644 --- a/README.md +++ b/README.md @@ -427,7 +427,7 @@ Take a look at the [REFERENCE.md](https://github.com/voxpupuli/puppet-zabbix/blo ## Limitations -This module supports Zabbix 4.0, 5.0, 5.2 and 5.4. The upstream supported versions are documented [here](https://www.zabbix.com/de/life_cycle_and_release_policy) +This module supports Zabbix 4.0, 5.0, 5.2, 5.4 and 6.0. The upstream supported versions are documented [here](https://www.zabbix.com/de/life_cycle_and_release_policy) Please have a look into the metadata.json for all supported operating systems. This module is supported on both the community and the Enterprise version of Puppet. diff --git a/lib/puppet/provider/zabbix_template/ruby.rb b/lib/puppet/provider/zabbix_template/ruby.rb index c38a5a091..510bb6752 100644 --- a/lib/puppet/provider/zabbix_template/ruby.rb +++ b/lib/puppet/provider/zabbix_template/ruby.rb @@ -57,7 +57,7 @@ def create updateExisting: true }, # templateDashboards was renamed to templateScreen on Zabbix >= 5.2 - (@resource[:zabbix_version] =~ %r{5\.[24]} ? :templateDashboards : :templateScreens) => { + (@resource[:zabbix_version] =~ %r{5\.[24]|6\.0} ? :templateDashboards : :templateScreens) => { createMissing: true, deleteMissing: (@resource[:delete_missing_templatescreens].nil? ? false : @resource[:delete_missing_templatescreens]), updateExisting: true diff --git a/lib/puppet/type/zabbix_template_host.rb b/lib/puppet/type/zabbix_template_host.rb index 3fc61d63c..a55cb4343 100644 --- a/lib/puppet/type/zabbix_template_host.rb +++ b/lib/puppet/type/zabbix_template_host.rb @@ -2,7 +2,7 @@ Puppet::Type.newtype(:zabbix_template_host) do @doc = <<-DOC - Link or Unlink template to host. + Link or Unlink template to host. Only for Zabbix < 6.0! Example. Name should be in the format of "template_name@hostname" diff --git a/manifests/database/mysql.pp b/manifests/database/mysql.pp index bd4aa05b1..cf9aa8d42 100644 --- a/manifests/database/mysql.pp +++ b/manifests/database/mysql.pp @@ -24,7 +24,7 @@ assert_private() if ($database_schema_path == false) or ($database_schema_path == '') { - if versioncmp($zabbix_version, '5.4') == 0 { + if versioncmp($zabbix_version, '5.4') >= 0 { $schema_path = '/usr/share/doc/zabbix-sql-scripts/mysql/' } else { $schema_path = '/usr/share/doc/zabbix-*-mysql*' @@ -42,10 +42,16 @@ case $zabbix_type { 'proxy': { - $zabbix_proxy_create_sql = "cd ${schema_path} && if [ -f schema.sql.gz ]; then gunzip -f schema.sql.gz ; fi && mysql -h '${database_host}' -u '${database_user}' -p'${database_password}' ${port}-D '${database_name}' < schema.sql && touch /etc/zabbix/.schema.done" + $zabbix_proxy_create_sql = versioncmp($zabbix_version, '6.0') >= 0 ? { + true => "cd ${schema_path} && mysql -h '${database_host}' -u '${database_user}' -p'${database_password}' ${port}-D '${database_name}' < proxy.sql && touch /etc/zabbix/.schema.done", + false => "cd ${schema_path} && if [ -f schema.sql.gz ]; then gunzip -f schema.sql.gz ; fi && mysql -h '${database_host}' -u '${database_user}' -p'${database_password}' ${port}-D '${database_name}' < schema.sql && touch /etc/zabbix/.schema.done" + } } default: { - $zabbix_server_create_sql = "cd ${schema_path} && if [ -f create.sql.gz ]; then gunzip -f create.sql.gz ; fi && mysql -h '${database_host}' -u '${database_user}' -p'${database_password}' ${port}-D '${database_name}' < create.sql && touch /etc/zabbix/.schema.done" + $zabbix_server_create_sql = versioncmp($zabbix_version, '6.0') >= 0 ? { + true => "cd ${schema_path} && if [ -f server.sql.gz ]; then gunzip -f server.sql.gz ; fi && mysql -h '${database_host}' -u '${database_user}' -p'${database_password}' ${port}-D '${database_name}' < server.sql && touch /etc/zabbix/.schema.done", + false => "cd ${schema_path} && if [ -f create.sql.gz ]; then gunzip -f create.sql.gz ; fi && mysql -h '${database_host}' -u '${database_user}' -p'${database_password}' ${port}-D '${database_name}' < create.sql && touch /etc/zabbix/.schema.done" + } $zabbix_server_images_sql = 'touch /etc/zabbix/.images.done' $zabbix_server_data_sql = 'touch /etc/zabbix/.data.done' } diff --git a/manifests/database/postgresql.pp b/manifests/database/postgresql.pp index 8d9fde24d..15fb822a3 100644 --- a/manifests/database/postgresql.pp +++ b/manifests/database/postgresql.pp @@ -25,13 +25,13 @@ if ($database_schema_path == false) or ($database_schema_path == '') { if member(['CentOS', 'RedHat', 'OracleLinux', 'VirtuozzoLinux'], $facts['os']['name']) { - if versioncmp($zabbix_version, '5.4') == 0 { + if versioncmp($zabbix_version, '5.4') >= 0 { $schema_path = '/usr/share/doc/zabbix-sql-scripts/postgresql/' } else { $schema_path = "/usr/share/doc/zabbix-*-pgsql-${zabbix_version}*/" } } else { - if versioncmp($zabbix_version, '5.4') == 0 { + if versioncmp($zabbix_version, '5.4') >= 0 { $schema_path = '/usr/share/doc/zabbix-sql-scripts/postgresql/' } else { $schema_path = '/usr/share/doc/zabbix-*-pgsql' @@ -49,10 +49,16 @@ case $zabbix_type { 'proxy': { - $zabbix_proxy_create_sql = "cd ${schema_path} && if [ -f schema.sql.gz ]; then gunzip -f schema.sql.gz ; fi && psql -h '${database_host}' -U '${database_user}' ${port}-d '${database_name}' -f schema.sql && touch /etc/zabbix/.schema.done" + $zabbix_proxy_create_sql = versioncmp($zabbix_version, '6.0') >= 0 ? { + true => "cd ${schema_path} && psql -h '${database_host}' -U '${database_user}' ${port}-d '${database_name}' -f proxy.sql && touch /etc/zabbix/.schema.done", + false => "cd ${schema_path} && if [ -f schema.sql.gz ]; then gunzip -f schema.sql.gz ; fi && psql -h '${database_host}' -U '${database_user}' ${port}-d '${database_name}' -f schema.sql && touch /etc/zabbix/.schema.done" + } } default: { - $zabbix_server_create_sql = "cd ${schema_path} && if [ -f create.sql.gz ]; then gunzip -f create.sql.gz ; fi && psql -h '${database_host}' -U '${database_user}' ${port}-d '${database_name}' -f create.sql && touch /etc/zabbix/.schema.done" + $zabbix_server_create_sql = versioncmp($zabbix_version, '6.0') >= 0 ? { + true => "cd ${schema_path} && if [ -f server.sql.gz ]; then gunzip -f server.sql.gz ; fi && psql -h '${database_host}' -U '${database_user}' ${port}-d '${database_name}' -f server.sql && touch /etc/zabbix/.schema.done", + false => "cd ${schema_path} && if [ -f create.sql.gz ]; then gunzip -f create.sql.gz ; fi && psql -h '${database_host}' -U '${database_user}' ${port}-d '${database_name}' -f create.sql && touch /etc/zabbix/.schema.done" + } $zabbix_server_images_sql = 'touch /etc/zabbix/.images.done' $zabbix_server_data_sql = 'touch /etc/zabbix/.data.done' } diff --git a/manifests/proxy.pp b/manifests/proxy.pp index 6cf01abf7..9ac864c52 100644 --- a/manifests/proxy.pp +++ b/manifests/proxy.pp @@ -355,7 +355,7 @@ } if $manage_database { - if versioncmp($zabbix_version, '5.4') == 0 { + if versioncmp($zabbix_version, '5.4') >= 0 { package { 'zabbix-sql-scripts': ensure => present, require => Class['zabbix::repo'], @@ -364,7 +364,7 @@ } # Zabbix version 5.4 uses zabbix-sql-scripts for initializing the database. - if versioncmp($zabbix_version, '5.4') == 0 { + if versioncmp($zabbix_version, '5.4') >= 0 { $zabbix_database_require = [Package["zabbix-proxy-${db}"], Package['zabbix-sql-scripts']] } else { $zabbix_database_require = Package["zabbix-proxy-${db}"] diff --git a/manifests/server.pp b/manifests/server.pp index 804d14a98..41d8f73b0 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -273,7 +273,7 @@ Optional[Stdlib::Absolutepath] $socketdir = $zabbix::params::server_socketdir, Optional[Stdlib::HTTPUrl] $webserviceurl = undef, ) inherits zabbix::params { - # zabbix server 5.2 and 5.4 is not supported on RHEL 7. + # zabbix server 5.2, 5.4 and 6.0 is not supported on RHEL 7. # https://www.zabbix.com/documentation/current/manual/installation/install_from_packages/rhel_centos if $facts['os']['family'] == 'RedHat' and versioncmp($zabbix_version, '5.2') >= 0 { if versioncmp($facts['os']['release']['major'], '7') == 0 { @@ -295,7 +295,7 @@ } } - if versioncmp($zabbix_version, '5.4') == 0 { + if versioncmp($zabbix_version, '5.4') >= 0 { package { 'zabbix-sql-scripts': ensure => present, require => Class['zabbix::repo'], @@ -309,8 +309,8 @@ 'postgresql' : { $db = 'pgsql' - # Zabbix version 5.4 uses zabbix-sql-scripts for initializing the database. - if versioncmp($zabbix_version, '5.4') == 0 { + # Zabbix version >= 5.4 uses zabbix-sql-scripts for initializing the database. + if versioncmp($zabbix_version, '5.4') >= 0 { $zabbix_database_require = [Package["zabbix-server-${db}"], Package['zabbix-sql-scripts']] } else { $zabbix_database_require = Package["zabbix-server-${db}"] @@ -335,8 +335,8 @@ 'mysql' : { $db = 'mysql' - # Zabbix version 5.4 uses zabbix-sql-scripts for initializing the database. - if versioncmp($zabbix_version, '5.4') == 0 { + # Zabbix version >= 5.4 uses zabbix-sql-scripts for initializing the database. + if versioncmp($zabbix_version, '5.4') >= 0 { $zabbix_database_require = [Package["zabbix-server-${db}"], Package['zabbix-sql-scripts']] } else { $zabbix_database_require = Package["zabbix-server-${db}"] diff --git a/manifests/web.pp b/manifests/web.pp index 678f0d77f..0718f4c5a 100644 --- a/manifests/web.pp +++ b/manifests/web.pp @@ -195,7 +195,7 @@ '4.0': { $zabbixapi_version = '4.2.0' } - /^5\.[024]/: { + /^[56]\.[024]/: { $zabbixapi_version = '5.0.0-alpha1' } default: { diff --git a/spec/acceptance/zabbix_application_spec.rb b/spec/acceptance/zabbix_application_spec.rb index b516b4ab3..18aa8215e 100644 --- a/spec/acceptance/zabbix_application_spec.rb +++ b/spec/acceptance/zabbix_application_spec.rb @@ -8,7 +8,7 @@ # 5.2 and 5.4 server packages are not available for RHEL 7 next if zabbix_version == '5.2' && default[:platform] == 'el-7-x86_64' # Application API was removed in Zabbix 5.4 - next if zabbix_version == '5.4' + next if zabbix_version >= '5.4' # No Zabbix 5.2 packages on Debian 11 next if zabbix_version == '5.2' && default[:platform] == 'debian-11-amd64' diff --git a/spec/acceptance/zabbix_host_spec.rb b/spec/acceptance/zabbix_host_spec.rb index 304dc1e28..555bd4489 100644 --- a/spec/acceptance/zabbix_host_spec.rb +++ b/spec/acceptance/zabbix_host_spec.rb @@ -6,9 +6,8 @@ # rubocop:disable RSpec/LetBeforeExamples describe 'zabbix_host type', unless: default[:platform] =~ %r{(ubuntu-16.04|debian-9)-amd64} do supported_versions.each do |zabbix_version| - # 5.2 and 5.4 server packages are not available for RHEL 7 - next if zabbix_version == '5.2' && default[:platform] == 'el-7-x86_64' - next if zabbix_version == '5.4' && default[:platform] == 'el-7-x86_64' + # >= 5.2 server packages are not available for RHEL 7 + next if zabbix_version >= '5.2' && default[:platform] == 'el-7-x86_64' # No Zabbix 5.2 packages on Debian 11 next if zabbix_version == '5.2' && default[:platform] == 'debian-11-amd64' diff --git a/spec/acceptance/zabbix_hostgroup_spec.rb b/spec/acceptance/zabbix_hostgroup_spec.rb index ad7e872ce..c9eb67ee8 100644 --- a/spec/acceptance/zabbix_hostgroup_spec.rb +++ b/spec/acceptance/zabbix_hostgroup_spec.rb @@ -5,9 +5,8 @@ describe 'zabbix_hostgroup type', unless: default[:platform] =~ %r{(ubuntu-16.04|debian-9)-amd64} do supported_versions.each do |zabbix_version| - # 5.2 and 5.4 server packages are not available for RHEL 7 - next if zabbix_version == '5.2' && default[:platform] == 'el-7-x86_64' - next if zabbix_version == '5.4' && default[:platform] == 'el-7-x86_64' + # >= 5.2 server packages are not available for RHEL 7 + next if zabbix_version >= '5.2' && default[:platform] == 'el-7-x86_64' # No Zabbix 5.2 packages on Debian 11 next if zabbix_version == '5.2' && default[:platform] == 'debian-11-amd64' diff --git a/spec/acceptance/zabbix_proxy_spec.rb b/spec/acceptance/zabbix_proxy_spec.rb index 8859a101a..3f8a57046 100644 --- a/spec/acceptance/zabbix_proxy_spec.rb +++ b/spec/acceptance/zabbix_proxy_spec.rb @@ -6,9 +6,8 @@ # rubocop:disable RSpec/LetBeforeExamples describe 'zabbix_proxy type', unless: default[:platform] =~ %r{(ubuntu-16.04|debian-9)-amd64} do supported_versions.each do |zabbix_version| - # 5.2 and 5.4 server packages are not available for RHEL 7 - next if zabbix_version == '5.2' && default[:platform] == 'el-7-x86_64' - next if zabbix_version == '5.4' && default[:platform] == 'el-7-x86_64' + # >= 5.2 server packages are not available for RHEL 7 + next if zabbix_version >= '5.2' && default[:platform] == 'el-7-x86_64' # No Zabbix 5.2 packages on Debian 11 next if zabbix_version == '5.2' && default[:platform] == 'debian-11-amd64' diff --git a/spec/acceptance/zabbix_template_host_spec.rb b/spec/acceptance/zabbix_template_host_spec.rb index 1701240e9..76d9cfc09 100644 --- a/spec/acceptance/zabbix_template_host_spec.rb +++ b/spec/acceptance/zabbix_template_host_spec.rb @@ -5,9 +5,10 @@ describe 'zabbix_template_host type', unless: default[:platform] =~ %r{(ubuntu-16.04|debian-9)-amd64} do supported_versions.each do |zabbix_version| - # 5.2 and 5.4 server packages are not available for RHEL 7 - next if zabbix_version == '5.2' && default[:platform] == 'el-7-x86_64' - next if zabbix_version == '5.4' && default[:platform] == 'el-7-x86_64' + # Zabbix 6.0 removed the ability to attach templates directly to hosts. + next if zabbix_version == '6.0' + # >= 5.2 server packages are not available for RHEL 7 + next if zabbix_version >= '5.2' && default[:platform] == 'el-7-x86_64' # No Zabbix 5.2 packages on Debian 11 next if zabbix_version == '5.2' && default[:platform] == 'debian-11-amd64' diff --git a/spec/acceptance/zabbix_template_spec.rb b/spec/acceptance/zabbix_template_spec.rb index 76c22695f..40b442ef3 100644 --- a/spec/acceptance/zabbix_template_spec.rb +++ b/spec/acceptance/zabbix_template_spec.rb @@ -5,9 +5,8 @@ describe 'zabbix_template type', unless: default[:platform] =~ %r{(ubuntu-16.04|debian-9)-amd64} do supported_versions.each do |zabbix_version| - # 5.2 and 5.4 server packages are not available for RHEL 7 - next if zabbix_version == '5.2' && default[:platform] == 'el-7-x86_64' - next if zabbix_version == '5.4' && default[:platform] == 'el-7-x86_64' + # >= 5.2 server packages are not available for RHEL 7 + next if zabbix_version >= '5.2' && default[:platform] == 'el-7-x86_64' # No Zabbix 5.2 packages on Debian 11 next if zabbix_version == '5.2' && default[:platform] == 'debian-11-amd64' diff --git a/spec/classes/database_mysql_spec.rb b/spec/classes/database_mysql_spec.rb index 29c4c4b81..c817311cb 100644 --- a/spec/classes/database_mysql_spec.rb +++ b/spec/classes/database_mysql_spec.rb @@ -27,12 +27,19 @@ supported_versions.each do |zabbix_version| # path to sql files on Debian and RedHat - path = if zabbix_version == '5.4' + path = if Puppet::Util::Package.versioncmp(zabbix_version, '5.4') >= 0 '/usr/share/doc/zabbix-sql-scripts/mysql/' else '/usr/share/doc/zabbix-*-mysql*' end + sql_server = case zabbix_version + when '6.0' + 'server.sql' + else + 'create.sql' + end + context "when zabbix_type is server and zabbix version is #{zabbix_version}" do describe 'and database_port is defined' do let :params do @@ -49,7 +56,7 @@ it { is_expected.to contain_class('zabbix::database::mysql') } it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_exec('zabbix_server_create.sql').with_command("cd #{path} && if [ -f create.sql.gz ]; then gunzip -f create.sql.gz ; fi && mysql -h 'rspec.puppet.com' -u 'zabbix-server' -p'zabbix-server' -P 3306 -D 'zabbix-server' < create.sql && touch /etc/zabbix/.schema.done") } + it { is_expected.to contain_exec('zabbix_server_create.sql').with_command("cd #{path} && if [ -f #{sql_server}.gz ]; then gunzip -f #{sql_server}.gz ; fi && mysql -h 'rspec.puppet.com' -u 'zabbix-server' -p'zabbix-server' -P 3306 -D 'zabbix-server' < #{sql_server} && touch /etc/zabbix/.schema.done") } it { is_expected.to contain_exec('zabbix_server_images.sql').with_command('touch /etc/zabbix/.images.done') } it { is_expected.to contain_exec('zabbix_server_data.sql').with_command('touch /etc/zabbix/.data.done') } end @@ -68,13 +75,13 @@ it { is_expected.to contain_class('zabbix::database::mysql') } it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_exec('zabbix_server_create.sql').with_command("cd #{path} && if [ -f create.sql.gz ]; then gunzip -f create.sql.gz ; fi && mysql -h 'rspec.puppet.com' -u 'zabbix-server' -p'zabbix-server' -D 'zabbix-server' < create.sql && touch /etc/zabbix/.schema.done") } + it { is_expected.to contain_exec('zabbix_server_create.sql').with_command("cd #{path} && if [ -f #{sql_server}.gz ]; then gunzip -f #{sql_server}.gz ; fi && mysql -h 'rspec.puppet.com' -u 'zabbix-server' -p'zabbix-server' -D 'zabbix-server' < #{sql_server} && touch /etc/zabbix/.schema.done") } it { is_expected.to contain_exec('zabbix_server_images.sql').with_command('touch /etc/zabbix/.images.done') } it { is_expected.to contain_exec('zabbix_server_data.sql').with_command('touch /etc/zabbix/.data.done') } end end - context "when zabbix_type is server and zabbix version is #{zabbix_version}" do + context "when zabbix_type is proxy and zabbix version is #{zabbix_version}" do describe 'and database_port is defined' do let :params do { @@ -90,7 +97,12 @@ it { is_expected.to contain_class('zabbix::database::mysql') } it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_exec('zabbix_proxy_create.sql').with_command("cd #{path} && if [ -f schema.sql.gz ]; then gunzip -f schema.sql.gz ; fi && mysql -h 'rspec.puppet.com' -u 'zabbix-proxy' -p'zabbix-proxy' -P 3306 -D 'zabbix-proxy' < schema.sql && touch /etc/zabbix/.schema.done") } + + if Puppet::Util::Package.versioncmp(zabbix_version, '6.0') < 0 + it { is_expected.to contain_exec('zabbix_proxy_create.sql').with_command("cd #{path} && if [ -f schema.sql.gz ]; then gunzip -f schema.sql.gz ; fi && mysql -h 'rspec.puppet.com' -u 'zabbix-proxy' -p'zabbix-proxy' -P 3306 -D 'zabbix-proxy' < schema.sql && touch /etc/zabbix/.schema.done") } + else + it { is_expected.to contain_exec('zabbix_proxy_create.sql').with_command("cd #{path} && mysql -h 'rspec.puppet.com' -u 'zabbix-proxy' -p'zabbix-proxy' -P 3306 -D 'zabbix-proxy' < proxy.sql && touch /etc/zabbix/.schema.done") } + end end describe 'and no database_port is defined' do @@ -107,7 +119,12 @@ it { is_expected.to contain_class('zabbix::database::mysql') } it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_exec('zabbix_proxy_create.sql').with_command("cd #{path} && if [ -f schema.sql.gz ]; then gunzip -f schema.sql.gz ; fi && mysql -h 'rspec.puppet.com' -u 'zabbix-proxy' -p'zabbix-proxy' -D 'zabbix-proxy' < schema.sql && touch /etc/zabbix/.schema.done") } + + if Puppet::Util::Package.versioncmp(zabbix_version, '6.0') < 0 + it { is_expected.to contain_exec('zabbix_proxy_create.sql').with_command("cd #{path} && if [ -f schema.sql.gz ]; then gunzip -f schema.sql.gz ; fi && mysql -h 'rspec.puppet.com' -u 'zabbix-proxy' -p'zabbix-proxy' -D 'zabbix-proxy' < schema.sql && touch /etc/zabbix/.schema.done") } + else + it { is_expected.to contain_exec('zabbix_proxy_create.sql').with_command("cd #{path} && mysql -h 'rspec.puppet.com' -u 'zabbix-proxy' -p'zabbix-proxy' -D 'zabbix-proxy' < proxy.sql && touch /etc/zabbix/.schema.done") } + end end end end diff --git a/spec/classes/database_postgresql_spec.rb b/spec/classes/database_postgresql_spec.rb index 0eb26fe55..fa75da20b 100644 --- a/spec/classes/database_postgresql_spec.rb +++ b/spec/classes/database_postgresql_spec.rb @@ -23,20 +23,27 @@ path = case facts[:os]['name'] when 'CentOS', 'RedHat', 'OracleLinux', 'VirtuozzoLinux' # Path on RedHat - if zabbix_version == '5.4' + if Puppet::Util::Package.versioncmp(zabbix_version, '5.4') >= 0 '/usr/share/doc/zabbix-sql-scripts/postgresql/' else "/usr/share/doc/zabbix-*-pgsql-#{zabbix_version}*/" end else # Path on Debian - if zabbix_version == '5.4' + if Puppet::Util::Package.versioncmp(zabbix_version, '5.4') >= 0 '/usr/share/doc/zabbix-sql-scripts/postgresql/' else '/usr/share/doc/zabbix-*-pgsql' end end + sql_server = case zabbix_version + when '6.0' + 'server.sql' + else + 'create.sql' + end + describe "when zabbix_type is server and version is #{zabbix_version}" do let :params do { @@ -52,7 +59,7 @@ it { is_expected.to compile.with_all_deps } it { is_expected.to contain_exec('update_pgpass').with_command('echo node01.example.com:5432:zabbix-server:zabbix-server:zabbix-server >> /root/.pgpass') } - it { is_expected.to contain_exec('zabbix_server_create.sql').with_command("cd #{path} && if [ -f create.sql.gz ]; then gunzip -f create.sql.gz ; fi && psql -h 'node01.example.com' -U 'zabbix-server' -p 5432 -d 'zabbix-server' -f create.sql && touch /etc/zabbix/.schema.done") } + it { is_expected.to contain_exec('zabbix_server_create.sql').with_command("cd #{path} && if [ -f #{sql_server}.gz ]; then gunzip -f #{sql_server}.gz ; fi && psql -h 'node01.example.com' -U 'zabbix-server' -p 5432 -d 'zabbix-server' -f #{sql_server} && touch /etc/zabbix/.schema.done") } it { is_expected.to contain_exec('zabbix_server_images.sql').with_command('touch /etc/zabbix/.images.done') } it { is_expected.to contain_exec('zabbix_server_data.sql').with_command('touch /etc/zabbix/.data.done') } it { is_expected.to contain_file('/root/.pgpass') } @@ -73,7 +80,7 @@ it { is_expected.to compile.with_all_deps } it { is_expected.to contain_exec('update_pgpass').with_command('echo node01.example.com:5432:zabbix-server:zabbix-server:zabbix-server >> /root/.pgpass') } - it { is_expected.to contain_exec('zabbix_server_create.sql').with_command("cd #{path} && if [ -f create.sql.gz ]; then gunzip -f create.sql.gz ; fi && psql -h 'node01.example.com' -U 'zabbix-server' -d 'zabbix-server' -f create.sql && touch /etc/zabbix/.schema.done") } + it { is_expected.to contain_exec('zabbix_server_create.sql').with_command("cd #{path} && if [ -f #{sql_server}.gz ]; then gunzip -f #{sql_server}.gz ; fi && psql -h 'node01.example.com' -U 'zabbix-server' -d 'zabbix-server' -f #{sql_server} && touch /etc/zabbix/.schema.done") } it { is_expected.to contain_exec('zabbix_server_images.sql').with_command('touch /etc/zabbix/.images.done') } it { is_expected.to contain_exec('zabbix_server_data.sql').with_command('touch /etc/zabbix/.data.done') } it { is_expected.to contain_file('/root/.pgpass') } @@ -95,7 +102,12 @@ it { is_expected.to compile.with_all_deps } it { is_expected.to contain_exec('update_pgpass').with_command('echo node01.example.com:5432:zabbix-proxy:zabbix-proxy:zabbix-proxy >> /root/.pgpass') } - it { is_expected.to contain_exec('zabbix_proxy_create.sql').with_command("cd #{path} && if [ -f schema.sql.gz ]; then gunzip -f schema.sql.gz ; fi && psql -h 'node01.example.com' -U 'zabbix-proxy' -p 5432 -d 'zabbix-proxy' -f schema.sql && touch /etc/zabbix/.schema.done") } + + if Puppet::Util::Package.versioncmp(zabbix_version, '6.0') < 0 + it { is_expected.to contain_exec('zabbix_proxy_create.sql').with_command("cd #{path} && if [ -f schema.sql.gz ]; then gunzip -f schema.sql.gz ; fi && psql -h 'node01.example.com' -U 'zabbix-proxy' -p 5432 -d 'zabbix-proxy' -f schema.sql && touch /etc/zabbix/.schema.done") } + else + it { is_expected.to contain_exec('zabbix_proxy_create.sql').with_command("cd #{path} && psql -h 'node01.example.com' -U 'zabbix-proxy' -p 5432 -d 'zabbix-proxy' -f proxy.sql && touch /etc/zabbix/.schema.done") } + end it { is_expected.to contain_class('zabbix::params') } end @@ -113,7 +125,13 @@ it { is_expected.to compile.with_all_deps } it { is_expected.to contain_exec('update_pgpass').with_command('echo node01.example.com:5432:zabbix-proxy:zabbix-proxy:zabbix-proxy >> /root/.pgpass') } - it { is_expected.to contain_exec('zabbix_proxy_create.sql').with_command("cd #{path} && if [ -f schema.sql.gz ]; then gunzip -f schema.sql.gz ; fi && psql -h 'node01.example.com' -U 'zabbix-proxy' -d 'zabbix-proxy' -f schema.sql && touch /etc/zabbix/.schema.done") } + + if Puppet::Util::Package.versioncmp(zabbix_version, '6.0') < 0 + it { is_expected.to contain_exec('zabbix_proxy_create.sql').with_command("cd #{path} && if [ -f schema.sql.gz ]; then gunzip -f schema.sql.gz ; fi && psql -h 'node01.example.com' -U 'zabbix-proxy' -d 'zabbix-proxy' -f schema.sql && touch /etc/zabbix/.schema.done") } + else + it { is_expected.to contain_exec('zabbix_proxy_create.sql').with_command("cd #{path} && psql -h 'node01.example.com' -U 'zabbix-proxy' -d 'zabbix-proxy' -f proxy.sql && touch /etc/zabbix/.schema.done") } + end + it { is_expected.to contain_class('zabbix::params') } end end diff --git a/spec/classes/web_spec.rb b/spec/classes/web_spec.rb index d416ad6ed..a9d371aba 100644 --- a/spec/classes/web_spec.rb +++ b/spec/classes/web_spec.rb @@ -84,7 +84,7 @@ packages = if facts[:osfamily] == 'RedHat' if facts[:operatingsystemmajrelease].to_i == 7 && !%w[VirtuozzoLinux OracleLinux Scientific].include?(facts[:os]['name']) && - zabbix_version =~ %r{5\.[024]} + Puppet::Util::Package.versioncmp(zabbix_version, '5.0') >= 0 %w[zabbix-web-pgsql-scl zabbix-web] else %w[zabbix-web-pgsql zabbix-web] diff --git a/spec/support/acceptance/prepare_host.rb b/spec/support/acceptance/prepare_host.rb index 82590faed..70ac31738 100644 --- a/spec/support/acceptance/prepare_host.rb +++ b/spec/support/acceptance/prepare_host.rb @@ -22,6 +22,7 @@ def prepare_host /opt/puppetlabs/bin/puppet resource package zabbix-server-pgsql ensure=purged /opt/puppetlabs/bin/puppet resource package zabbix-web-pgsql ensure=purged /opt/puppetlabs/bin/puppet resource package zabbix-frontend-php ensure=purged + /opt/puppetlabs/bin/puppet resource package zabbix-sql-scripts ensure=purged /opt/puppetlabs/puppet/bin/gem uninstall zabbixapi -a rm -f /etc/zabbix/.*done if id postgres > /dev/null 2>&1; then @@ -38,6 +39,7 @@ def prepare_host /opt/puppetlabs/bin/puppet resource package zabbix-web-pgsql ensure=purged /opt/puppetlabs/bin/puppet resource package zabbix-web-pgsql-scl ensure=purged /opt/puppetlabs/bin/puppet resource package zabbix-frontend-php ensure=purged + /opt/puppetlabs/bin/puppet resource package zabbix-sql-scripts ensure=purged /opt/puppetlabs/puppet/bin/gem uninstall zabbixapi -a rm -f /etc/zabbix/.*done if id postgres > /dev/null 2>&1; then diff --git a/spec/support/acceptance/supported_versions.rb b/spec/support/acceptance/supported_versions.rb index 10980cd52..e92d38094 100644 --- a/spec/support/acceptance/supported_versions.rb +++ b/spec/support/acceptance/supported_versions.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true def supported_versions - %w[4.0 5.0 5.2 5.4] + %w[4.0 5.0 5.2 5.4 6.0] end