|
14 | 14 | # use for custom type tests |
15 | 15 |
|
16 | 16 | template = case zabbix_version |
17 | | - when '4.0' |
18 | | - ['Template OS Linux', 'Template Module ICMP Ping'] |
19 | 17 | when '5.0' |
20 | 18 | ['Template OS Linux by Zabbix agent', 'Template Module ICMP Ping'] |
21 | 19 | else |
22 | 20 | ['Linux by Zabbix agent', 'ICMP Ping'] |
23 | 21 | end |
24 | 22 |
|
25 | 23 | template_snmp = case zabbix_version |
26 | | - when '4.0' |
27 | | - ['Template OS Linux SNMPv2'] |
28 | 24 | when '5.0' |
29 | 25 | ['Template OS Linux SNMP'] |
30 | 26 | else |
@@ -96,36 +92,33 @@ class { 'zabbix': |
96 | 92 | apply_manifest(pp2, catch_changes: true) |
97 | 93 | end |
98 | 94 |
|
99 | | - # Zabbix version 4.0 doesn't support interface details hash |
100 | | - if zabbix_version != '4.0' |
101 | | - pp3 = <<-EOS |
102 | | - zabbix_host { 'test3.example.com': |
103 | | - ipaddress => '127.0.0.3', |
104 | | - use_ip => false, |
105 | | - port => 161, |
106 | | - groups => ['Virtual machines'], |
107 | | - templates => #{template_snmp}, |
108 | | - macros => [], |
109 | | - interfacetype => 2, |
110 | | - interfacedetails => {"version" => "2", "bulk" => "0", "community" => "public"}, |
111 | | - } |
112 | | - zabbix_host { 'test4.example.com': |
113 | | - ipaddress => '127.0.0.4', |
114 | | - use_ip => false, |
115 | | - port => 161, |
116 | | - groups => ['Virtual machines'], |
117 | | - templates => #{template}, |
118 | | - macros => [], |
119 | | - } |
120 | | - EOS |
| 95 | + pp3 = <<-EOS |
| 96 | + zabbix_host { 'test3.example.com': |
| 97 | + ipaddress => '127.0.0.3', |
| 98 | + use_ip => false, |
| 99 | + port => 161, |
| 100 | + groups => ['Virtual machines'], |
| 101 | + templates => #{template_snmp}, |
| 102 | + macros => [], |
| 103 | + interfacetype => 2, |
| 104 | + interfacedetails => {"version" => "2", "bulk" => "0", "community" => "public"}, |
| 105 | + } |
| 106 | + zabbix_host { 'test4.example.com': |
| 107 | + ipaddress => '127.0.0.4', |
| 108 | + use_ip => false, |
| 109 | + port => 161, |
| 110 | + groups => ['Virtual machines'], |
| 111 | + templates => #{template}, |
| 112 | + macros => [], |
| 113 | + } |
| 114 | + EOS |
121 | 115 |
|
122 | | - it 'creates hosts with SNMP interface and details without errors' do |
123 | | - apply_manifest(pp3, catch_failures: true) |
124 | | - end |
| 116 | + it 'creates hosts with SNMP interface and details without errors' do |
| 117 | + apply_manifest(pp3, catch_failures: true) |
| 118 | + end |
125 | 119 |
|
126 | | - it 'creates hosts with SNMP interface and details without changes' do |
127 | | - apply_manifest(pp3, catch_changes: true) |
128 | | - end |
| 120 | + it 'creates hosts with SNMP interface and details without changes' do |
| 121 | + apply_manifest(pp3, catch_changes: true) |
129 | 122 | end |
130 | 123 |
|
131 | 124 | it_behaves_like 'an idempotent resource' do |
@@ -240,97 +233,92 @@ class { 'zabbix': |
240 | 233 | end |
241 | 234 | end |
242 | 235 |
|
243 | | - # Zabbix version 4.0 doesn't support interface details hash |
244 | | - if zabbix_version != '4.0' |
245 | | - |
246 | | - context 'test3.example.com' do |
247 | | - let(:test3) { result_hosts.select { |h| h['host'] == 'test3.example.com' }.first } |
| 236 | + context 'test3.example.com' do |
| 237 | + let(:test3) { result_hosts.select { |h| h['host'] == 'test3.example.com' }.first } |
248 | 238 |
|
249 | | - it 'is created' do |
250 | | - expect(test3['host']).to eq('test3.example.com') |
251 | | - end |
252 | | - |
253 | | - it 'is in group Virtual machines' do |
254 | | - expect(test3['groups'].map { |g| g['name'] }).to eq(['Virtual machines']) |
255 | | - end |
| 239 | + it 'is created' do |
| 240 | + expect(test3['host']).to eq('test3.example.com') |
| 241 | + end |
256 | 242 |
|
257 | | - it 'has a correct interface dns configured' do |
258 | | - expect(test3['interfaces'][0]['dns']).to eq('test3.example.com') |
259 | | - end |
| 243 | + it 'is in group Virtual machines' do |
| 244 | + expect(test3['groups'].map { |g| g['name'] }).to eq(['Virtual machines']) |
| 245 | + end |
260 | 246 |
|
261 | | - it 'has a correct interface ip configured' do |
262 | | - expect(test3['interfaces'][0]['ip']).to eq('127.0.0.3') |
263 | | - end |
| 247 | + it 'has a correct interface dns configured' do |
| 248 | + expect(test3['interfaces'][0]['dns']).to eq('test3.example.com') |
| 249 | + end |
264 | 250 |
|
265 | | - it 'has a correct interface main configured' do |
266 | | - expect(test3['interfaces'][0]['main']).to eq('1') |
267 | | - end |
| 251 | + it 'has a correct interface ip configured' do |
| 252 | + expect(test3['interfaces'][0]['ip']).to eq('127.0.0.3') |
| 253 | + end |
268 | 254 |
|
269 | | - it 'has a correct interface port configured' do |
270 | | - expect(test3['interfaces'][0]['port']).to eq('161') |
271 | | - end |
| 255 | + it 'has a correct interface main configured' do |
| 256 | + expect(test3['interfaces'][0]['main']).to eq('1') |
| 257 | + end |
272 | 258 |
|
273 | | - it 'has a correct interface type configured' do |
274 | | - expect(test3['interfaces'][0]['type']).to eq('2') |
275 | | - end |
| 259 | + it 'has a correct interface port configured' do |
| 260 | + expect(test3['interfaces'][0]['port']).to eq('161') |
| 261 | + end |
276 | 262 |
|
277 | | - it 'has a correct interface details configured' do |
278 | | - expect(test3['interfaces'][0]['details']).to eq('version' => '2', 'bulk' => '0', 'community' => 'public') |
279 | | - end |
| 263 | + it 'has a correct interface type configured' do |
| 264 | + expect(test3['interfaces'][0]['type']).to eq('2') |
| 265 | + end |
280 | 266 |
|
281 | | - it 'has a correct interface useip configured' do |
282 | | - expect(test3['interfaces'][0]['useip']).to eq('0') |
283 | | - end |
| 267 | + it 'has a correct interface details configured' do |
| 268 | + expect(test3['interfaces'][0]['details']).to eq('version' => '2', 'bulk' => '0', 'community' => 'public') |
| 269 | + end |
284 | 270 |
|
285 | | - it 'has templates attached' do |
286 | | - expect(test3['parentTemplates'].map { |t| t['host'] }.sort).to eq(template_snmp.sort) |
287 | | - end |
| 271 | + it 'has a correct interface useip configured' do |
| 272 | + expect(test3['interfaces'][0]['useip']).to eq('0') |
288 | 273 | end |
289 | 274 |
|
290 | | - context 'test4.example.com' do |
291 | | - let(:test4) { result_hosts.select { |h| h['host'] == 'test4.example.com' }.first } |
| 275 | + it 'has templates attached' do |
| 276 | + expect(test3['parentTemplates'].map { |t| t['host'] }.sort).to eq(template_snmp.sort) |
| 277 | + end |
| 278 | + end |
292 | 279 |
|
293 | | - it 'is created' do |
294 | | - expect(test4['host']).to eq('test4.example.com') |
295 | | - end |
| 280 | + context 'test4.example.com' do |
| 281 | + let(:test4) { result_hosts.select { |h| h['host'] == 'test4.example.com' }.first } |
296 | 282 |
|
297 | | - it 'is in group Virtual machines' do |
298 | | - expect(test4['groups'].map { |g| g['name'] }).to eq(['Virtual machines']) |
299 | | - end |
| 283 | + it 'is created' do |
| 284 | + expect(test4['host']).to eq('test4.example.com') |
| 285 | + end |
300 | 286 |
|
301 | | - it 'has a correct interface dns configured' do |
302 | | - expect(test4['interfaces'][0]['dns']).to eq('test4.example.com') |
303 | | - end |
| 287 | + it 'is in group Virtual machines' do |
| 288 | + expect(test4['groups'].map { |g| g['name'] }).to eq(['Virtual machines']) |
| 289 | + end |
304 | 290 |
|
305 | | - it 'has a correct interface ip configured' do |
306 | | - expect(test4['interfaces'][0]['ip']).to eq('127.0.0.4') |
307 | | - end |
| 291 | + it 'has a correct interface dns configured' do |
| 292 | + expect(test4['interfaces'][0]['dns']).to eq('test4.example.com') |
| 293 | + end |
308 | 294 |
|
309 | | - it 'has a correct interface main configured' do |
310 | | - expect(test4['interfaces'][0]['main']).to eq('1') |
311 | | - end |
| 295 | + it 'has a correct interface ip configured' do |
| 296 | + expect(test4['interfaces'][0]['ip']).to eq('127.0.0.4') |
| 297 | + end |
312 | 298 |
|
313 | | - it 'has a correct interface port configured' do |
314 | | - expect(test4['interfaces'][0]['port']).to eq('161') |
315 | | - end |
| 299 | + it 'has a correct interface main configured' do |
| 300 | + expect(test4['interfaces'][0]['main']).to eq('1') |
| 301 | + end |
316 | 302 |
|
317 | | - it 'has a correct interface type configured' do |
318 | | - expect(test4['interfaces'][0]['type']).to eq('1') |
319 | | - end |
| 303 | + it 'has a correct interface port configured' do |
| 304 | + expect(test4['interfaces'][0]['port']).to eq('161') |
| 305 | + end |
320 | 306 |
|
321 | | - it 'has a correct interface details configured' do |
322 | | - expect(test4['interfaces'][0]['details']).to eq([]) |
323 | | - end |
| 307 | + it 'has a correct interface type configured' do |
| 308 | + expect(test4['interfaces'][0]['type']).to eq('1') |
| 309 | + end |
324 | 310 |
|
325 | | - it 'has a correct interface useip configured' do |
326 | | - expect(test4['interfaces'][0]['useip']).to eq('0') |
327 | | - end |
| 311 | + it 'has a correct interface details configured' do |
| 312 | + expect(test4['interfaces'][0]['details']).to eq([]) |
| 313 | + end |
328 | 314 |
|
329 | | - it 'has templates attached' do |
330 | | - expect(test4['parentTemplates'].map { |t| t['host'] }.sort).to eq(template.sort) |
331 | | - end |
| 315 | + it 'has a correct interface useip configured' do |
| 316 | + expect(test4['interfaces'][0]['useip']).to eq('0') |
332 | 317 | end |
333 | 318 |
|
| 319 | + it 'has templates attached' do |
| 320 | + expect(test4['parentTemplates'].map { |t| t['host'] }.sort).to eq(template.sort) |
| 321 | + end |
334 | 322 | end |
335 | 323 |
|
336 | 324 | context 'test5.example.com' do |
|
0 commit comments