From 39966c553691960568b1f7ec4ba4ae7724881904 Mon Sep 17 00:00:00 2001 From: Roberto Valentini Date: Fri, 28 Jun 2024 13:29:34 +0200 Subject: [PATCH] Remove baseline_os filter Fix spec for supported OS in metadata.json --- .sync.yml | 1 - spec/classes/agent_spec.rb | 37 +- spec/classes/database_mysql_spec.rb | 2 +- spec/classes/database_postgresql_spec.rb | 2 +- spec/classes/database_spec.rb | 2 +- spec/classes/javagateway_spec.rb | 4 +- spec/classes/proxy_spec.rb | 698 +++++++++++------------ spec/classes/repo_spec.rb | 8 +- spec/classes/sender_spec.rb | 6 +- spec/classes/server_spec.rb | 6 +- spec/classes/userparameter_spec.rb | 2 +- spec/classes/web_spec.rb | 10 +- spec/defines/userparameters_spec.rb | 2 +- spec/spec_helper.rb | 1 - spec/spec_helper_methods.rb | 31 - 15 files changed, 395 insertions(+), 417 deletions(-) delete mode 100644 spec/spec_helper_methods.rb diff --git a/.sync.yml b/.sync.yml index 0eecc424f..75052a749 100644 --- a/.sync.yml +++ b/.sync.yml @@ -8,7 +8,6 @@ spec/spec_helper.rb: mock_with: ':mocha' spec_overrides: - "require 'support/acceptance/supported_versions'" - - "require 'spec_helper_methods'" .puppet-lint.rc: enabled_lint_checks: - parameter_documentation diff --git a/spec/classes/agent_spec.rb b/spec/classes/agent_spec.rb index edae4c834..c52280fc0 100644 --- a/spec/classes/agent_spec.rb +++ b/spec/classes/agent_spec.rb @@ -14,11 +14,13 @@ } end - on_supported_os(baseline_os_hash).each do |os, facts| + on_supported_os.each do |os, facts| context "on #{os}" do config_path = case facts[:os]['name'] when 'windows' 'C:/ProgramData/zabbix/zabbix_agentd.conf' + when 'FreeBSD' + '/usr/local/etc/zabbix6/zabbix_agentd.conf' else '/etc/zabbix/zabbix_agentd.conf' end @@ -32,6 +34,8 @@ include_dir = case facts[:os]['name'] when 'windows' 'C:/ProgramData/zabbix/zabbix_agentd.d' + when 'FreeBSD' + '/usr/local/etc/zabbix6/zabbix_agentd.d' else '/etc/zabbix/zabbix_agentd.d' end @@ -50,6 +54,9 @@ when 'windows' package_name = 'zabbix-agent' service_name = 'Zabbix Agent' + when 'FreeBSD' + package_name = 'zabbix6-agent' + service_name = 'zabbix_agentd' else package_name = 'zabbix-agent' service_name = 'zabbix-agent' @@ -60,7 +67,7 @@ context 'with all defaults' do it { is_expected.to contain_selinux__module('zabbix-agent') } if facts[:os]['family'] == 'RedHat' it { is_expected.to contain_yumrepo('zabbix-frontend') } if facts[:os]['family'] == 'RedHat' && facts[:os]['release']['major'] == '7' - 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_package('zabbix-required-scl-repo') } if facts[:os]['family'] == 'RedHat' && facts[:os]['release']['major'] == '7' && %w[OracleLinux CentOS].include?(facts[:os]['name']) it { is_expected.to contain_apt__key('zabbix-A1848F5') } if facts[:os]['family'] == 'Debian' it { is_expected.to contain_apt__key('zabbix-FBABD5F') } if facts[:os]['family'] == 'Debian' it { is_expected.to contain_file(include_dir).with_ensure('directory') } @@ -75,11 +82,20 @@ ) end else - it do - is_expected.to contain_package(package_name). - with_ensure('present'). - with_tag('zabbix'). - that_requires('Class[zabbix::repo]') + + if facts[:os]['family'] == 'Gentoo' + it do + is_expected.to contain_package(package_name). + with_ensure('present'). + with_tag('zabbix') + end + else + it do + is_expected.to contain_package(package_name). + with_ensure('present'). + with_tag('zabbix'). + that_requires('Class[zabbix::repo]') + end end it do @@ -103,7 +119,7 @@ end case facts[:os]['family'] - when 'Archlinux' + when %w[Archlinux Gentoo FreeBSD].include?(facts[:os]['family']) it { is_expected.not_to compile.with_all_deps } when 'Debian' # rubocop:disable RSpec/RepeatedExample @@ -218,6 +234,9 @@ end context 'when declaring manage_startup_script is true' do + next if facts[:os]['family'] == 'FreeBSD' + next if facts[:os]['family'] == 'Gentoo' + let :params do { manage_startup_script: true @@ -478,6 +497,8 @@ end context 'when zabbix_package_agent is zabbix-agent2' do + next if facts[:os]['family'] == 'Gentoo' + let :params do { zabbix_package_agent: 'zabbix-agent2', startagents: 1, diff --git a/spec/classes/database_mysql_spec.rb b/spec/classes/database_mysql_spec.rb index 2e59d7590..064e65627 100644 --- a/spec/classes/database_mysql_spec.rb +++ b/spec/classes/database_mysql_spec.rb @@ -7,7 +7,7 @@ 'rspec.puppet.com' end - on_supported_os(baseline_os_hash).each do |os, facts| + on_supported_os.each do |os, facts| next if facts[:os]['name'] == 'windows' context "on #{os}" do diff --git a/spec/classes/database_postgresql_spec.rb b/spec/classes/database_postgresql_spec.rb index 802550213..65c30300c 100644 --- a/spec/classes/database_postgresql_spec.rb +++ b/spec/classes/database_postgresql_spec.rb @@ -7,7 +7,7 @@ 'rspec.puppet.com' end - on_supported_os(baseline_os_hash).each do |os, facts| + on_supported_os.each do |os, facts| next if facts[:os]['name'] == 'windows' context "on #{os}" do diff --git a/spec/classes/database_spec.rb b/spec/classes/database_spec.rb index 809e6d852..8c84ee2b8 100644 --- a/spec/classes/database_spec.rb +++ b/spec/classes/database_spec.rb @@ -7,7 +7,7 @@ 'rspec.puppet.com' end - on_supported_os(baseline_os_hash).each do |os, facts| + on_supported_os.each do |os, facts| next if facts[:os]['name'] == 'windows' context "on #{os}" do diff --git a/spec/classes/javagateway_spec.rb b/spec/classes/javagateway_spec.rb index 11ba5d894..5350a82ca 100644 --- a/spec/classes/javagateway_spec.rb +++ b/spec/classes/javagateway_spec.rb @@ -7,7 +7,7 @@ 'rspec.puppet.com' end - on_supported_os(baseline_os_hash).each do |os, facts| + on_supported_os.each do |os, facts| next if facts[:os]['name'] == 'windows' context "on #{os}" do @@ -28,7 +28,7 @@ it { is_expected.to contain_service('zabbix-java-gateway').with_require(['Package[zabbix-java-gateway]', 'File[/etc/zabbix/zabbix_java_gateway.conf]']) } it { is_expected.to contain_yumrepo('zabbix-frontend') } if facts[:os]['family'] == 'RedHat' && facts[:os]['release']['major'] == '7' - 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_package('zabbix-required-scl-repo') } if facts[:os]['family'] == 'RedHat' && facts[:os]['release']['major'] == '7' && %w[OracleLinux CentOS].include?(facts[:os]['name']) it { is_expected.to contain_apt__key('zabbix-A1848F5') } if facts[:os]['family'] == 'Debian' it { is_expected.to contain_apt__key('zabbix-FBABD5F') } if facts[:os]['family'] == 'Debian' end diff --git a/spec/classes/proxy_spec.rb b/spec/classes/proxy_spec.rb index 711d8e354..293baac09 100644 --- a/spec/classes/proxy_spec.rb +++ b/spec/classes/proxy_spec.rb @@ -7,13 +7,19 @@ 'rspec.puppet.com' end - on_supported_os(baseline_os_hash).each do |os, facts| + on_supported_os.each do |os, facts| + next if %w[Archlinux FreeBSD AIX Gentoo].include?(facts[:os]['family']) # zabbix proxy is currently not supported next if facts[:os]['name'] == 'windows' context "on #{os}" do let :facts do facts end + let :params do + { + zabbix_server_host: '192.168.1.1', + } + end zabbix_version = if facts[:os]['family'] == 'RedHat' && facts[:os]['release']['major'] == '7' '5.0' @@ -21,431 +27,417 @@ '6.0' end - case facts[:os]['family'] - when 'Archlinux' - context 'with all defaults' do - it { is_expected.not_to compile } - end - else + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf.d').with_ensure('directory') } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf.d').with_require('File[/etc/zabbix/zabbix_proxy.conf]') } + it { is_expected.to compile.with_all_deps } + it { is_expected.to contain_class('zabbix::params') } + it { is_expected.to contain_exec('zabbix_create.sql') } + it { is_expected.to contain_postgresql__server__pg_hba_rule('Allow zabbix-proxy to access database') } + + describe 'when manage_repo is true and zabbix version is unset' do let :params do { - zabbix_server_host: '192.168.1.1', + manage_repo: true } end - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf.d').with_ensure('directory') } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf.d').with_require('File[/etc/zabbix/zabbix_proxy.conf]') } - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_class('zabbix::params') } - it { is_expected.to contain_exec('zabbix_create.sql') } - it { is_expected.to contain_postgresql__server__pg_hba_rule('Allow zabbix-proxy to access database') } + it { is_expected.to contain_class('zabbix::repo').with_zabbix_version(zabbix_version) } + it { is_expected.to contain_package('zabbix-proxy-pgsql').with_require('Class[Zabbix::Repo]') } - describe 'when manage_repo is true and zabbix version is unset' do - let :params do - { - manage_repo: true - } - end + case facts[:os]['family'] + when 'RedHat' + it { is_expected.to contain_yumrepo('zabbix-nonsupported') } + it { is_expected.to contain_yumrepo('zabbix') } + when 'Debian' + it { is_expected.to contain_apt__source('zabbix') } + end + end - it { is_expected.to contain_class('zabbix::repo').with_zabbix_version(zabbix_version) } - it { is_expected.to contain_package('zabbix-proxy-pgsql').with_require('Class[Zabbix::Repo]') } + describe 'with enabled selinux', if: facts[:os]['family'] == 'RedHat' do + let :facts do + super().merge(selinux: true) + end - case facts[:os]['family'] - when 'RedHat' - it { is_expected.to contain_yumrepo('zabbix-nonsupported') } - it { is_expected.to contain_yumrepo('zabbix') } - when 'Debian' - it { is_expected.to contain_apt__source('zabbix') } - end + it { is_expected.to contain_selboolean('zabbix_can_network').with('value' => 'on', 'persistent' => true) } + end + + describe 'when database_type is postgresql' do + let :params do + { + database_type: 'postgresql' + } end - describe 'with enabled selinux', if: facts[:os]['family'] == 'RedHat' do - let :facts do - super().merge(selinux: true) - end + it { is_expected.to contain_package('zabbix-proxy-pgsql').with_ensure('present') } + it { is_expected.to contain_package('zabbix-proxy-pgsql').with_name('zabbix-proxy-pgsql') } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_require('Package[zabbix-proxy-pgsql]') } + end - it { is_expected.to contain_selboolean('zabbix_can_network').with('value' => 'on', 'persistent' => true) } + describe 'when database_type is mysql' do + let :params do + { + database_type: 'mysql' + } end - describe 'when database_type is postgresql' do - let :params do - { - database_type: 'postgresql' - } - end + it { is_expected.to contain_package('zabbix-proxy-mysql').with_ensure('present') } + it { is_expected.to contain_package('zabbix-proxy-mysql').with_name('zabbix-proxy-mysql') } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_require('Package[zabbix-proxy-mysql]') } + end - it { is_expected.to contain_package('zabbix-proxy-pgsql').with_ensure('present') } - it { is_expected.to contain_package('zabbix-proxy-pgsql').with_name('zabbix-proxy-pgsql') } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_require('Package[zabbix-proxy-pgsql]') } + describe 'when manage_resources is true' do + let :params do + { + manage_resources: true, + listenip: '192.168.1.1' + } end - describe 'when database_type is mysql' do - let :params do - { - database_type: 'mysql' - } - end + it { is_expected.to contain_class('zabbix::resources::proxy') } + it { is_expected.to contain_zabbix__userparameters('Zabbix_Proxy') } + end - it { is_expected.to contain_package('zabbix-proxy-mysql').with_ensure('present') } - it { is_expected.to contain_package('zabbix-proxy-mysql').with_name('zabbix-proxy-mysql') } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_require('Package[zabbix-proxy-mysql]') } + context 'with zabbix::database::postgresql class' do + let :params do + { + database_type: 'postgresql', + manage_database: true + } end - describe 'when manage_resources is true' do - let :params do - { - manage_resources: true, - listenip: '192.168.1.1' - } - 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(zabbix_version) } + 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') } + it { is_expected.to contain_class('zabbix::database::postgresql').with_database_host('localhost') } + end - it { is_expected.to contain_class('zabbix::resources::proxy') } - it { is_expected.to contain_zabbix__userparameters('Zabbix_Proxy') } + context 'with zabbix::database::mysql class' do + let(:params) do + { + database_type: 'mysql', + manage_database: true + } end - context 'with zabbix::database::postgresql class' do - let :params do - { - database_type: 'postgresql', - manage_database: true - } - 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(zabbix_version) } + 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') } + it { is_expected.to contain_class('zabbix::database::mysql').with_database_host('localhost') } + it { is_expected.to contain_mysql__db('zabbix_proxy') } + 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(zabbix_version) } - 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') } - it { is_expected.to contain_class('zabbix::database::postgresql').with_database_host('localhost') } + context 'when manage_database is true' do + let(:params) do + { + manage_database: true + } end - context 'with zabbix::database::mysql class' do - let(:params) do - { - database_type: 'mysql', - manage_database: true - } - end + it { is_expected.to contain_class('zabbix::database').with_zabbix_type('proxy') } + it { is_expected.to contain_class('zabbix::database').with_database_type('postgresql') } + it { is_expected.to contain_class('zabbix::database').with_database_name('zabbix_proxy') } + it { is_expected.to contain_class('zabbix::database').with_database_user('zabbix-proxy') } + it { is_expected.to contain_class('zabbix::database').with_database_password('zabbix-proxy') } + it { is_expected.to contain_class('zabbix::database').with_database_host('localhost') } + it { is_expected.to contain_class('zabbix::database').with_zabbix_proxy('localhost') } + it { is_expected.to contain_class('zabbix::database').with_zabbix_proxy_ip('127.0.0.1') } + 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(zabbix_version) } - 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') } - it { is_expected.to contain_class('zabbix::database::mysql').with_database_host('localhost') } - it { is_expected.to contain_mysql__db('zabbix_proxy') } + context 'when declaring manage_firewall is true' do + let(:params) do + { + manage_firewall: true + } end - context 'when manage_database is true' do - let(:params) do - { - manage_database: true - } - end + it { is_expected.to contain_firewall('151 zabbix-proxy') } + end - it { is_expected.to contain_class('zabbix::database').with_zabbix_type('proxy') } - it { is_expected.to contain_class('zabbix::database').with_database_type('postgresql') } - it { is_expected.to contain_class('zabbix::database').with_database_name('zabbix_proxy') } - it { is_expected.to contain_class('zabbix::database').with_database_user('zabbix-proxy') } - it { is_expected.to contain_class('zabbix::database').with_database_password('zabbix-proxy') } - it { is_expected.to contain_class('zabbix::database').with_database_host('localhost') } - it { is_expected.to contain_class('zabbix::database').with_zabbix_proxy('localhost') } - it { is_expected.to contain_class('zabbix::database').with_zabbix_proxy_ip('127.0.0.1') } + context 'when declaring manage_firewall is false' do + let(:params) do + { + manage_firewall: false + } end - context 'when declaring manage_firewall is true' do - let(:params) do - { - manage_firewall: true - } - end + it { is_expected.not_to contain_firewall('151 zabbix-proxy') } + end - it { is_expected.to contain_firewall('151 zabbix-proxy') } + # If manage_service is true (default), it should create a service + # and ensure that it is running. + context 'when declaring manage_service is true' do + let :params do + { + manage_service: true + } end - context 'when declaring manage_firewall is false' do - let(:params) do - { - manage_firewall: false - } - end + it { is_expected.to contain_service('zabbix-proxy').with_ensure('running') } + it { is_expected.to contain_service('zabbix-proxy').with_enable('true') } + it { is_expected.to contain_service('zabbix-proxy').with_require(['Package[zabbix-proxy-pgsql]', 'File[/etc/zabbix/zabbix_proxy.conf.d]', 'File[/etc/zabbix/zabbix_proxy.conf]', 'Class[Zabbix::Database]']) } + end - it { is_expected.not_to contain_firewall('151 zabbix-proxy') } + # When the manage_service is false, it may not make the service. + context 'when declaring manage_service is false' do + let :params do + { + manage_service: false + } end - # If manage_service is true (default), it should create a service - # and ensure that it is running. - context 'when declaring manage_service is true' do - let :params do - { - manage_service: true - } - end + it { is_expected.not_to contain_service('zabbix-proxy') } + end - it { is_expected.to contain_service('zabbix-proxy').with_ensure('running') } - it { is_expected.to contain_service('zabbix-proxy').with_enable('true') } - it { is_expected.to contain_service('zabbix-proxy').with_require(['Package[zabbix-proxy-pgsql]', 'File[/etc/zabbix/zabbix_proxy.conf.d]', 'File[/etc/zabbix/zabbix_proxy.conf]', 'Class[Zabbix::Database]']) } + # Make sure we have set some vars in zabbix_proxy.conf file. This is configuration file is the same on all + # operating systems. So we aren't testing this for all opeating systems, just this one. + context 'with zabbix_proxy.conf settings' do + let(:params) do + { + allowroot: '0', + cachesize: '32M', + configfrequency: '3600', + database_host: 'localhost', + database_name: 'zabbix-proxy', + database_password: 'zabbix-proxy', + database_schema: 'zabbix-proxy', + database_user: 'zabbix-proxy', + database_tlsconnect: 'verify_ca', + database_tlscafile: '/etc/zabbix/ssl/ca.cert', + database_tlscertfile: '/etc/zabbix/ssl/cert.cert', + database_tlskeyfile: '/etc/zabbix/ssl/key.key', + database_tlscipher: 'TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256', + database_tlscipher13: 'TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256', + datasenderfrequency: '1', + debuglevel: '4', + externalscripts: '/usr/lib/zabbix/externalscripts', + fping6location: '/usr/sbin/fping6', + fpinglocation: '60', + heartbeatfrequency: '60', + historycachesize: '16M', + historytextcachesize: '8M', + hostname: 'rspec.puppet.com', + housekeepingfrequency: '1', + include_dir: '/etc/zabbix/zabbix_proxy.conf.d', + javagateway: '192.168.1.2', + javagatewayport: '10051', + startjavapollers: '5', + listenip: '192.168.1.1', + listenport: '10051', + loadmodulepath: '${libdir}/modules', + loadmodule: 'pizza', + localbuffer: '0', + logfilesize: '15', + logfile: '/var/log/zabbix/proxy_server.log', + logtype: 'file', + logslowqueries: '0', + mode: '0', + offlinebuffer: '1', + pidfile: '/var/run/zabbix/proxy_server.pid', + snmptrapper: '0', + snmptrapperfile: '/tmp/zabbix_traps.tmp', + sshkeylocation: '/home/zabbix/.ssh/', + sslcertlocation_dir: '/usr/lib/zabbix/ssl/certs', + sslkeylocation_dir: '/usr/lib/zabbix/ssl/keys', + sslcalocation_dir: '/usr/lib/zabbix/ssl/certs', + startdbsyncers: '4', + startdiscoverers: '15', + starthttppollers: '15', + startipmipollers: '15', + startpingers: '15', + startpollers: '15', + startpollersunreachable: '15', + startpreprocessors: 10, + starttrappers: '15', + startvmwarecollectors: '0', + timeout: '20', + tmpdir: '/tmp', + trappertimeout: '16', + unavaliabledelay: '60', + unreachabedelay: '15', + unreachableperiod: '45', + vmwarecachesize: '8M', + vmwarefrequency: '60', + zabbix_server_host: '192.168.1.1', + zabbix_server_port: '10051', + zabbix_version: '5.0', + tlsciphercert: 'EECDH+aRSA+AES128:RSA+aRSA+AES128', + tlsciphercert13: 'EECDH+aRSA+AES128:RSA+aRSA+AES128', + tlscipherpsk: 'kECDHEPSK+AES128:kPSK+AES128', + tlscipherpsk13: 'TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256', + tlscipherall: 'TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256', + tlscipherall13: 'EECDH+aRSA+AES128:RSA+aRSA+AES128:kECDHEPSK+AES128:kPSK+AES128' + } end - # When the manage_service is false, it may not make the service. - context 'when declaring manage_service is false' do - let :params do - { - manage_service: false - } - end + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^ProxyMode=0$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^Server=192.168.1.1$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^ServerPort=10051$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^Hostname=rspec.puppet.com$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^ListenPort=10051$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^LogFile=/var/log/zabbix/proxy_server.log$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^LogFileSize=15$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^LogType=file$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^DebugLevel=4$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^PidFile=/var/run/zabbix/proxy_server.pid$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^DBHost=localhost$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^DBName=zabbix-proxy$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^DBSchema=zabbix-proxy$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^DBUser=zabbix-proxy$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^DBPassword=zabbix-proxy$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^DBTLSConnect=verify_ca} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^DBTLSCAFile=/etc/zabbix/ssl/ca.cert} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^DBTLSCertFile=/etc/zabbix/ssl/cert.cert} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^DBTLSKeyFile=/etc/zabbix/ssl/key.key} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^DBTLSCipher=TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^DBTLSCipher13=TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^ProxyLocalBuffer=0$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^ProxyOfflineBuffer=1$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^HeartbeatFrequency=60$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^ConfigFrequency=3600$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^DataSenderFrequency=1$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartPollers=15$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartIPMIPollers=15$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartPreprocessors=10$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartPollersUnreachable=15$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartTrappers=15$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartPingers=15$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartDiscoverers=15$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartHTTPPollers=15$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^JavaGateway=192.168.1.2$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^JavaGatewayPort=10051$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartJavaPollers=5$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartVMwareCollectors=0$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^VMwareFrequency=60$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^VMwareCacheSize=8M$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^SNMPTrapperFile=/tmp/zabbix_traps.tmp$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartSNMPTrapper=0$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^ListenIP=192.168.1.1$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^HousekeepingFrequency=1$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^CacheSize=32M$} } + 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{^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$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^UnavailableDelay=60$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^UnreachableDelay=15$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^ExternalScripts=/usr/lib/zabbix/externalscripts$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^FpingLocation=60$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^Fping6Location=/usr/sbin/fping6$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^SSHKeyLocation=/home/zabbix/.ssh/$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^LogSlowQueries=0$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TmpDir=/tmp$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^AllowRoot=0$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^Include=/etc/zabbix/zabbix_proxy.conf.d$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^SSLCertLocation=/usr/lib/zabbix/ssl/certs} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^SSLKeyLocation=/usr/lib/zabbix/ssl/keys} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^SSLCALocation=/usr/lib/zabbix/ssl/certs} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^LoadModulePath=\$\{libdir\}/modules$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^LoadModule=pizza$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSCipherCert=EECDH\+aRSA\+AES128:RSA\+aRSA\+AES128$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSCipherCert13=EECDH\+aRSA\+AES128:RSA\+aRSA\+AES128$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSCipherPSK=kECDHEPSK\+AES128:kPSK\+AES128$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSCipherPSK13=TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSCipherAll=TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSCipherAll13=EECDH\+aRSA\+AES128:RSA\+aRSA\+AES128:kECDHEPSK\+AES128:kPSK\+AES128$} } + end - it { is_expected.not_to contain_service('zabbix-proxy') } + context 'with zabbix_proxy.conf and version 5.0' do + let :params do + { + socketdir: '/var/run/zabbix', + startodbcpollers: 1, + zabbix_version: '5.0' + } end - # Make sure we have set some vars in zabbix_proxy.conf file. This is configuration file is the same on all - # operating systems. So we aren't testing this for all opeating systems, just this one. - context 'with zabbix_proxy.conf settings' do - let(:params) do - { - allowroot: '0', - cachesize: '32M', - configfrequency: '3600', - database_host: 'localhost', - database_name: 'zabbix-proxy', - database_password: 'zabbix-proxy', - database_schema: 'zabbix-proxy', - database_user: 'zabbix-proxy', - database_tlsconnect: 'verify_ca', - database_tlscafile: '/etc/zabbix/ssl/ca.cert', - database_tlscertfile: '/etc/zabbix/ssl/cert.cert', - database_tlskeyfile: '/etc/zabbix/ssl/key.key', - database_tlscipher: 'TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256', - database_tlscipher13: 'TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256', - datasenderfrequency: '1', - debuglevel: '4', - externalscripts: '/usr/lib/zabbix/externalscripts', - fping6location: '/usr/sbin/fping6', - fpinglocation: '60', - heartbeatfrequency: '60', - historycachesize: '16M', - historytextcachesize: '8M', - hostname: 'rspec.puppet.com', - housekeepingfrequency: '1', - include_dir: '/etc/zabbix/zabbix_proxy.conf.d', - javagateway: '192.168.1.2', - javagatewayport: '10051', - startjavapollers: '5', - listenip: '192.168.1.1', - listenport: '10051', - loadmodulepath: '${libdir}/modules', - loadmodule: 'pizza', - localbuffer: '0', - logfilesize: '15', - logfile: '/var/log/zabbix/proxy_server.log', - logtype: 'file', - logslowqueries: '0', - mode: '0', - offlinebuffer: '1', - pidfile: '/var/run/zabbix/proxy_server.pid', - snmptrapper: '0', - snmptrapperfile: '/tmp/zabbix_traps.tmp', - sshkeylocation: '/home/zabbix/.ssh/', - sslcertlocation_dir: '/usr/lib/zabbix/ssl/certs', - sslkeylocation_dir: '/usr/lib/zabbix/ssl/keys', - sslcalocation_dir: '/usr/lib/zabbix/ssl/certs', - startdbsyncers: '4', - startdiscoverers: '15', - starthttppollers: '15', - startipmipollers: '15', - startpingers: '15', - startpollers: '15', - startpollersunreachable: '15', - startpreprocessors: 10, - starttrappers: '15', - startvmwarecollectors: '0', - timeout: '20', - tmpdir: '/tmp', - trappertimeout: '16', - unavaliabledelay: '60', - unreachabedelay: '15', - unreachableperiod: '45', - vmwarecachesize: '8M', - vmwarefrequency: '60', - zabbix_server_host: '192.168.1.1', - zabbix_server_port: '10051', - zabbix_version: '5.0', - tlsciphercert: 'EECDH+aRSA+AES128:RSA+aRSA+AES128', - tlsciphercert13: 'EECDH+aRSA+AES128:RSA+aRSA+AES128', - tlscipherpsk: 'kECDHEPSK+AES128:kPSK+AES128', - tlscipherpsk13: 'TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256', - tlscipherall: 'TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256', - tlscipherall13: 'EECDH+aRSA+AES128:RSA+aRSA+AES128:kECDHEPSK+AES128:kPSK+AES128' - } - end + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^SocketDir=/var/run/zabbix} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').without_content %r{^StartODBCPollers=1$} } + end - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^ProxyMode=0$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^Server=192.168.1.1$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^ServerPort=10051$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^Hostname=rspec.puppet.com$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^ListenPort=10051$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^LogFile=/var/log/zabbix/proxy_server.log$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^LogFileSize=15$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^LogType=file$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^DebugLevel=4$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^PidFile=/var/run/zabbix/proxy_server.pid$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^DBHost=localhost$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^DBName=zabbix-proxy$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^DBSchema=zabbix-proxy$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^DBUser=zabbix-proxy$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^DBPassword=zabbix-proxy$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^DBTLSConnect=verify_ca} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^DBTLSCAFile=/etc/zabbix/ssl/ca.cert} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^DBTLSCertFile=/etc/zabbix/ssl/cert.cert} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^DBTLSKeyFile=/etc/zabbix/ssl/key.key} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^DBTLSCipher=TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^DBTLSCipher13=TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^ProxyLocalBuffer=0$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^ProxyOfflineBuffer=1$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^HeartbeatFrequency=60$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^ConfigFrequency=3600$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^DataSenderFrequency=1$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartPollers=15$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartIPMIPollers=15$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartPreprocessors=10$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartPollersUnreachable=15$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartTrappers=15$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartPingers=15$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartDiscoverers=15$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartHTTPPollers=15$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^JavaGateway=192.168.1.2$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^JavaGatewayPort=10051$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartJavaPollers=5$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartVMwareCollectors=0$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^VMwareFrequency=60$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^VMwareCacheSize=8M$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^SNMPTrapperFile=/tmp/zabbix_traps.tmp$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartSNMPTrapper=0$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^ListenIP=192.168.1.1$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^HousekeepingFrequency=1$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^CacheSize=32M$} } - 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{^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$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^UnavailableDelay=60$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^UnreachableDelay=15$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^ExternalScripts=/usr/lib/zabbix/externalscripts$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^FpingLocation=60$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^Fping6Location=/usr/sbin/fping6$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^SSHKeyLocation=/home/zabbix/.ssh/$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^LogSlowQueries=0$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TmpDir=/tmp$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^AllowRoot=0$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^Include=/etc/zabbix/zabbix_proxy.conf.d$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^SSLCertLocation=/usr/lib/zabbix/ssl/certs} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^SSLKeyLocation=/usr/lib/zabbix/ssl/keys} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^SSLCALocation=/usr/lib/zabbix/ssl/certs} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^LoadModulePath=\$\{libdir\}/modules$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^LoadModule=pizza$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSCipherCert=EECDH\+aRSA\+AES128:RSA\+aRSA\+AES128$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSCipherCert13=EECDH\+aRSA\+AES128:RSA\+aRSA\+AES128$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSCipherPSK=kECDHEPSK\+AES128:kPSK\+AES128$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSCipherPSK13=TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSCipherAll=TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSCipherAll13=EECDH\+aRSA\+AES128:RSA\+aRSA\+AES128:kECDHEPSK\+AES128:kPSK\+AES128$} } + context 'with zabbix_proxy.conf and version 6.0' do + let :params do + { + socketdir: '/var/run/zabbix', + startodbcpollers: 1, + zabbix_version: '6.0' + } end - context 'with zabbix_proxy.conf and version 5.0' do + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^SocketDir=/var/run/zabbix} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartODBCPollers=1$} } + end + + context 'with zabbix_proxy.conf and logtype declared' do + describe 'as system' do let :params do { - socketdir: '/var/run/zabbix', - startodbcpollers: 1, - zabbix_version: '5.0' + logtype: 'system' } end - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^SocketDir=/var/run/zabbix} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').without_content %r{^StartODBCPollers=1$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^LogType=system$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').without_content %r{^LogFile=} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').without_content %r{^LogFileSize=} } end - context 'with zabbix_proxy.conf and version 6.0' do + describe 'as console' do let :params do { - socketdir: '/var/run/zabbix', - startodbcpollers: 1, - zabbix_version: '6.0' + logtype: 'console' } end - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^SocketDir=/var/run/zabbix} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartODBCPollers=1$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^LogType=console$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').without_content %r{^LogFile=} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').without_content %r{^LogFileSize=} } end - context 'with zabbix_proxy.conf and logtype declared' do - describe 'as system' do - let :params do - { - logtype: 'system' - } - end - - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^LogType=system$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').without_content %r{^LogFile=} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').without_content %r{^LogFileSize=} } - end - - describe 'as console' do - let :params do - { - logtype: 'console' - } - end - - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^LogType=console$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').without_content %r{^LogFile=} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').without_content %r{^LogFileSize=} } - end - - describe 'as file' do - let :params do - { - logtype: 'file' - } - end - - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^LogType=file$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^LogFile=/var/log/zabbix/zabbix_proxy.log$} } - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^LogFileSize=10$} } - end - end - - context 'tlsaccept with one string value' do + describe 'as file' do let :params do { - tlsaccept: 'cert' + logtype: 'file' } end - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSAccept=cert$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^LogType=file$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^LogFile=/var/log/zabbix/zabbix_proxy.log$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^LogFileSize=10$} } end + end - context 'tlsaccept with one value array' do - let :params do - { - tlsaccept: %w[cert] - } - end + context 'tlsaccept with one string value' do + let :params do + { + tlsaccept: 'cert' + } + end - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSAccept=cert$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSAccept=cert$} } + end + + context 'tlsaccept with one value array' do + let :params do + { + tlsaccept: %w[cert] + } end - context 'tlsaccept with two value array' do - let :params do - { - tlsaccept: %w[unencrypted cert] - } - end + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSAccept=cert$} } + end - it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSAccept=unencrypted,cert$} } + context 'tlsaccept with two value array' do + let :params do + { + tlsaccept: %w[unencrypted cert] + } end + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSAccept=unencrypted,cert$} } end end end diff --git a/spec/classes/repo_spec.rb b/spec/classes/repo_spec.rb index 8bbd91694..1ff31bf89 100644 --- a/spec/classes/repo_spec.rb +++ b/spec/classes/repo_spec.rb @@ -4,18 +4,18 @@ require 'spec_helper' describe 'zabbix::repo' do - on_supported_os(baseline_os_hash).each do |os, facts| + on_supported_os.each do |os, facts| context "on #{os}" do let :facts do facts end case facts[:os]['family'] - when 'Archlinux' - next + when 'Archlinux', 'FreeBSD', 'Gentoo', 'AIX' + # rubocop:disable RSpec/RepeatedExample + it { is_expected.to compile.with_all_deps } when 'Debian' - # rubocop:disable RSpec/RepeatedExample it { is_expected.to compile.with_all_deps } it { is_expected.to contain_class('zabbix::params') } it { is_expected.to contain_class('zabbix::repo') } diff --git a/spec/classes/sender_spec.rb b/spec/classes/sender_spec.rb index b9917d98e..47f96393a 100644 --- a/spec/classes/sender_spec.rb +++ b/spec/classes/sender_spec.rb @@ -7,7 +7,7 @@ 'agent.example.com' end - on_supported_os(baseline_os_hash).each do |os, facts| + on_supported_os.each do |os, facts| next if facts[:os]['name'] == 'windows' context "on #{os}" do @@ -37,7 +37,7 @@ } end - if %w[Archlinux Gentoo].include?(facts[:os]['family']) + if %w[Archlinux Gentoo FreeBSD].include?(facts[:os]['family']) it { is_expected.not_to compile.with_all_deps } else it { is_expected.to contain_class('zabbix::repo').with_zabbix_version(zabbix_version) } @@ -50,7 +50,7 @@ it { is_expected.to contain_yumrepo('zabbix') } it { is_expected.to contain_yumrepo('zabbix-frontend') } if facts[:os]['release']['major'] == '7' - it { is_expected.to contain_package('zabbix-required-scl-repo') } if facts[:os]['release']['major'] == '7' + it { is_expected.to contain_package('zabbix-required-scl-repo') } if facts[:os]['release']['major'] == '7' && %w[OracleLinux CentOS].include?(facts[:os]['name']) when 'Debian' it { is_expected.to contain_apt__source('zabbix') } it { is_expected.to contain_apt__key('zabbix-A1848F5') } diff --git a/spec/classes/server_spec.rb b/spec/classes/server_spec.rb index 0d343037a..910819ef6 100644 --- a/spec/classes/server_spec.rb +++ b/spec/classes/server_spec.rb @@ -8,8 +8,8 @@ 'rspec.puppet.com' end - on_supported_os(baseline_os_hash).each do |os, facts| - next if facts[:os]['family'] == 'Archlinux' # zabbix server is currently not supported on archlinux + on_supported_os.each do |os, facts| + next if %w[Archlinux FreeBSD AIX Gentoo].include?(facts[:os]['family']) # zabbix server is currently not supported next if facts[:os]['name'] == 'windows' context "on #{os}" do @@ -54,7 +54,7 @@ it { is_expected.to contain_yumrepo('zabbix') } it { is_expected.to contain_yumrepo('zabbix-frontend') } if facts[:os]['release']['major'] == '7' - it { is_expected.to contain_package('zabbix-required-scl-repo') } if facts[:os]['release']['major'] == '7' + it { is_expected.to contain_package('zabbix-required-scl-repo') } if facts[:os]['release']['major'] == '7' && %w[OracleLinux CentOS].include?(facts[:os]['name']) end end diff --git a/spec/classes/userparameter_spec.rb b/spec/classes/userparameter_spec.rb index 5d2ddb78e..4de5e5ddb 100644 --- a/spec/classes/userparameter_spec.rb +++ b/spec/classes/userparameter_spec.rb @@ -7,7 +7,7 @@ 'agent.example.com' end - on_supported_os(baseline_os_hash).each do |os, facts| + on_supported_os.each do |os, facts| context "on #{os}" do let :facts do facts diff --git a/spec/classes/web_spec.rb b/spec/classes/web_spec.rb index 6fee84aff..5864765ef 100644 --- a/spec/classes/web_spec.rb +++ b/spec/classes/web_spec.rb @@ -24,11 +24,10 @@ class { 'apache': PUPPET end - on_supported_os(baseline_os_hash).each do |os, facts| + on_supported_os.each do |os, facts| supported_versions.each do |zabbix_version| next if facts[:os]['name'] == 'windows' - next if facts[:os]['name'] == 'Archlinux' - next if facts[:os]['name'] == 'Gentoo' + next if %w[Archlinux Gentoo FreeBSD].include?(facts[:os]['family']) context "on #{os}" do let :facts do @@ -47,7 +46,7 @@ class { 'apache': it { is_expected.to contain_yumrepo('zabbix') } if facts[:os]['family'] == 'RedHat' it { is_expected.to contain_yumrepo('zabbix-nonsupported') } if facts[:os]['family'] == 'RedHat' it { is_expected.to contain_yumrepo('zabbix-frontend') } if facts[:os]['family'] == 'RedHat' && facts[:os]['release']['major'] == '7' - 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_package('zabbix-required-scl-repo') } if facts[:os]['family'] == 'RedHat' && facts[:os]['release']['major'] == '7' && %w[OracleLinux CentOS].include?(facts[:os]['name']) 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' @@ -90,8 +89,7 @@ class { 'apache': pgsqlpackage = 'php-pgsql' packages = if facts[:os]['family'] == 'RedHat' - if facts[:os]['release']['major'].to_i == 7 && - !%w[OracleLinux].include?(facts[:os]['name']) + if facts[:os]['release']['major'].to_i == 7 %w[zabbix-web-pgsql-scl zabbix-web] else %w[zabbix-web-pgsql zabbix-web] diff --git a/spec/defines/userparameters_spec.rb b/spec/defines/userparameters_spec.rb index a49949a4e..3b62a1503 100644 --- a/spec/defines/userparameters_spec.rb +++ b/spec/defines/userparameters_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe 'zabbix::userparameters', type: :define do - on_supported_os(baseline_os_hash).each do |os, facts| + on_supported_os.each do |os, facts| next if facts[:os]['name'] == 'windows' context "on #{os}" do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 0aec83fe7..8361eb93b 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -24,5 +24,4 @@ require 'support/acceptance/supported_versions' -require 'spec_helper_methods' Dir['./spec/support/spec/**/*.rb'].sort.each { |f| require f } diff --git a/spec/spec_helper_methods.rb b/spec/spec_helper_methods.rb deleted file mode 100644 index 30ad7aaa8..000000000 --- a/spec/spec_helper_methods.rb +++ /dev/null @@ -1,31 +0,0 @@ -# frozen_string_literal: true - -def baseline_os_hash - { - supported_os: [ - { - 'operatingsystem' => 'CentOS', - 'operatingsystemrelease' => %w[7] - }, - { - 'operatingsystem' => 'Debian', - 'operatingsystemrelease' => %w[11 12] - }, - { - 'operatingsystem' => 'Ubuntu', - 'operatingsystemrelease' => %w[20.04 22.04] - }, - { - 'operatingsystem' => 'Archlinux', - }, - # TODO: Support and tests for Gentoo need to be fixed - # { - # 'operatingsystem' => 'Gentoo', - # }, - { - 'operatingsystem' => 'windows', - 'operatingsystemrelease' => %w[2016 2019] - }, - ] - } -end