From 89f0147c01e8705231e184072165657b54774b54 Mon Sep 17 00:00:00 2001 From: Dusan Matejka Date: Mon, 9 Aug 2021 08:23:55 +0200 Subject: [PATCH] fix CI tests for module_defaults and zabbix_poller services (#437) * fix CI tests for module_defaults and zabbix_poller services * fixed wrong flag - template_info plugins supports check mode * override zabbix poller trigger name only for 5.0 --- plugins/modules/zabbix_template_info.py | 2 +- .../targets/test_zabbix_action/tasks/main.yml | 14 +++++------ .../test_zabbix_discovery_rule/tasks/main.yml | 2 +- .../test_zabbix_host_info/tasks/main.yml | 2 +- .../test_zabbix_mediatype/tasks/main.yml | 12 +++++----- .../test_zabbix_service/defaults/main.yml | 2 ++ .../test_zabbix_service/tasks/main.yml | 23 +++++++++++-------- .../test_zabbix_usergroup/tasks/main.yml | 2 +- 8 files changed, 33 insertions(+), 26 deletions(-) create mode 100644 tests/integration/targets/test_zabbix_service/defaults/main.yml diff --git a/plugins/modules/zabbix_template_info.py b/plugins/modules/zabbix_template_info.py index 248d6a97b..4d8c28dcd 100644 --- a/plugins/modules/zabbix_template_info.py +++ b/plugins/modules/zabbix_template_info.py @@ -208,7 +208,7 @@ def main(): )) module = AnsibleModule( argument_spec=argument_spec, - supports_check_mode=False + supports_check_mode=True ) template_name = module.params['template_name'] diff --git a/tests/integration/targets/test_zabbix_action/tasks/main.yml b/tests/integration/targets/test_zabbix_action/tasks/main.yml index df91f3217..3f33dd374 100644 --- a/tests/integration/targets/test_zabbix_action/tasks/main.yml +++ b/tests/integration/targets/test_zabbix_action/tasks/main.yml @@ -27,7 +27,7 @@ - name: test - simple actions module_defaults: - zabbix_action: + community.zabbix.zabbix_action: server_url: "{{ zabbix_server_url }}" login_user: "{{ zabbix_login_user }}" login_password: "{{ zabbix_login_password }}" @@ -255,7 +255,7 @@ - name: test - trigger actions with conditions module_defaults: - zabbix_action: + community.zabbix.zabbix_action: server_url: "{{ zabbix_server_url }}" login_user: "{{ zabbix_login_user }}" login_password: "{{ zabbix_login_password }}" @@ -507,7 +507,7 @@ - name: test - trigger actions with operations module_defaults: - zabbix_action: + community.zabbix.zabbix_action: server_url: "{{ zabbix_server_url }}" login_user: "{{ zabbix_login_user }}" login_password: "{{ zabbix_login_password }}" @@ -659,7 +659,7 @@ - name: test - discovery actions module_defaults: - zabbix_action: + community.zabbix.zabbix_action: server_url: "{{ zabbix_server_url }}" login_user: "{{ zabbix_login_user }}" login_password: "{{ zabbix_login_password }}" @@ -820,7 +820,7 @@ - name: test - auto registration actions module_defaults: - zabbix_action: + community.zabbix.zabbix_action: server_url: "{{ zabbix_server_url }}" login_user: "{{ zabbix_login_user }}" login_password: "{{ zabbix_login_password }}" @@ -911,7 +911,7 @@ - name: test - internal actions module_defaults: - zabbix_action: + community.zabbix.zabbix_action: server_url: "{{ zabbix_server_url }}" login_user: "{{ zabbix_login_user }}" login_password: "{{ zabbix_login_password }}" @@ -1015,7 +1015,7 @@ when: - zabbix_version is version('3.4', '>=') module_defaults: - zabbix_action: + community.zabbix.zabbix_action: server_url: "{{ zabbix_server_url }}" login_user: "{{ zabbix_login_user }}" login_password: "{{ zabbix_login_password }}" diff --git a/tests/integration/targets/test_zabbix_discovery_rule/tasks/main.yml b/tests/integration/targets/test_zabbix_discovery_rule/tasks/main.yml index 5f31d48de..e29f8e0e1 100644 --- a/tests/integration/targets/test_zabbix_discovery_rule/tasks/main.yml +++ b/tests/integration/targets/test_zabbix_discovery_rule/tasks/main.yml @@ -5,7 +5,7 @@ - name: test - Zabbix discovery rule module_defaults: - zabbix_discovery_rule: + community.zabbix.zabbix_discovery_rule: server_url: "{{ zabbix_server_url }}" login_user: "{{ zabbix_login_user }}" login_password: "{{ zabbix_login_password }}" diff --git a/tests/integration/targets/test_zabbix_host_info/tasks/main.yml b/tests/integration/targets/test_zabbix_host_info/tasks/main.yml index 9f072a9fb..8835cf926 100644 --- a/tests/integration/targets/test_zabbix_host_info/tasks/main.yml +++ b/tests/integration/targets/test_zabbix_host_info/tasks/main.yml @@ -33,7 +33,7 @@ - name: "test - Set default parameters to zabbix_host_info" module_defaults: - zabbix_host_info: + community.zabbix.zabbix_host_info: server_url: "{{ zabbix_server_url }}" login_user: "{{ zabbix_login_user }}" login_password: "{{ zabbix_login_password }}" diff --git a/tests/integration/targets/test_zabbix_mediatype/tasks/main.yml b/tests/integration/targets/test_zabbix_mediatype/tasks/main.yml index b74a5b7dd..0a3bf9050 100644 --- a/tests/integration/targets/test_zabbix_mediatype/tasks/main.yml +++ b/tests/integration/targets/test_zabbix_mediatype/tasks/main.yml @@ -1,7 +1,7 @@ --- - name: test - email mediatypes module_defaults: - zabbix_mediatype: + community.zabbix.zabbix_mediatype: server_url: "{{ zabbix_server_url }}" login_user: "{{ zabbix_login_user }}" login_password: "{{ zabbix_login_password }}" @@ -313,7 +313,7 @@ - name: test - script mediatypes module_defaults: - zabbix_mediatype: + community.zabbix.zabbix_mediatype: server_url: "{{ zabbix_server_url }}" login_user: "{{ zabbix_login_user }}" login_password: "{{ zabbix_login_password }}" @@ -378,7 +378,7 @@ - name: test - sms mediatypes module_defaults: - zabbix_mediatype: + community.zabbix.zabbix_mediatype: server_url: "{{ zabbix_server_url }}" login_user: "{{ zabbix_login_user }}" login_password: "{{ zabbix_login_password }}" @@ -448,7 +448,7 @@ - name: test - jabber mediatypes when: zabbix_version is version('4.2', '<=') module_defaults: - zabbix_mediatype: + community.zabbix.zabbix_mediatype: server_url: "{{ zabbix_server_url }}" login_user: "{{ zabbix_login_user }}" login_password: "{{ zabbix_login_password }}" @@ -486,7 +486,7 @@ - name: test - ez_texting mediatypes when: zabbix_version is version('4.2', '<=') module_defaults: - zabbix_mediatype: + community.zabbix.zabbix_mediatype: server_url: "{{ zabbix_server_url }}" login_user: "{{ zabbix_login_user }}" login_password: "{{ zabbix_login_password }}" @@ -536,7 +536,7 @@ - name: test - email mediatypes when: zabbix_version is version('4.4', '>=') module_defaults: - zabbix_mediatype: + community.zabbix.zabbix_mediatype: server_url: "{{ zabbix_server_url }}" login_user: "{{ zabbix_login_user }}" login_password: "{{ zabbix_login_password }}" diff --git a/tests/integration/targets/test_zabbix_service/defaults/main.yml b/tests/integration/targets/test_zabbix_service/defaults/main.yml new file mode 100644 index 000000000..2a50fa6ae --- /dev/null +++ b/tests/integration/targets/test_zabbix_service/defaults/main.yml @@ -0,0 +1,2 @@ +--- +service_example_trigger: "Zabbix http poller processes more than 75% busy" diff --git a/tests/integration/targets/test_zabbix_service/tasks/main.yml b/tests/integration/targets/test_zabbix_service/tasks/main.yml index ae6105d91..54cfaf004 100644 --- a/tests/integration/targets/test_zabbix_service/tasks/main.yml +++ b/tests/integration/targets/test_zabbix_service/tasks/main.yml @@ -131,6 +131,11 @@ that: - update_calculate_sla_idempotency_check_result.changed is sameas false +- name: "Override trigger_name for different version of Zabbix" + set_fact: + service_example_trigger: "Zabbix server: Utilization of http poller processes over 75%" + when: zabbix_version is version("5.0", "==") + - name: "test - Update trigger_host and trigger_name with check_mode" zabbix_service: server_url: "{{ zabbix_server_url }}" @@ -140,7 +145,7 @@ sla: 99.999 calculate_sla: yes trigger_host: "Zabbix server" - trigger_name: "Zabbix http poller processes more than 75% busy" + trigger_name: "{{ service_example_trigger }}" state: present check_mode: yes register: update_trigger_name_check_mode_result @@ -158,7 +163,7 @@ sla: 99.999 calculate_sla: yes trigger_host: "Zabbix server" - trigger_name: "Zabbix http poller processes more than 75% busy" + trigger_name: "{{ service_example_trigger }}" state: present register: update_trigger_name_result @@ -175,7 +180,7 @@ sla: 99.999 calculate_sla: yes trigger_host: "Zabbix server" - trigger_name: "Zabbix http poller processes more than 75% busy" + trigger_name: "{{ service_example_trigger }}" state: present register: update_trigger_name_idempotency_check_result @@ -192,7 +197,7 @@ sla: 99.999 calculate_sla: yes trigger_host: "Zabbix server" - trigger_name: "Zabbix http poller processes more than 75% busy" + trigger_name: "{{ service_example_trigger }}" algorithm: all_children state: present check_mode: yes @@ -211,7 +216,7 @@ sla: 99.999 calculate_sla: yes trigger_host: "Zabbix server" - trigger_name: "Zabbix http poller processes more than 75% busy" + trigger_name: "{{ service_example_trigger }}" algorithm: all_children state: present register: update_algorithm_result @@ -229,7 +234,7 @@ sla: 99.999 calculate_sla: yes trigger_host: "Zabbix server" - trigger_name: "Zabbix http poller processes more than 75% busy" + trigger_name: "{{ service_example_trigger }}" algorithm: all_children state: present register: update_algorithm_idempotency_check_result @@ -261,7 +266,7 @@ sla: 99.999 calculate_sla: yes trigger_host: "Zabbix server" - trigger_name: "Zabbix http poller processes more than 75% busy" + trigger_name: "{{ service_example_trigger }}" algorithm: all_children parent: ExampleServiceForServiceModuleRoot state: present @@ -281,7 +286,7 @@ sla: 99.999 calculate_sla: yes trigger_host: "Zabbix server" - trigger_name: "Zabbix http poller processes more than 75% busy" + trigger_name: "{{ service_example_trigger }}" algorithm: all_children parent: ExampleServiceForServiceModuleRoot state: present @@ -300,7 +305,7 @@ sla: 99.999 calculate_sla: yes trigger_host: "Zabbix server" - trigger_name: "Zabbix http poller processes more than 75% busy" + trigger_name: "{{ service_example_trigger }}" algorithm: all_children parent: ExampleServiceForServiceModuleRoot state: present diff --git a/tests/integration/targets/test_zabbix_usergroup/tasks/main.yml b/tests/integration/targets/test_zabbix_usergroup/tasks/main.yml index 5e7833012..439e0f6ab 100644 --- a/tests/integration/targets/test_zabbix_usergroup/tasks/main.yml +++ b/tests/integration/targets/test_zabbix_usergroup/tasks/main.yml @@ -5,7 +5,7 @@ - name: test - Zabbix user group module_defaults: - zabbix_usergroup: + community.zabbix.zabbix_usergroup: server_url: "{{ zabbix_server_url }}" login_user: "{{ zabbix_login_user }}" login_password: "{{ zabbix_login_password }}"