-
Notifications
You must be signed in to change notification settings - Fork 284
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tag support for zabbix_host_events_info module (#1258)
- Loading branch information
Showing
7 changed files
with
203 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
minor_changes: | ||
- zabbix_host_events_info - add tag support |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
tests/integration/targets/test_zabbix_host_events_info/meta/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
dependencies: | ||
- setup_zabbix |
13 changes: 13 additions & 0 deletions
13
tests/integration/targets/test_zabbix_host_events_info/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
- name: test - do not run tests for Zabbix < 6.4 | ||
meta: end_play | ||
when: zabbix_version is version('6.4', '<') | ||
|
||
# setup stuff | ||
- include_tasks: zabbix_setup.yml | ||
|
||
# zabbix_item module tests | ||
- include_tasks: zabbix_tests.yml | ||
|
||
# tear down stuff set up earlier | ||
- include_tasks: zabbix_teardown.yml |
63 changes: 63 additions & 0 deletions
63
tests/integration/targets/test_zabbix_host_events_info/tasks/zabbix_setup.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
--- | ||
|
||
- name: Create example template | ||
community.zabbix.zabbix_template: | ||
template_name: ExampleTemplate | ||
template_groups: | ||
- Templates | ||
|
||
- name: Create example host | ||
community.zabbix.zabbix_host: | ||
host_name: ExampleHost | ||
host_groups: | ||
- Linux servers | ||
- Zabbix servers | ||
link_templates: | ||
- ExampleTemplate | ||
status: enabled | ||
state: present | ||
interfaces: | ||
- type: 1 | ||
main: 1 | ||
useip: 1 | ||
ip: 10.1.1.1 | ||
dns: "" | ||
port: "10050" | ||
|
||
- name: create ping item | ||
community.zabbix.zabbix_item: | ||
name: ping | ||
template_name: ExampleTemplate | ||
params: | ||
type: zabbix_agent_active | ||
key: agent.ping | ||
value_type: numeric_unsigned | ||
interval: 20s | ||
state: present | ||
|
||
- name: create ping warning trigger | ||
community.zabbix.zabbix_trigger: | ||
name: ping-warning | ||
template_name: ExampleTemplate | ||
params: | ||
severity: warning | ||
expression: 'nodata(/ExampleTemplate/agent.ping,1m)=1' | ||
manual_close: True | ||
state: present | ||
|
||
- name: create ping high trigger | ||
community.zabbix.zabbix_trigger: | ||
name: ping-high | ||
template_name: ExampleTemplate | ||
params: | ||
severity: high | ||
expression: 'nodata(/ExampleTemplate/agent.ping,2m)=1' | ||
manual_close: True | ||
tags: | ||
- tag: ExampleTag | ||
value: ExampleValue | ||
state: present | ||
|
||
- name: Wait to ensure triggers are firing | ||
ansible.builtin.wait_for: | ||
timeout: 180 |
9 changes: 9 additions & 0 deletions
9
tests/integration/targets/test_zabbix_host_events_info/tasks/zabbix_teardown.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
- name: remove example host | ||
community.zabbix.zabbix_host: | ||
host_name: ExampleHost | ||
state: absent | ||
|
||
- name: remove example template | ||
community.zabbix.zabbix_template: | ||
template_name: ExampleTemplate | ||
state: absent |
42 changes: 42 additions & 0 deletions
42
tests/integration/targets/test_zabbix_host_events_info/tasks/zabbix_tests.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
|
||
- name: test - get warning and higher events for host | ||
community.zabbix.zabbix_host_events_info: | ||
host_identifier: ExampleHost | ||
host_id_type: hostname | ||
trigger_severity: warning | ||
register: zabbix_host_events_warning | ||
|
||
- name: assert that both events are listed as problem | ||
ansible.builtin.assert: | ||
that: zabbix_host_events_warning.triggers_problem | length == 2 | ||
|
||
- name: test - get events high and higher for host | ||
community.zabbix.zabbix_host_events_info: | ||
host_identifier: ExampleHost | ||
host_id_type: hostname | ||
trigger_severity: high | ||
register: zabbix_host_events_high | ||
|
||
- name: assert that only high event is listed as problem | ||
ansible.builtin.assert: | ||
that: zabbix_host_events_high.triggers_problem | length == 1 | ||
|
||
- name: test - get events with tag for host | ||
community.zabbix.zabbix_host_events_info: | ||
host_identifier: ExampleHost | ||
host_id_type: hostname | ||
trigger_severity: warning | ||
tags: | ||
- tag: ExampleTag | ||
value: ExampleValue | ||
operator: equal | ||
register: zabbix_host_events_tags | ||
|
||
- name: assert that only matching tag is listed as problem | ||
ansible.builtin.assert: | ||
that: zabbix_host_events_tags.triggers_problem | length == 1 | ||
|
||
- name: assert tags are returned | ||
ansible.builtin.assert: | ||
that: zabbix_host_events_tags.triggers_problem[0].last_event.tags[0].tag == 'ExampleTag' |