From a8dac1a8b24bdfae7adf8b89066074d8d0da1320 Mon Sep 17 00:00:00 2001 From: Roberto Valentini Date: Thu, 27 Jun 2024 11:14:04 +0200 Subject: [PATCH] Add zabbix 7.0 support in CI skip zabbixapi resource check do to the gem was not compatible with zabbix 7.0 api --- .github/workflows/ci.yml | 2 +- manifests/repo.pp | 10 +++++++++- spec/acceptance/zabbix_host_spec.rb | 3 +++ spec/acceptance/zabbix_hostgroup_spec.rb | 3 +++ spec/acceptance/zabbix_proxy_spec.rb | 3 +++ spec/acceptance/zabbix_template_host_spec.rb | 2 +- spec/acceptance/zabbix_template_spec.rb | 3 +++ spec/classes/database_mysql_spec.rb | 3 +-- spec/classes/database_postgresql_spec.rb | 3 +-- spec/setup_acceptance_node.pp | 3 +++ spec/support/acceptance/supported_versions.rb | 5 +++-- 11 files changed, 31 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 22f1d2a6d..6b4d78725 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,4 +20,4 @@ jobs: name: Puppet uses: voxpupuli/gha-puppet/.github/workflows/beaker.yml@v2 with: - beaker_facter: 'zabbix_version:Zabbix:5.0,6.0' + beaker_facter: 'zabbix_version:Zabbix:5.0,6.0,7.0' diff --git a/manifests/repo.pp b/manifests/repo.pp index 58c09443d..4a7674566 100644 --- a/manifests/repo.pp +++ b/manifests/repo.pp @@ -31,7 +31,10 @@ } case $facts['os']['family'] { 'RedHat': { - if versioncmp(fact('os.release.major'), '9') >= 0 { + 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' + } elsif versioncmp(fact('os.release.major'), '9') >= 0 { $gpgkey_zabbix = 'https://repo.zabbix.com/RPM-GPG-KEY-ZABBIX-08EFA7DD' $gpgkey_nonsupported = 'https://repo.zabbix.com/RPM-GPG-KEY-ZABBIX-08EFA7DD' } else { @@ -139,6 +142,10 @@ id => 'A1848F5352D022B9471D83D0082AB56BA14FE591', source => 'https://repo.zabbix.com/zabbix-official-repo.key', } + apt::key { 'zabbix-4C3D6F2': + id => '4C3D6F2CC75F5146754FC374D913219AB5333005', + source => 'https://repo.zabbix.com/zabbix-official-repo.key', + } # Debian 11 provides Zabbix 5.0 by default. This can cause problems for 4.0 versions $pinpriority = $facts['os']['release']['major'] ? { @@ -153,6 +160,7 @@ require => [ Apt_key['zabbix-FBABD5F'], Apt_key['zabbix-A1848F5'], + Apt_key['zabbix-4C3D6F2'], ], } diff --git a/spec/acceptance/zabbix_host_spec.rb b/spec/acceptance/zabbix_host_spec.rb index 5c46de337..b81d32eab 100644 --- a/spec/acceptance/zabbix_host_spec.rb +++ b/spec/acceptance/zabbix_host_spec.rb @@ -6,6 +6,9 @@ # rubocop:disable RSpec/LetBeforeExamples describe 'zabbix_host type' do supported_server_versions(default[:platform]).each do |zabbix_version| + # Zabbix 7.0 removed the deprecated params 'user' in favor to 'username' + next if zabbix_version >= '7.0' + context "create zabbix_host resources with zabbix version #{zabbix_version}" do # This will deploy a running Zabbix setup (server, web, db) which we can # use for custom type tests diff --git a/spec/acceptance/zabbix_hostgroup_spec.rb b/spec/acceptance/zabbix_hostgroup_spec.rb index 260e4b1fd..ec9067415 100644 --- a/spec/acceptance/zabbix_hostgroup_spec.rb +++ b/spec/acceptance/zabbix_hostgroup_spec.rb @@ -5,6 +5,9 @@ describe 'zabbix_hostgroup type' do supported_server_versions(default[:platform]).each do |zabbix_version| + # Zabbix 7.0 removed the deprecated params 'user' in favor to 'username' + next if zabbix_version >= '7.0' + context "create zabbix_hostgroup resources with zabbix version #{zabbix_version}" do # This will deploy a running Zabbix setup (server, web, db) which we can # use for custom type tests diff --git a/spec/acceptance/zabbix_proxy_spec.rb b/spec/acceptance/zabbix_proxy_spec.rb index 94ab1b015..94a1a6395 100644 --- a/spec/acceptance/zabbix_proxy_spec.rb +++ b/spec/acceptance/zabbix_proxy_spec.rb @@ -6,6 +6,9 @@ # rubocop:disable RSpec/LetBeforeExamples describe 'zabbix_proxy type' do supported_server_versions(default[:platform]).each do |zabbix_version| + # Zabbix 7.0 removed the deprecated params 'user' in favor to 'username' + next if zabbix_version >= '7.0' + context "create zabbix_proxy resources with zabbix version #{zabbix_version}" do # This will deploy a running Zabbix setup (server, web, db) which we can # use for custom type tests diff --git a/spec/acceptance/zabbix_template_host_spec.rb b/spec/acceptance/zabbix_template_host_spec.rb index b455e3078..edca8331f 100644 --- a/spec/acceptance/zabbix_template_host_spec.rb +++ b/spec/acceptance/zabbix_template_host_spec.rb @@ -6,7 +6,7 @@ describe 'zabbix_template_host type' do supported_server_versions(default[:platform]).each do |zabbix_version| # Zabbix 6.0 removed the ability to attach templates directly to hosts. - next if zabbix_version == '6.0' + next if zabbix_version >= '6.0' context "create zabbix_template_host resources with zabbix version #{zabbix_version}" do template = case zabbix_version diff --git a/spec/acceptance/zabbix_template_spec.rb b/spec/acceptance/zabbix_template_spec.rb index ccbd66089..b7266810c 100644 --- a/spec/acceptance/zabbix_template_spec.rb +++ b/spec/acceptance/zabbix_template_spec.rb @@ -5,6 +5,9 @@ describe 'zabbix_template type' do supported_server_versions(default[:platform]).each do |zabbix_version| + # Zabbix 7.0 removed the deprecated params 'user' in favor to 'username' + next if zabbix_version >= '7.0' + context "create zabbix_template resources with zabbix version #{zabbix_version}" do # This will deploy a running Zabbix setup (server, web, db) which we can # use for custom type tests diff --git a/spec/classes/database_mysql_spec.rb b/spec/classes/database_mysql_spec.rb index 1861980df..2e59d7590 100644 --- a/spec/classes/database_mysql_spec.rb +++ b/spec/classes/database_mysql_spec.rb @@ -29,8 +29,7 @@ '/usr/share/doc/zabbix-*-mysql*' end - sql_server = case zabbix_version - when '6.0' + sql_server = if Puppet::Util::Package.versioncmp(zabbix_version, '6.0') >= 0 'server.sql' else 'create.sql' diff --git a/spec/classes/database_postgresql_spec.rb b/spec/classes/database_postgresql_spec.rb index eb1c5ed2e..802550213 100644 --- a/spec/classes/database_postgresql_spec.rb +++ b/spec/classes/database_postgresql_spec.rb @@ -42,8 +42,7 @@ '/usr/share/doc/zabbix-*-pgsql' end - sql_server = case zabbix_version - when '6.0' + sql_server = if Puppet::Util::Package.versioncmp(zabbix_version, '6.0') >= 0 'server.sql' else 'create.sql' diff --git a/spec/setup_acceptance_node.pp b/spec/setup_acceptance_node.pp index de1ecc6a6..58130b243 100644 --- a/spec/setup_acceptance_node.pp +++ b/spec/setup_acceptance_node.pp @@ -8,6 +8,9 @@ target => '/bin/mkdir', } } + package { 'gnupg': + ensure => present, + } } 'Ubuntu': { # The Ubuntu 18.04+ docker image has a dpkg config that won't install docs, to keep used space low diff --git a/spec/support/acceptance/supported_versions.rb b/spec/support/acceptance/supported_versions.rb index e38eed6b7..a8006c0cb 100644 --- a/spec/support/acceptance/supported_versions.rb +++ b/spec/support/acceptance/supported_versions.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true def supported_versions - supported_versions = %w[5.0 6.0] + supported_versions = %w[5.0 6.0 7.0] # this is a hack so that we don't have to rewrite the existing acceptance tests if (beaker_zabbix_version = ENV.fetch('BEAKER_FACTER_zabbix_version', nil)) supported_versions &= [beaker_zabbix_version] @@ -20,6 +20,7 @@ def supported_server_versions(platform) supported_versions.reject do |version| platform.start_with?('archlinux') || (version >= '5.2' && platform.start_with?('el-7')) || - (version < '6.0' && platform.start_with?('el-9', 'ubuntu-22', 'debian-12')) + (version < '6.0' && platform.start_with?('el-9', 'ubuntu-22', 'debian-12')) || + (version >= '7.0' && platform.start_with?('ubuntu-20', 'debian-11')) end end