Debian Codegraph @

ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_maintenance/tasks/main.yml

raw
1 # New host create test from here
2 - name: "test - Create a new host"
3 community.zabbix.zabbix_host:
4 host_name: example
5 host_groups:
6 - Linux servers
7 interfaces:
8 - type: 1
9 main: 1
10 useip: 1
11 ip: 10.1.1.1
12 dns: ""
13 port: 10050
14 register: create_host_result
15
16 - name: "test - Create maintenance with a host_name param (minutes and time_groups not set)"
17 community.zabbix.zabbix_maintenance:
18 name: maintenance
19 host_name: example
20 state: present
21 register: create_maintenance_host_name_result
22
23 - ansible.builtin.assert:
24 that:
25 - create_maintenance_host_name_result.changed is sameas true
26
27 - name: "test - Create maintenance with a host_name param(again - expectations: false change will occur)"
28 community.zabbix.zabbix_maintenance:
29 name: maintenance
30 host_name: example
31 state: present
32 register: create_maintenance_host_name_again_result
33
34 - ansible.builtin.assert:
35 that:
36 - create_maintenance_host_name_again_result.changed is sameas false
37
38 - name: "test - Update maintenance with a desc param"
39 community.zabbix.zabbix_maintenance:
40 name: maintenance
41 host_name: example
42 desc: "test description"
43 state: present
44 register: update_maintenance_desc_result
45
46 - ansible.builtin.assert:
47 that:
48 - update_maintenance_desc_result.changed is sameas true
49
50 - name: "test - Update maintenance with a desc param(again - expectations: no change will occur)"
51 community.zabbix.zabbix_maintenance:
52 name: maintenance
53 host_name: example
54 desc: "test description"
55 state: present
56 register: update_maintenance_desc_again_result
57
58 - ansible.builtin.assert:
59 that:
60 - update_maintenance_desc_again_result.changed is sameas false
61
62 - name: "test - Update maintenance with a collect_data"
63 community.zabbix.zabbix_maintenance:
64 name: maintenance
65 host_name: example
66 desc: "test description"
67 collect_data: false
68 state: present
69 register: update_maintenance_collect_data_result
70
71 - ansible.builtin.assert:
72 that:
73 - update_maintenance_collect_data_result.changed is sameas true
74
75 - name: "test - Update maintenance with a collect_data(again - expectations: no change will occur)"
76 community.zabbix.zabbix_maintenance:
77 name: maintenance
78 host_name: example
79 desc: "test description"
80 collect_data: false
81 state: present
82 register: update_maintenance_collect_data_again_result
83
84 - ansible.builtin.assert:
85 that:
86 - update_maintenance_collect_data_again_result.changed is sameas false
87
88 - name: "test - Update maintenance with a minutes param"
89 community.zabbix.zabbix_maintenance:
90 name: maintenance
91 host_name: example
92 desc: "test description"
93 collect_data: false
94 minutes: 90
95 state: present
96 register: update_maintenance_minutes_result
97
98 - ansible.builtin.assert:
99 that:
100 - update_maintenance_minutes_result.changed is sameas true
101
102 - name: "test - Update maintenance with a minutes param(again - expectations: no change will occur)"
103 community.zabbix.zabbix_maintenance:
104 name: maintenance
105 host_name: example
106 desc: "test description"
107 collect_data: false
108 minutes: 90
109 state: present
110 register: update_maintenance_minutes_again_result
111
112 - ansible.builtin.assert:
113 that:
114 - update_maintenance_minutes_again_result.changed is sameas false
115
116 - name: "test - Update maintenance with a host_groups param"
117 community.zabbix.zabbix_maintenance:
118 name: maintenance
119 host_name: example
120 host_groups:
121 - Linux servers
122 - Hypervisors
123 desc: "test description"
124 collect_data: false
125 minutes: 90
126 state: present
127 register: update_maintenance_host_groups_result
128
129 - ansible.builtin.assert:
130 that:
131 - update_maintenance_host_groups_result.changed is sameas true
132
133 - name: "test - Update maintenance with a host_groups param(again - expectations: no change will occur)"
134 community.zabbix.zabbix_maintenance:
135 name: maintenance
136 host_name: example
137 host_groups:
138 - Linux servers
139 - Hypervisors
140 desc: "test description"
141 collect_data: false
142 minutes: 90
143 state: present
144 register: update_maintenance_host_groups_again_result
145
146 - ansible.builtin.assert:
147 that:
148 - update_maintenance_host_groups_again_result.changed is sameas false
149
150 - name: "test - Update maintenance with change host_name to host_names param"
151 community.zabbix.zabbix_maintenance:
152 name: maintenance
153 host_names:
154 - example
155 - Zabbix server
156 host_groups:
157 - Linux servers
158 - Hypervisors
159 desc: "test description"
160 collect_data: false
161 minutes: 90
162 state: present
163 register: update_maintenance_host_names_result
164
165 - ansible.builtin.assert:
166 that:
167 - update_maintenance_host_names_result.changed is sameas true
168
169 - name: "test - Update maintenance with change host_name to host_names param(again - expectations: no change will occur)"
170 community.zabbix.zabbix_maintenance:
171 name: maintenance
172 host_names:
173 - example
174 - Zabbix server
175 host_groups:
176 - Linux servers
177 - Hypervisors
178 desc: "test description"
179 collect_data: false
180 minutes: 90
181 state: present
182 register: update_maintenance_host_names_again_result
183
184 - ansible.builtin.assert:
185 that:
186 - update_maintenance_host_names_again_result.changed is sameas false
187
188 - name: "test - Update maintenance with tags"
189 community.zabbix.zabbix_maintenance:
190 name: maintenance
191 host_names:
192 - example
193 - Zabbix server
194 host_groups:
195 - Linux servers
196 - Hypervisors
197 desc: "test description"
198 collect_data: yes # required for tags
199 minutes: 90
200 state: present
201 tags:
202 - tag: ExampleHostsTag
203 - tag: ExampleHostsTag2
204 value: ExampleTagValue
205 - tag: ExampleHostsTag3
206 value: ExampleTagValue
207 operator: 0
208 register: update_maintenance_host_tags
209
210 - ansible.builtin.assert:
211 that:
212 - update_maintenance_host_tags.changed is sameas true
213
214 - name: "test - Update maintenance with tags (again)"
215 community.zabbix.zabbix_maintenance:
216 name: maintenance
217 host_names:
218 - example
219 - Zabbix server
220 host_groups:
221 - Linux servers
222 - Hypervisors
223 desc: "test description"
224 collect_data: yes
225 minutes: 90
226 state: present
227 tags:
228 - tag: ExampleHostsTag3
229 value: ExampleTagValue
230 operator: 0
231 - tag: ExampleHostsTag
232 - tag: ExampleHostsTag2
233 value: ExampleTagValue
234 register: update_maintenance_host_tags
235
236 - ansible.builtin.assert:
237 that:
238 - update_maintenance_host_tags.changed is sameas false
239
240 - name: "test - Create maintenance with an active_since param"
241 community.zabbix.zabbix_maintenance:
242 name: maintenance
243 host_name: example
244 active_since: "1979-09-19"
245 state: present
246 register: create_maintenance_active_since_result
247
248 - ansible.builtin.assert:
249 that:
250 - create_maintenance_active_since_result.changed is sameas true
251
252 - name: "test - Create maintenance with a active_since param(again - expectations: false change will occur)"
253 community.zabbix.zabbix_maintenance:
254 name: maintenance
255 host_name: example
256 active_since: "1979-09-19"
257 state: present
258 register: create_maintenance_active_since_again_result
259
260 - ansible.builtin.assert:
261 that:
262 - create_maintenance_active_since_again_result.changed is sameas false
263
264 - name: "test - Create maintenance with an active_till param"
265 community.zabbix.zabbix_maintenance:
266 name: maintenance
267 host_name: example
268 active_since: "1979-09-19 00:00"
269 active_till: "1979-09-19 23:59"
270 state: present
271 register: create_maintenance_active_till_result
272
273 - ansible.builtin.assert:
274 that:
275 - create_maintenance_active_till_result.changed is sameas true
276
277 - name: "test - Create maintenance with a active_till param(again - expectations: false change will occur)"
278 community.zabbix.zabbix_maintenance:
279 name: maintenance
280 host_name: example
281 active_since: "1979-09-19 00:00"
282 active_till: "1979-09-19 23:59"
283 state: present
284 register: create_maintenance_active_till_again_result
285
286 - ansible.builtin.assert:
287 that:
288 - create_maintenance_active_till_again_result.changed is sameas false
289
290 - name: "test - Create maintenance with an append param"
291 community.zabbix.zabbix_maintenance:
292 name: maintenance
293 host_names:
294 - Zabbix server
295 host_groups:
296 - Linux servers
297 append: true
298 active_since: "1979-09-19 00:00"
299 active_till: "1979-09-19 23:59"
300 state: present
301 register: create_maintenance_append_result
302
303 - ansible.builtin.assert:
304 that:
305 - create_maintenance_append_result.changed is sameas true
306
307 - name: "test - Create maintenance with an append param(again - expectations: no change will occur)"
308 community.zabbix.zabbix_maintenance:
309 name: maintenance
310 host_names:
311 - Zabbix server
312 host_groups:
313 - Linux servers
314 append: true
315 active_since: "1979-09-19 00:00"
316 active_till: "1979-09-19 23:59"
317 state: present
318 register: create_maintenance_append_again_result
319
320 - ansible.builtin.assert:
321 that:
322 - create_maintenance_append_again_result.changed is sameas false
323
324 - name: "test - Delete maintenance"
325 community.zabbix.zabbix_maintenance:
326 name: maintenance
327 host_name: example
328 state: absent
329 register: delete_maintenance_result
330 tags:
331 - cleanup
332
333 - ansible.builtin.assert:
334 that:
335 - delete_maintenance_result.changed is sameas true
336
337 - name: "test - Delete maintenance(again - expectations: no change will occur)"
338 community.zabbix.zabbix_maintenance:
339 name: maintenance
340 host_name: example
341 state: absent
342 register: delete_maintenance_again_result
343
344 - ansible.builtin.assert:
345 that:
346 - delete_maintenance_again_result.changed is sameas false
347
348 - name: "test - Create maintenance event using time_periods - once"
349 community.zabbix.zabbix_maintenance:
350 name: maintenance
351 host_name: example
352 desc: "test description"
353 state: present
354 time_periods:
355 - frequency: once
356 start_date: "2025-01-01"
357 start_time: "17:01"
358 register: create_maintenance_tp_once
359
360 - ansible.builtin.assert:
361 that:
362 - create_maintenance_tp_once.changed is sameas true
363
364 - name: "test - Create maintenance event using time_periods - once (no change)"
365 community.zabbix.zabbix_maintenance:
366 name: maintenance
367 host_name: example
368 desc: "test description"
369 state: present
370 time_periods:
371 - frequency: once
372 start_date: "2025-01-01"
373 start_time: "17:01"
374 register: create_maintenance_tp_once_again
375
376 - ansible.builtin.assert:
377 that:
378 - create_maintenance_tp_once_again.changed is sameas false
379
380 - name: "test - Create maintenance event using time_periods - once (update date)"
381 community.zabbix.zabbix_maintenance:
382 name: maintenance
383 host_name: example
384 desc: "test description"
385 state: present
386 time_periods:
387 - frequency: once
388 start_date: "2023-01-01"
389 start_time: "17:01"
390 register: create_maintenance_tp_once_update_date
391
392 - ansible.builtin.assert:
393 that:
394 - create_maintenance_tp_once_update_date.changed is sameas true
395
396
397 - name: "test - Create maintenance event using time_periods - daily"
398 community.zabbix.zabbix_maintenance:
399 name: maintenance
400 host_name: example
401 desc: "test description"
402 state: present
403 time_periods:
404 - frequency: daily
405 start_time: "18:01"
406 duration: 18
407 every: 1
408 register: create_maintenance_tp_daily
409
410 - ansible.builtin.assert:
411 that:
412 - create_maintenance_tp_daily.changed is sameas true
413
414 - name: "test - Create maintenance event using time_periods - once (no change)"
415 community.zabbix.zabbix_maintenance:
416 name: maintenance
417 host_name: example
418 desc: "test description"
419 state: present
420 time_periods:
421 - frequency: daily
422 start_time: "18:01"
423 duration: 18
424 every: 1
425 register: create_maintenance_tp_daily_again
426
427 - ansible.builtin.assert:
428 that:
429 - create_maintenance_tp_daily_again.changed is sameas false
430
431 - name: "test - Create maintenance event using time_periods - Update duration"
432 community.zabbix.zabbix_maintenance:
433 name: maintenance
434 host_name: example
435 desc: "test description"
436 state: present
437 time_periods:
438 - frequency: daily
439 start_time: "18:01"
440 duration: 19
441 every: 1
442 register: create_maintenance_tp_daily_update_duration
443
444 - ansible.builtin.assert:
445 that:
446 - create_maintenance_tp_daily_update_duration.changed is sameas true
447
448 - name: "test - Create maintenance event using time_periods - Update start_time"
449 community.zabbix.zabbix_maintenance:
450 name: maintenance
451 host_name: example
452 desc: "test description"
453 state: present
454 time_periods:
455 - frequency: daily
456 start_time: "19:01"
457 duration: 19
458 every: 1
459 register: create_maintenance_tp_daily_update_start_time
460
461 - ansible.builtin.assert:
462 that:
463 - create_maintenance_tp_daily_update_start_time.changed is sameas true
464
465 - name: "test - Create maintenance event using time_periods - Weekly"
466 community.zabbix.zabbix_maintenance:
467 name: maintenance
468 host_name: example
469 desc: "test description"
470 state: present
471 time_periods:
472 - frequency: weekly
473 start_time: "19:01"
474 duration: 19
475 every: 2
476 day_of_week: ["Monday"]
477 register: create_maintenance_tp_weekly
478
479 - ansible.builtin.assert:
480 that:
481 - create_maintenance_tp_weekly.changed is sameas true
482
483 - name: "test - Create maintenance event using time_periods - Weekly (No Change)"
484 community.zabbix.zabbix_maintenance:
485 name: maintenance
486 host_name: example
487 desc: "test description"
488 state: present
489 time_periods:
490 - frequency: weekly
491 start_time: "19:01"
492 duration: 19
493 every: 2
494 day_of_week: ["Monday"]
495 register: create_maintenance_tp_weekly_again
496
497 - ansible.builtin.assert:
498 that:
499 - create_maintenance_tp_weekly_again.changed is sameas false
500
501 - name: "test - Create maintenance event using time_periods - Weekly (Update Days)"
502 community.zabbix.zabbix_maintenance:
503 name: maintenance
504 host_name: example
505 desc: "test description"
506 state: present
507 time_periods:
508 - frequency: weekly
509 start_time: "19:01"
510 duration: 19
511 every: 2
512 day_of_week: ["Monday", "Friday"]
513 register: create_maintenance_tp_weekly_update_days
514
515 - ansible.builtin.assert:
516 that:
517 - create_maintenance_tp_weekly_update_days.changed is sameas true
518
519 - name: "test - Create maintenance event using time_periods - Monthly - Day of Month - No Month Listed"
520 community.zabbix.zabbix_maintenance:
521 name: maintenance
522 host_name: example
523 desc: "test description"
524 state: present
525 time_periods:
526 - frequency: monthly
527 start_time: "19:01"
528 duration: 19
529 every: 2
530 day_of_month: 5
531 register: create_maintenance_tp_monthly_day_of_month
532
533 - ansible.builtin.assert:
534 that:
535 - create_maintenance_tp_monthly_day_of_month.changed is sameas true
536
537 - name: "test - Create maintenance event using time_periods - Monthly - Day of Month - No Month Listed - Again (No Change)"
538 community.zabbix.zabbix_maintenance:
539 name: maintenance
540 host_name: example
541 desc: "test description"
542 state: present
543 time_periods:
544 - frequency: monthly
545 start_time: "19:01"
546 duration: 19
547 every: 2
548 day_of_month: 5
549 register: create_maintenance_tp_monthly_day_of_month_again
550
551 - ansible.builtin.assert:
552 that:
553 - create_maintenance_tp_monthly_day_of_month_again.changed is sameas false
554
555 - name: "test - Create maintenance event using time_periods - Monthly - Day of Month - Month Listed"
556 community.zabbix.zabbix_maintenance:
557 name: maintenance
558 host_name: example
559 desc: "test description"
560 state: present
561 time_periods:
562 - frequency: monthly
563 start_time: "19:01"
564 duration: 19
565 every: 2
566 day_of_month: 5
567 months: ["January", "December"]
568 register: create_maintenance_tp_monthly_day_of_month
569
570 - ansible.builtin.assert:
571 that:
572 - create_maintenance_tp_monthly_day_of_month.changed is sameas true
573
574 - name: "test - Create maintenance event using time_periods - Monthly - Day of Month - Month Listed - Again (No Change)"
575 community.zabbix.zabbix_maintenance:
576 name: maintenance
577 host_name: example
578 desc: "test description"
579 state: present
580 time_periods:
581 - frequency: monthly
582 start_time: "19:01"
583 duration: 19
584 every: 2
585 day_of_month: 5
586 months: ["January", "December"]
587 register: create_maintenance_tp_monthly_day_of_month_again
588
589 - ansible.builtin.assert:
590 that:
591 - create_maintenance_tp_monthly_day_of_month_again.changed is sameas false
592
593 - name: "test - Create maintenance event using time_periods - Monthly - Update Day of Month"
594 community.zabbix.zabbix_maintenance:
595 name: maintenance
596 host_name: example
597 desc: "test description"
598 state: present
599 time_periods:
600 - frequency: monthly
601 start_time: "19:01"
602 duration: 19
603 every: 2
604 day_of_month: 6
605 register: create_maintenance_tp_monthly_day_of_month_update
606
607 - ansible.builtin.assert:
608 that:
609 - create_maintenance_tp_monthly_day_of_month_update.changed is sameas true
610
611 - name: "test - Create maintenance event using time_periods - Monthly - Day of Week"
612 community.zabbix.zabbix_maintenance:
613 name: maintenance
614 host_name: example
615 desc: "test description"
616 state: present
617 time_periods:
618 - frequency: monthly
619 start_time: "19:01"
620 duration: 19
621 every: first
622 day_of_week: ["Monday"]
623 register: create_maintenance_tp_monthly_day_of_week
624
625 - ansible.builtin.assert:
626 that:
627 - create_maintenance_tp_monthly_day_of_week.changed is sameas true
628
629 - name: "test - Create maintenance event using time_periods - Monthly - Day of Week - Again (No Change)"
630 community.zabbix.zabbix_maintenance:
631 name: maintenance
632 host_name: example
633 desc: "test description"
634 state: present
635 time_periods:
636 - frequency: monthly
637 start_time: "19:01"
638 duration: 19
639 every: first
640 day_of_week: ["Monday"]
641 register: create_maintenance_tp_monthly_day_of_week_again
642
643 - ansible.builtin.assert:
644 that:
645 - create_maintenance_tp_monthly_day_of_week_again.changed is sameas false
646
647 - name: "test - Create maintenance event using time_periods - Monthly - Day of Week - Update"
648 community.zabbix.zabbix_maintenance:
649 name: maintenance
650 host_name: example
651 desc: "test description"
652 state: present
653 time_periods:
654 - frequency: monthly
655 start_time: "19:01"
656 duration: 19
657 every: first
658 day_of_week: ["Tuesday"]
659 register: create_maintenance_tp_monthly_day_of_week_update
660
661 - ansible.builtin.assert:
662 that:
663 - create_maintenance_tp_monthly_day_of_week_update.changed is sameas true
664
665 - name: "test - Create maintenance event using time_periods - Monthly - Day of Week - Update Every"
666 community.zabbix.zabbix_maintenance:
667 name: maintenance
668 host_name: example
669 desc: "test description"
670 state: present
671 time_periods:
672 - frequency: monthly
673 start_time: "19:01"
674 duration: 19
675 every: second
676 day_of_week: ["Tuesday"]
677 register: create_maintenance_tp_monthly_day_of_week_update_every
678
679 - ansible.builtin.assert:
680 that:
681 - create_maintenance_tp_monthly_day_of_week_update_every.changed is sameas true
682
683 - name: test - Define both minutes and host_groups (should fail)
684 community.zabbix.zabbix_maintenance:
685 name: maintenance
686 host_name: example
687 desc: "test description"
688 state: present
689 minutes: 11
690 time_periods:
691 - frequency: monthly
692 start_time: "19:01"
693 duration: 19
694 every: second
695 day_of_week: ["Tuesday"]
696 register: fail_min_and_timeperiods
697 ignore_errors: true
698
699 - ansible.builtin.assert:
700 that: fail_min_and_timeperiods.failed is sameas True
701
702 - name: "test - Delete maintenance"
703 community.zabbix.zabbix_maintenance:
704 name: maintenance
705 host_name: example
706 state: absent
707 register: delete_maintenance_result
708 tags:
709 - cleanup
710
711 - name: "test - Delete testing host"
712 community.zabbix.zabbix_host:
713 host_name: example
714 state: absent
715 tags:
716 - cleanup