|
7 | 7 | next if version < '6.0' && default[:platform] =~ %r{debian-12} |
8 | 8 |
|
9 | 9 | describe "zabbix::agent class with zabbix_version #{version}" do |
10 | | - it 'works idempotently with no errors' do |
11 | | - pp = <<-EOS |
12 | | - class { 'zabbix::agent': |
13 | | - server => '192.168.20.11', |
14 | | - zabbix_package_state => 'latest', |
15 | | - zabbix_version => '#{version}', |
16 | | - } |
17 | | - EOS |
| 10 | + context 'With minimal parameter' do |
| 11 | + it 'works idempotently with no errors' do |
| 12 | + pp = <<-EOS |
| 13 | + class { 'zabbix::agent': |
| 14 | + server => '192.168.20.11', |
| 15 | + zabbix_package_state => 'latest', |
| 16 | + zabbix_version => '#{version}', |
| 17 | + } |
| 18 | + EOS |
18 | 19 |
|
19 | | - prepare_host |
| 20 | + prepare_host |
20 | 21 |
|
21 | | - # Run it twice and test for idempotency |
22 | | - apply_manifest(pp, catch_failures: true) |
23 | | - apply_manifest(pp, catch_changes: true) |
24 | | - end |
| 22 | + # Run it twice and test for idempotency |
| 23 | + apply_manifest(pp, catch_failures: true) |
| 24 | + apply_manifest(pp, catch_changes: true) |
| 25 | + end |
25 | 26 |
|
26 | | - # do some basic checks |
27 | | - describe package('zabbix-agent') do |
28 | | - it { is_expected.to be_installed } |
29 | | - end |
| 27 | + # do some basic checks |
| 28 | + describe package('zabbix-agent') do |
| 29 | + it { is_expected.to be_installed } |
| 30 | + end |
30 | 31 |
|
31 | | - describe service('zabbix-agent') do |
32 | | - it { is_expected.to be_running } |
33 | | - it { is_expected.to be_enabled } |
34 | | - end |
| 32 | + describe service('zabbix-agent') do |
| 33 | + it { is_expected.to be_running } |
| 34 | + it { is_expected.to be_enabled } |
| 35 | + end |
35 | 36 |
|
36 | | - describe file('/etc/zabbix/zabbix_agentd.conf') do |
37 | | - its(:content) { is_expected.not_to match %r{ListenIP=} } |
| 37 | + describe file('/etc/zabbix/zabbix_agentd.conf') do |
| 38 | + its(:content) { is_expected.not_to match %r{ListenIP=} } |
| 39 | + end |
38 | 40 | end |
39 | 41 |
|
40 | 42 | context 'With ListenIP set to an IP-Address' do |
@@ -90,4 +92,97 @@ class { 'zabbix::agent': |
90 | 92 | end |
91 | 93 | end |
92 | 94 | end |
| 95 | + |
| 96 | + describe "zabbix::agent class with agent2 and zabbix_version #{version}" do |
| 97 | + # <6.0 agent2 packages are not available for ubuntu 22.04 |
| 98 | + next if version < '6.0' && default[:platform] =~ %r{ubuntu-22} |
| 99 | + |
| 100 | + before(:all) do |
| 101 | + prepare_host |
| 102 | + end |
| 103 | + |
| 104 | + context 'With minimal parameter' do |
| 105 | + it_behaves_like 'an idempotent resource' do |
| 106 | + let(:manifest) do |
| 107 | + <<-PUPPET |
| 108 | + class { 'zabbix::agent': |
| 109 | + agent_configfile_path => '/etc/zabbix/zabbix_agent2.conf', |
| 110 | + include_dir => '/etc/zabbix/zabbix_agent2.d', |
| 111 | + include_dir_purge => false, |
| 112 | + zabbix_package_agent => 'zabbix-agent2', |
| 113 | + servicename => 'zabbix-agent2', |
| 114 | + manage_startup_script => false, |
| 115 | + server => '192.168.20.11', |
| 116 | + zabbix_package_state => 'latest', |
| 117 | + zabbix_version => '#{version}', |
| 118 | + } |
| 119 | + PUPPET |
| 120 | + end |
| 121 | + end |
| 122 | + |
| 123 | + # do some basic checks |
| 124 | + describe package('zabbix-agent2') do |
| 125 | + it { is_expected.to be_installed } |
| 126 | + end |
| 127 | + |
| 128 | + describe service('zabbix-agent2') do |
| 129 | + it { is_expected.to be_running } |
| 130 | + it { is_expected.to be_enabled } |
| 131 | + end |
| 132 | + |
| 133 | + describe file('/etc/zabbix/zabbix_agentd2.conf') do |
| 134 | + its(:content) { is_expected.not_to match %r{ListenIP=} } |
| 135 | + end |
| 136 | + end |
| 137 | + |
| 138 | + context 'With ListenIP set to an IP-Address' do |
| 139 | + it_behaves_like 'an idempotent resource' do |
| 140 | + let(:manifest) do |
| 141 | + <<-PUPPET |
| 142 | + class { 'zabbix::agent': |
| 143 | + agent_configfile_path => '/etc/zabbix/zabbix_agent2.conf', |
| 144 | + include_dir => '/etc/zabbix/zabbix_agent2.d', |
| 145 | + include_dir_purge => false, |
| 146 | + zabbix_package_agent => 'zabbix-agent2', |
| 147 | + servicename => 'zabbix-agent2', |
| 148 | + manage_startup_script => false, |
| 149 | + server => '192.168.20.11', |
| 150 | + zabbix_package_state => 'latest', |
| 151 | + listenip => '127.0.0.1', |
| 152 | + zabbix_version => '#{version}', |
| 153 | + } |
| 154 | + PUPPET |
| 155 | + end |
| 156 | + end |
| 157 | + |
| 158 | + describe file('/etc/zabbix/zabbix_agent2.conf') do |
| 159 | + its(:content) { is_expected.to match %r{ListenIP=127.0.0.1} } |
| 160 | + end |
| 161 | + end |
| 162 | + |
| 163 | + context 'With ListenIP set to lo' do |
| 164 | + it_behaves_like 'an idempotent resource' do |
| 165 | + let(:manifest) do |
| 166 | + <<-PUPPET |
| 167 | + class { 'zabbix::agent': |
| 168 | + agent_configfile_path => '/etc/zabbix/zabbix_agent2.conf', |
| 169 | + include_dir => '/etc/zabbix/zabbix_agent2.d', |
| 170 | + include_dir_purge => false, |
| 171 | + zabbix_package_agent => 'zabbix-agent2', |
| 172 | + servicename => 'zabbix-agent2', |
| 173 | + manage_startup_script => false, |
| 174 | + server => '192.168.20.11', |
| 175 | + zabbix_package_state => 'latest', |
| 176 | + listenip => 'lo', |
| 177 | + zabbix_version => '#{version}', |
| 178 | + } |
| 179 | + PUPPET |
| 180 | + end |
| 181 | + |
| 182 | + describe file('/etc/zabbix/zabbix_agent2.conf') do |
| 183 | + its(:content) { is_expected.to match %r{ListenIP=127.0.0.1} } |
| 184 | + end |
| 185 | + end |
| 186 | + end |
| 187 | + end |
93 | 188 | end |
0 commit comments