Debian Codegraph @

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

raw symbols SCIP
1 ---
2 - name: test - prepare example template for zabbix_action module
3 community.zabbix.zabbix_template:
4 template_name: ExampleTemplateForActionModule
5 template_groups:
6 - Templates
7 state: present
8 register: zbxaction_prep_template
9
10 - name: test - prepare example mediatype for zabbix_action module
11 community.zabbix.zabbix_mediatype:
12 name: ExampleMediaTypeForActionModule
13 smtp_email: [email protected]
14 type: email
15 state: present
16 register: zbxaction_prep_mediatype
17
18 - name: test - simple actions
19 module_defaults:
20 community.zabbix.zabbix_action:
21 state: present
22 status: enabled
23 name: ExampleTriggerAction
24 event_source: trigger
25 notify_if_canceled: true
26 esc_period: 60
27 conditions:
28 - type: trigger_severity
29 operator: ">="
30 value: Information
31 operations:
32 - type: send_message
33 subject: ExampleSubject
34 op_message: ExampleMessage
35 media_type: ExampleMediaTypeForActionModule
36 send_to_users:
37 - Admin
38
39 block:
40 - name: test - create new action
41 community.zabbix.zabbix_action:
42 register: zbxaction_new
43
44 - ansible.builtin.assert:
45 that: zbxaction_new.changed is sameas True
46
47 - name: test - create new action (again)
48 community.zabbix.zabbix_action:
49 register: zbxaction_new
50
51 - ansible.builtin.assert:
52 that: zbxaction_new.changed is sameas False
53
54 - name: test - update action with esc_period as string
55 community.zabbix.zabbix_action:
56 esc_period: 2m
57 register: zbxaction_escperiod_str
58
59 - ansible.builtin.assert:
60 that: zbxaction_escperiod_str.changed is sameas True
61
62 - name: test - update action with esc_period as string (again)
63 community.zabbix.zabbix_action:
64 esc_period: 2m
65 register: zbxaction_escperiod_str
66
67 - ansible.builtin.assert:
68 that: zbxaction_escperiod_str.changed is sameas False
69
70 - name: test - update action with esc_period as macro
71 community.zabbix.zabbix_action:
72 esc_period: "{$MYMACRO}"
73 register: zbxaction_escperiod_macro
74
75 - ansible.builtin.assert:
76 that: zbxaction_escperiod_macro.changed is sameas True
77
78 - name: test - update action with esc_period as macro (again)
79 community.zabbix.zabbix_action:
80 esc_period: "{$MYMACRO}"
81 register: zbxaction_escperiod_macro
82
83 - ansible.builtin.assert:
84 that: zbxaction_escperiod_macro.changed is sameas False
85
86 - name: test - update action with esc_period
87 community.zabbix.zabbix_action:
88 esc_period: 120
89 register: zbxaction_escperiod
90
91 - ansible.builtin.assert:
92 that: zbxaction_escperiod.changed is sameas True
93
94 - name: test - update action with esc_period (again)
95 community.zabbix.zabbix_action:
96 esc_period: 120
97 register: zbxaction_escperiod
98
99 - ansible.builtin.assert:
100 that: zbxaction_escperiod.changed is sameas False
101
102 - name: test - update action with pause_in_maintenance
103 community.zabbix.zabbix_action:
104 esc_period: 120
105 pause_in_maintenance: false
106 register: zbxaction_maintpause
107
108 - ansible.builtin.assert:
109 that: zbxaction_maintpause.changed is sameas True
110
111 - name: test - update action with pause_in_maintenance (again)
112 community.zabbix.zabbix_action:
113 esc_period: 120
114 pause_in_maintenance: false
115 register: zbxaction_maintpause
116
117 - ansible.builtin.assert:
118 that: zbxaction_maintpause.changed is sameas False
119
120 - name: test - reset action to default
121 community.zabbix.zabbix_action:
122 register: zbxaction_reset
123
124 - ansible.builtin.assert:
125 that: zbxaction_reset.changed is sameas True
126
127 - name: test - disable action
128 community.zabbix.zabbix_action:
129 status: disabled
130 register: zbxaction_disable
131
132 - ansible.builtin.assert:
133 that: zbxaction_disable.changed is sameas True
134
135 - name: test - disable action (again)
136 community.zabbix.zabbix_action:
137 status: disabled
138 register: zbxaction_disable
139
140 - ansible.builtin.assert:
141 that: zbxaction_disable.changed is sameas False
142
143 - name: test - delete action
144 community.zabbix.zabbix_action:
145 state: absent
146 register: zbxaction_delete
147
148 - ansible.builtin.assert:
149 that: zbxaction_delete.changed is sameas True
150
151 - name: test - delete action (again)
152 community.zabbix.zabbix_action:
153 state: absent
154 register: zbxaction_delete
155
156 - ansible.builtin.assert:
157 that: zbxaction_delete.changed is sameas False
158
159 - name: test - trigger actions with conditions
160 module_defaults:
161 community.zabbix.zabbix_action:
162 state: present
163 status: enabled
164 name: ExampleTriggerActionConditions
165 event_source: trigger
166 notify_if_canceled: true
167 esc_period: 60
168 operations:
169 - type: send_message
170 subject: ExampleSubject
171 op_message: ExampleMessage
172 media_type: ExampleMediaTypeForActionModule
173 send_to_users:
174 - Admin
175
176 block:
177 - name: test - create new action with multiple conditions
178 community.zabbix.zabbix_action:
179 conditions:
180 - type: host_group
181 operator: "="
182 value: Linux servers
183 - type: trigger_severity
184 operator: ">="
185 value: Average
186 - type: event_tag_value
187 value: MyTag
188 operator: "="
189 value2: MyTagValue
190 - type: time_period
191 operator: not in
192 value: 6-7,00:00-24:00
193 register: zbxaction_conditions
194
195 - ansible.builtin.assert:
196 that: zbxaction_conditions.changed is sameas True
197
198 - name: test - create new action with multiple conditions (again)
199 community.zabbix.zabbix_action:
200 conditions:
201 - type: host_group
202 operator: "="
203 value: Linux servers
204 - type: trigger_severity
205 operator: ">="
206 value: Average
207 - type: event_tag_value
208 value: MyTag
209 operator: "="
210 value2: MyTagValue
211 - type: time_period
212 operator: not in
213 value: 6-7,00:00-24:00
214 register: zbxaction_conditions
215
216 - ansible.builtin.assert:
217 that: zbxaction_conditions.changed is sameas False
218
219 - name: test - create new action with multiple conditions (reorder)
220 community.zabbix.zabbix_action:
221 conditions:
222 - type: host_group
223 operator: "="
224 value: Linux servers
225 - type: event_tag_value
226 value: MyTag
227 operator: "="
228 value2: MyTagValue
229 - type: trigger_severity
230 operator: ">="
231 value: Average
232 - type: time_period
233 operator: not in
234 value: 6-7,00:00-24:00
235 register: zbxaction_conditions_reorder
236
237 - ansible.builtin.assert:
238 that: zbxaction_conditions_reorder.changed is sameas False
239
240 - name: test - update action with multiple conditions by removing one condition
241 community.zabbix.zabbix_action:
242 conditions:
243 - type: host_group
244 operator: "="
245 value: Linux servers
246 - type: event_tag_value
247 value: MyTag
248 operator: "="
249 value2: MyTagValue
250 - type: trigger_severity
251 operator: ">="
252 value: Average
253 register: zbxaction_conditions_delone
254
255 - ansible.builtin.assert:
256 that: zbxaction_conditions_delone.changed is sameas True
257
258 - name: test - update action with multiple conditions by changing operators
259 community.zabbix.zabbix_action:
260 conditions:
261 - type: host_group
262 operator: "<>"
263 value: Linux servers
264 - type: event_tag_value
265 value: MyTag
266 operator: "<>"
267 value2: MyTagValue
268 - type: trigger_severity
269 operator: "<="
270 value: Average
271 register: zbxaction_conditions_operators
272
273 - ansible.builtin.assert:
274 that: zbxaction_conditions_operators.changed is sameas True
275
276 - name: test - update action with multiple conditions with operator aliases
277 community.zabbix.zabbix_action:
278 conditions:
279 - type: host_group
280 operator: does not equal
281 value: Linux servers
282 - type: event_tag_value
283 value: MyTag
284 operator: contains
285 value2: MyTagValue
286 - type: trigger_severity
287 operator: is less than or equals
288 value: Average
289 register: zbxaction_conditions_operator_aliases
290
291 - ansible.builtin.assert:
292 that: zbxaction_conditions_operator_aliases.changed is sameas True
293
294 - name: test - update action with multiple conditions and evaltype
295 community.zabbix.zabbix_action:
296 conditions:
297 - type: host_group
298 operator: "<>"
299 value: Linux servers
300 - type: event_tag_value
301 value: MyTag
302 operator: "<>"
303 value2: MyTagValue
304 - type: trigger_severity
305 operator: "<="
306 value: Average
307 eval_type: and
308 register: zbxaction_conditions_eval
309
310 - ansible.builtin.assert:
311 that: zbxaction_conditions_eval.changed is sameas True
312
313 - name: test - update action with multiple conditions and evaltype (again)
314 community.zabbix.zabbix_action:
315 conditions:
316 - type: host_group
317 operator: "<>"
318 value: Linux servers
319 - type: event_tag_value
320 value: MyTag
321 operator: "<>"
322 value2: MyTagValue
323 - type: trigger_severity
324 operator: "<="
325 value: Average
326 eval_type: and
327 register: zbxaction_conditions_eval
328
329 - ansible.builtin.assert:
330 that: zbxaction_conditions_eval.changed is sameas False
331
332 - name: test - update action with reduced conditions and formula
333 community.zabbix.zabbix_action:
334 conditions:
335 - type: host_group
336 operator: "="
337 value: Linux servers
338 formulaid: A
339 - type: trigger_severity
340 operator: ">="
341 value: Average
342 formulaid: B
343 - type: event_tag_value
344 value: MyTag
345 operator: "<>"
346 value2: MyTagValue
347 formulaid: C
348 formula: A and (B or C)
349 register: zbxaction_conditions_formula
350
351 - ansible.builtin.assert:
352 that: zbxaction_conditions_formula.changed is sameas True
353
354 - name: test - update formula used in action with reduced conditions
355 community.zabbix.zabbix_action:
356 conditions:
357 - type: host_group
358 operator: "="
359 value: Linux servers
360 formulaid: A
361 - type: trigger_severity
362 operator: ">="
363 value: Average
364 formulaid: B
365 - type: event_tag_value
366 value: MyTag
367 operator: "<>"
368 value2: MyTagValue
369 formulaid: C
370 formula: (A or B) or C
371 register: zbxaction_conditions_formula
372
373 - ansible.builtin.assert:
374 that: zbxaction_conditions_formula.changed is sameas True
375
376 - name: test - update formula used in action with reduced conditions (again)
377 community.zabbix.zabbix_action:
378 conditions:
379 - type: host_group
380 operator: "="
381 value: Linux servers
382 formulaid: A
383 - type: trigger_severity
384 operator: ">="
385 value: Average
386 formulaid: B
387 - type: event_tag_value
388 value: MyTag
389 operator: "<>"
390 value2: MyTagValue
391 formulaid: C
392 formula: (A or B) or C
393 register: zbxaction_conditions_formula
394
395 - ansible.builtin.assert:
396 that: zbxaction_conditions_formula.changed is sameas False
397
398 - name: test - delete action
399 community.zabbix.zabbix_action:
400 state: absent
401 register: zbxaction_delete
402
403 - ansible.builtin.assert:
404 that: zbxaction_delete.changed is sameas True
405
406 - name: test - trigger actions with message operations
407 module_defaults:
408 community.zabbix.zabbix_action:
409 state: present
410 status: enabled
411 name: ExampleTriggerActionOperations
412 event_source: trigger
413 notify_if_canceled: true
414 esc_period: 60
415 conditions:
416 - type: trigger_severity
417 operator: ">="
418 value: Average
419
420 block:
421 - name: test - create new action with send_message operations
422 community.zabbix.zabbix_action:
423 operations:
424 - type: send_message
425 send_to_users:
426 - Admin
427 subject: test_subject
428 op_message: test_message
429 media_type: ExampleMediaTypeForActionModule
430 operation_condition: not_acknowledged
431 esc_step_from: 1
432 esc_step_to: 2
433 - type: send_message
434 send_to_users:
435 - Admin
436 subject: test_subject
437 op_message: test_message
438 media_type: SMS
439 operation_condition: not_acknowledged
440 esc_step_from: 2
441 esc_step_to: 0
442 esc_period: 300
443 register: zbxaction_ops
444
445 - ansible.builtin.assert:
446 that: zbxaction_ops.changed is sameas True
447
448 - name: test - create new action with send_message operations (again)
449 community.zabbix.zabbix_action:
450 operations:
451 - type: send_message
452 send_to_users:
453 - Admin
454 subject: test_subject
455 op_message: test_message
456 media_type: ExampleMediaTypeForActionModule
457 operation_condition: not_acknowledged
458 esc_step_from: 1
459 esc_step_to: 2
460 - type: send_message
461 send_to_users:
462 - Admin
463 subject: test_subject
464 op_message: test_message
465 media_type: SMS
466 operation_condition: not_acknowledged
467 esc_step_from: 2
468 esc_step_to: 0
469 esc_period: 300
470 register: zbxaction_ops
471
472 - ansible.builtin.assert:
473 that: zbxaction_ops.changed is sameas False
474
475 - name: test - delete action
476 community.zabbix.zabbix_action:
477 state: absent
478 register: zbxaction_delete
479
480 - ansible.builtin.assert:
481 that: zbxaction_delete.changed is sameas True
482
483 - name: test - create new action with escalation steps 1-1
484 community.zabbix.zabbix_action:
485 operations:
486 - type: send_message
487 send_to_users:
488 - Admin
489 media_type: ExampleMediaTypeForActionModule
490 esc_step_from: 1
491 esc_step_to: 1
492 register: zbxaction_esc11
493
494 - ansible.builtin.assert:
495 that: zbxaction_esc11.changed is sameas True
496
497 - name: test - create new action with escalation steps 1-1 (again)
498 community.zabbix.zabbix_action:
499 operations:
500 - type: send_message
501 send_to_users:
502 - Admin
503 media_type: ExampleMediaTypeForActionModule
504 esc_step_from: 1
505 esc_step_to: 1
506 register: zbxaction_esc11_again
507
508 - ansible.builtin.assert:
509 that: zbxaction_esc11_again.changed is sameas False
510
511 - name: test - update action with escalation steps 2-2
512 community.zabbix.zabbix_action:
513 operations:
514 - type: send_message
515 send_to_users:
516 - Admin
517 media_type: ExampleMediaTypeForActionModule
518 esc_step_from: 2
519 esc_step_to: 2
520 register: zbxaction_esc22
521
522 - ansible.builtin.assert:
523 that: zbxaction_esc22.changed is sameas True
524
525 - name: test - create new action with escalation steps 2-2 (again)
526 community.zabbix.zabbix_action:
527 operations:
528 - type: send_message
529 send_to_users:
530 - Admin
531 media_type: ExampleMediaTypeForActionModule
532 esc_step_from: 2
533 esc_step_to: 2
534 register: zbxaction_esc22_again
535
536 - ansible.builtin.assert:
537 that: zbxaction_esc11_again.changed is sameas False
538
539 - name: test - delete action
540 community.zabbix.zabbix_action:
541 state: absent
542 register: zbxaction_delete
543
544 - ansible.builtin.assert:
545 that: zbxaction_delete.changed is sameas True
546
547 - name: test - discovery actions
548 module_defaults:
549 community.zabbix.zabbix_action:
550 state: present
551 status: enabled
552 name: ExampleDiscoveryActionOperations
553 event_source: discovery
554 esc_period: 60
555
556 block:
557 - name: test - create new discovery action
558 community.zabbix.zabbix_action:
559 conditions:
560 - type: host_IP
561 operator: "="
562 value: "192.168.0.1-127"
563 - type: discovery_object
564 operator: "="
565 value: host
566 - type: discovery_status
567 operator: "="
568 value: "discovered"
569 - type: uptime_or_downtime_duration
570 operator: ">="
571 value: 1800
572 operations:
573 - type: add_host
574 - type: add_to_host_group
575 host_groups:
576 - Linux servers
577 - type: link_to_template
578 templates:
579 - ExampleTemplateForActionModule
580 - type: enable_host
581 - type: set_host_inventory_mode
582 inventory: automatic
583 register: zbxaction_discovery
584
585 - ansible.builtin.assert:
586 that: zbxaction_discovery.changed is sameas True
587
588 - name: test - create new discovery action (again)
589 community.zabbix.zabbix_action:
590 conditions:
591 - type: host_IP
592 operator: "="
593 value: "192.168.0.1-127"
594 - type: discovery_object
595 operator: "="
596 value: host
597 - type: discovery_status
598 operator: "="
599 value: "discovered"
600 - type: uptime_or_downtime_duration
601 operator: ">="
602 value: 1800
603 operations:
604 - type: add_host
605 - type: add_to_host_group
606 host_groups:
607 - Linux servers
608 - type: link_to_template
609 templates:
610 - ExampleTemplateForActionModule
611 - type: enable_host
612 - type: set_host_inventory_mode
613 inventory: automatic
614 register: zbxaction_discovery
615
616 - ansible.builtin.assert:
617 that: zbxaction_discovery.changed is sameas False
618
619 - name: test - update discovery action conditions and operations
620 community.zabbix.zabbix_action:
621 conditions:
622 - type: host_IP
623 operator: "="
624 value: "192.168.1.1-127"
625 - type: discovery_object
626 operator: "="
627 value: host
628 - type: discovery_status
629 operator: "="
630 value: "discovered"
631 - type: uptime_or_downtime_duration
632 operator: ">="
633 value: 2200
634 operations:
635 - type: add_host
636 - type: add_to_host_group
637 host_groups:
638 - Linux servers
639 - Discovered hosts
640 - type: link_to_template
641 templates:
642 - ExampleTemplateForActionModule
643 - type: enable_host
644 - type: send_message
645 send_to_users:
646 - Admin
647 subject: test_subject
648 op_message: test_message
649 media_type: ExampleMediaTypeForActionModule
650 operation_condition: not_acknowledged
651 esc_step_from: 1
652 esc_step_to: 2
653 register: zbxaction_discovery_update
654
655 - ansible.builtin.assert:
656 that: zbxaction_discovery_update.changed is sameas True
657
658 - name: test - update discovery action conditions and operations (again)
659 community.zabbix.zabbix_action:
660 conditions:
661 - type: host_IP
662 operator: "="
663 value: "192.168.1.1-127"
664 - type: discovery_object
665 operator: "="
666 value: host
667 - type: discovery_status
668 operator: "="
669 value: "discovered"
670 - type: uptime_or_downtime_duration
671 operator: ">="
672 value: 2200
673 operations:
674 - type: add_host
675 - type: add_to_host_group
676 host_groups:
677 - Linux servers
678 - Discovered hosts
679 - type: link_to_template
680 templates:
681 - ExampleTemplateForActionModule
682 - type: enable_host
683 - type: send_message
684 send_to_users:
685 - Admin
686 subject: test_subject
687 op_message: test_message
688 media_type: ExampleMediaTypeForActionModule
689 operation_condition: not_acknowledged
690 esc_step_from: 1
691 esc_step_to: 2
692 register: zbxaction_discovery_update
693
694 - ansible.builtin.assert:
695 that: zbxaction_discovery_update.changed is sameas False
696
697 - name: test - delete action
698 community.zabbix.zabbix_action:
699 state: absent
700 register: zbxaction_delete
701
702 - ansible.builtin.assert:
703 that: zbxaction_delete.changed is sameas True
704
705 - name: test - create discovery rule
706 community.zabbix.zabbix_discovery_rule:
707 state: present
708 status: enabled
709 name: Test discovery rule
710 iprange: 127.0.0.1
711 dchecks:
712 - type: SNMPv2
713 ports: 161
714 key: '.1.3.6.1.2.1.1.1.0'
715 snmp_community: public
716 - type: HTTP
717 ports: "80"
718 - type: HTTP
719 ports: "81"
720 - type: Zabbix
721 key: "system.uname"
722 ports: "10050"
723 - type: Zabbix
724 key: "system.uname"
725 ports: "10051"
726 delay: 24h
727
728 - name: test - create discovery action with SNMP discovery check
729 community.zabbix.zabbix_action:
730 conditions:
731 - type: discovery_check
732 operator: '='
733 value: 'Test discovery rule: SNMPv2 agent ".1.3.6.1.2.1.1.1.0"'
734 operations:
735 - type: add_to_host_group
736 host_groups:
737 - Zabbix servers
738 register: zbxaction_discovery_create_snmp_condition
739
740 - ansible.builtin.assert:
741 that: zbxaction_discovery_create_snmp_condition.changed is sameas True
742
743 - name: test - update discovery action with wrong discovery check type
744 community.zabbix.zabbix_action:
745 conditions:
746 - type: discovery_check
747 operator: '='
748 value: 'Test discovery rule: fake check type'
749 operations:
750 - type: add_to_host_group
751 host_groups:
752 - Zabbix servers
753 register: zbxaction_discovery_update_wrong_dcheck_type
754 ignore_errors: true
755
756 - ansible.builtin.assert:
757 that: zbxaction_discovery_update_wrong_dcheck_type.failed is sameas True
758
759 - name: test - update discovery action with wrong discovery check
760 community.zabbix.zabbix_action:
761 conditions:
762 - type: discovery_check
763 operator: '='
764 value: 'Test discovery rule: SNMPv2 agent ".1"'
765 operations:
766 - type: add_to_host_group
767 host_groups:
768 - Zabbix servers
769 register: zbxaction_discovery_update_wrong_dcheck
770 ignore_errors: true
771
772 - ansible.builtin.assert:
773 that: zbxaction_discovery_update_wrong_dcheck.failed is sameas True
774
775 - name: test - update discovery action with wrong discovery rule
776 community.zabbix.zabbix_action:
777 conditions:
778 - type: discovery_check
779 operator: '='
780 value: 'Test discovery rule fake: SNMPv2 agent ".1.3.6.1.2.1.1.1.0"'
781 operations:
782 - type: add_to_host_group
783 host_groups:
784 - Zabbix servers
785 register: zbxaction_discovery_update_wrong_drule
786 ignore_errors: true
787
788 - ansible.builtin.assert:
789 that: zbxaction_discovery_update_wrong_drule.failed is sameas True
790
791 - name: test - create discovery action with some discovery checks
792 community.zabbix.zabbix_action:
793 conditions:
794 - type: "discovery_check"
795 operator: "equals"
796 value: 'Test discovery rule: HTTP'
797 - type: "discovery_check"
798 operator: "equals"
799 value: 'Test discovery rule: HTTP (81)'
800 - type: "discovery_check"
801 operator: "equals"
802 value: 'Test discovery rule: Zabbix agent "system.uname"'
803 - type: "discovery_check"
804 operator: "equals"
805 value: 'Test discovery rule: Zabbix agent (10051) "system.uname"'
806 operations:
807 - type: add_to_host_group
808 host_groups:
809 - Zabbix servers
810 register: zbxaction_create_valid_conditions
811 ignore_errors: true
812
813 - ansible.builtin.assert:
814 that: zbxaction_create_valid_conditions.changed is sameas True
815
816 - name: Test tag operations for Zabbix >= 7.0
817 block:
818 - name: test - add Add host tags operation to discovery action
819 community.zabbix.zabbix_action:
820 operations:
821 - type: add_to_host_group
822 host_groups:
823 - Zabbix servers
824 - type: add_host_tags
825 tags:
826 - tag: tag1
827 value: val1
828 register: zbxaction_discovery_update_add_tags
829
830 - ansible.builtin.assert:
831 that: zbxaction_discovery_update_add_tags.changed is sameas True
832
833 - name: test - add Add host tags operation to discovery action (again)
834 community.zabbix.zabbix_action:
835 operations:
836 - type: add_to_host_group
837 host_groups:
838 - Zabbix servers
839 - type: add_host_tags
840 tags:
841 - tag: tag1
842 value: val1
843 register: zbxaction_discovery_update_add_tags_again
844
845 - ansible.builtin.assert:
846 that: zbxaction_discovery_update_add_tags_again.changed is sameas False
847
848 - name: test - add Remove host tags operation to discovery action
849 community.zabbix.zabbix_action:
850 operations:
851 - type: add_to_host_group
852 host_groups:
853 - Zabbix servers
854 - type: remove_host_tags
855 tags:
856 - tag: tag2
857 value: val2
858 register: zbxaction_discovery_update_remote_tags
859
860 - name: test - add Remove host tags operation to discovery action (again)
861 community.zabbix.zabbix_action:
862 operations:
863 - type: add_to_host_group
864 host_groups:
865 - Zabbix servers
866 - type: remove_host_tags
867 tags:
868 - tag: tag2
869 value: val2
870 register: zbxaction_discovery_update_remote_tags_again
871
872 - ansible.builtin.assert:
873 that: zbxaction_discovery_update_remote_tags_again.changed is sameas False
874
875 when: zabbix_version is version('7.0', '>=')
876
877 - name: test - delete action
878 community.zabbix.zabbix_action:
879 state: absent
880
881 - name: test - delete rule
882 community.zabbix.zabbix_discovery_rule:
883 name: est discovery rule
884 state: absent
885
886 - name: test - auto registration actions
887 module_defaults:
888 community.zabbix.zabbix_action:
889 state: present
890 status: enabled
891 name: ExampleAutoRegActionOperations
892 event_source: auto_registration
893 esc_period: 60
894
895 block:
896 - name: test - create new auto registration action
897 community.zabbix.zabbix_action:
898 conditions:
899 - type: host_name
900 operator: like
901 value: zabbix
902 - type: host_metadata
903 operator: not like
904 value: somemetadata
905 operations:
906 - type: add_host
907 register: zbxaction_autoreg
908
909 - ansible.builtin.assert:
910 that: zbxaction_autoreg.changed is sameas True
911
912 - name: test - create new auto registration action (again)
913 community.zabbix.zabbix_action:
914 conditions:
915 - type: host_name
916 operator: like
917 value: zabbix
918 - type: host_metadata
919 operator: not like
920 value: somemetadata
921 operations:
922 - type: add_host
923 register: zbxaction_autoreg
924
925 - ansible.builtin.assert:
926 that: zbxaction_autoreg.changed is sameas False
927
928 - name: test - update auto registration action
929 community.zabbix.zabbix_action:
930 conditions:
931 - type: host_name
932 operator: like
933 value: zabbix
934 - type: host_metadata
935 operator: not like
936 value: somemetadata
937 - type: host_metadata
938 operator: like
939 value: somemetadata2
940 operations:
941 - type: add_host
942 register: zbxaction_autoreg_update
943
944 - ansible.builtin.assert:
945 that: zbxaction_autoreg_update.changed is sameas True
946
947 - name: test - update auto registration action (again)
948 community.zabbix.zabbix_action:
949 conditions:
950 - type: host_name
951 operator: like
952 value: zabbix
953 - type: host_metadata
954 operator: not like
955 value: somemetadata
956 - type: host_metadata
957 operator: like
958 value: somemetadata2
959 operations:
960 - type: add_host
961 register: zbxaction_autoreg_update
962
963 - ansible.builtin.assert:
964 that: zbxaction_autoreg_update.changed is sameas False
965
966 - name: test - delete action
967 community.zabbix.zabbix_action:
968 state: absent
969 register: zbxaction_delete
970
971 - ansible.builtin.assert:
972 that: zbxaction_delete.changed is sameas True
973
974 - name: test - internal actions
975 module_defaults:
976 community.zabbix.zabbix_action:
977 state: present
978 status: enabled
979 name: ExampleInternalActionOperations
980 event_source: internal
981 esc_period: 60
982 operations:
983 - type: send_message
984 send_to_users:
985 - Admin
986 subject: test_subject
987 op_message: test_message
988 media_type: ExampleMediaTypeForActionModule
989
990 block:
991 - name: test - create new internal action
992 community.zabbix.zabbix_action:
993 conditions:
994 - type: host_template
995 operator: "="
996 value: ExampleTemplateForActionModule
997 - type: event_type
998 operator: "="
999 value: item in not supported state
1000 register: zbxaction_internal
1001
1002 - ansible.builtin.assert:
1003 that: zbxaction_internal.changed is sameas True
1004
1005 - name: test - create new internal action (again)
1006 community.zabbix.zabbix_action:
1007 conditions:
1008 - type: host_template
1009 operator: "="
1010 value: ExampleTemplateForActionModule
1011 - type: event_type
1012 operator: "="
1013 value: item in not supported state
1014 register: zbxaction_internal
1015
1016 - ansible.builtin.assert:
1017 that: zbxaction_internal.changed is sameas False
1018
1019 - name: test - update internal action conditions
1020 community.zabbix.zabbix_action:
1021 conditions:
1022 - type: host_template
1023 operator: "="
1024 value: ExampleTemplateForActionModule
1025 - type: event_type
1026 operator: "="
1027 value: item in not supported state
1028 - type: event_type
1029 operator: "="
1030 value: trigger in unknown state
1031 register: zbxaction_internal_update
1032
1033 - ansible.builtin.assert:
1034 that: zbxaction_internal_update.changed is sameas True
1035
1036 - name: test - update internal action conditions (again)
1037 community.zabbix.zabbix_action:
1038 conditions:
1039 - type: host_template
1040 operator: "="
1041 value: ExampleTemplateForActionModule
1042 - type: event_type
1043 operator: "="
1044 value: item in not supported state
1045 - type: event_type
1046 operator: "="
1047 value: trigger in unknown state
1048 register: zbxaction_internal_update
1049
1050 - ansible.builtin.assert:
1051 that: zbxaction_internal_update.changed is sameas False
1052
1053 - name: test - delete action
1054 community.zabbix.zabbix_action:
1055 state: absent
1056 register: zbxaction_delete
1057
1058 - ansible.builtin.assert:
1059 that: zbxaction_delete.changed is sameas True
1060
1061 - module_defaults:
1062 community.zabbix.zabbix_action:
1063 state: present
1064 status: enabled
1065 name: ExampleTriggerActionRecAckOps
1066 event_source: trigger
1067 notify_if_canceled: true
1068 esc_period: 60
1069 conditions:
1070 - type: trigger_severity
1071 operator: ">="
1072 value: Information
1073 operations:
1074 - type: send_message
1075 subject: ExampleSubject
1076 op_message: ExampleMessage
1077 media_type: ExampleMediaTypeForActionModule
1078 send_to_users:
1079 - Admin
1080
1081 block:
1082 - name: test - create new action with recovery and acknowledge operations
1083 community.zabbix.zabbix_action:
1084 recovery_operations:
1085 - type: send_message
1086 subject: ExampleSubject
1087 op_message: ExampleMessage
1088 media_type: ExampleMediaTypeForActionModule
1089 send_to_users:
1090 - Admin
1091 - type: notify_all_involved
1092 subject: RecoverySubject
1093 op_message: RecoveryMessage
1094 acknowledge_operations:
1095 - type: send_message
1096 subject: ExampleSubject
1097 op_message: ExampleMessage
1098 media_type: ExampleMediaTypeForActionModule
1099 send_to_users:
1100 - Admin
1101 - type: notify_all_involved
1102 subject: RecoverySubject
1103 op_message: RecoveryMessage
1104 media_type: ExampleMediaTypeForActionModule
1105 register: zbxaction_recack_new
1106
1107 - ansible.builtin.assert:
1108 that: zbxaction_recack_new.changed is sameas True
1109
1110 - name: test - create new action with recovery and acknowledge operations (again)
1111 community.zabbix.zabbix_action:
1112 recovery_operations:
1113 - type: send_message
1114 subject: ExampleSubject
1115 op_message: ExampleMessage
1116 media_type: ExampleMediaTypeForActionModule
1117 send_to_users:
1118 - Admin
1119 - type: notify_all_involved
1120 subject: RecoverySubject
1121 op_message: RecoveryMessage
1122 acknowledge_operations:
1123 - type: send_message
1124 subject: ExampleSubject
1125 op_message: ExampleMessage
1126 media_type: ExampleMediaTypeForActionModule
1127 send_to_users:
1128 - Admin
1129 - type: notify_all_involved
1130 subject: RecoverySubject
1131 op_message: RecoveryMessage
1132 media_type: ExampleMediaTypeForActionModule
1133 register: zbxaction_recack_new
1134
1135 - ansible.builtin.assert:
1136 that: zbxaction_recack_new.changed is sameas False
1137
1138 - when: zabbix_version is version('7.0', '>=')
1139 block:
1140 - name: test - update action with pause_symptoms off
1141 community.zabbix.zabbix_action:
1142 recovery_operations:
1143 - type: send_message
1144 subject: ExampleSubject
1145 op_message: ExampleMessage
1146 media_type: ExampleMediaTypeForActionModule
1147 send_to_users:
1148 - Admin
1149 - type: notify_all_involved
1150 subject: RecoverySubject
1151 op_message: RecoveryMessage
1152 acknowledge_operations:
1153 - type: send_message
1154 subject: ExampleSubject
1155 op_message: ExampleMessage
1156 media_type: ExampleMediaTypeForActionModule
1157 send_to_users:
1158 - Admin
1159 - type: notify_all_involved
1160 subject: RecoverySubject
1161 op_message: RecoveryMessage
1162 media_type: ExampleMediaTypeForActionModule
1163 pause_symptoms: False
1164 register: zbxaction_pause_symptoms
1165
1166 - ansible.builtin.assert:
1167 that: zbxaction_pause_symptoms.changed is sameas True
1168
1169 - name: test - update action with pause_symptoms off (again)
1170 community.zabbix.zabbix_action:
1171 recovery_operations:
1172 - type: send_message
1173 subject: ExampleSubject
1174 op_message: ExampleMessage
1175 media_type: ExampleMediaTypeForActionModule
1176 send_to_users:
1177 - Admin
1178 - type: notify_all_involved
1179 subject: RecoverySubject
1180 op_message: RecoveryMessage
1181 acknowledge_operations:
1182 - type: send_message
1183 subject: ExampleSubject
1184 op_message: ExampleMessage
1185 media_type: ExampleMediaTypeForActionModule
1186 send_to_users:
1187 - Admin
1188 - type: notify_all_involved
1189 subject: RecoverySubject
1190 op_message: RecoveryMessage
1191 media_type: ExampleMediaTypeForActionModule
1192 pause_symptoms: False
1193 register: zbxaction_pause_symptoms
1194
1195 - ansible.builtin.assert:
1196 that: zbxaction_pause_symptoms.changed is sameas False
1197
1198 - name: test - delete action
1199 community.zabbix.zabbix_action:
1200 state: absent
1201 register: zbxaction_delete
1202
1203 - ansible.builtin.assert:
1204 that: zbxaction_delete.changed is sameas True
1205
1206 - name: delete ExampleApplicationAction action
1207 community.zabbix.zabbix_action:
1208 name: ExampleApplicationAction
1209 state: absent
1210
1211 - name: test - cleanup example template for zabbix_action module
1212 community.zabbix.zabbix_template:
1213 template_name: ExampleTemplateForActionModule
1214 state: absent
1215 register: zbxaction_prep_template
1216
1217 - name: test - cleanup example mediatype for zabbix_action module
1218 community.zabbix.zabbix_mediatype:
1219 name: ExampleMediaTypeForActionModule
1220 type: email
1221 state: absent
1222 register: zbxaction_prep_mediatype