diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-18 05:52:22 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-18 05:52:22 +0000 |
commit | 38b7c80217c4e72b1d8988eb1e60bb6e77334114 (patch) | |
tree | 356e9fd3762877d07cde52d21e77070aeff7e789 /ansible_collections/community/zabbix/tests/integration/targets | |
parent | Adding upstream version 7.7.0+dfsg. (diff) | |
download | ansible-38b7c80217c4e72b1d8988eb1e60bb6e77334114.tar.xz ansible-38b7c80217c4e72b1d8988eb1e60bb6e77334114.zip |
Adding upstream version 9.4.0+dfsg.upstream/9.4.0+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/community/zabbix/tests/integration/targets')
51 files changed, 5956 insertions, 7646 deletions
diff --git a/ansible_collections/community/zabbix/tests/integration/targets/setup_zabbix/tasks/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/setup_zabbix/tasks/main.yml index ba4c30311..fd7f6a700 100644 --- a/ansible_collections/community/zabbix/tests/integration/targets/setup_zabbix/tasks/main.yml +++ b/ansible_collections/community/zabbix/tests/integration/targets/setup_zabbix/tasks/main.yml @@ -1,6 +1,6 @@ --- - name: get zabbix version - uri: + ansible.builtin.uri: url: "{{ zabbix_api_server_url }}/api_jsonrpc.php" method: POST body: @@ -16,7 +16,7 @@ register: zabbix_version_result - name: set zabbix_version variable - set_fact: + ansible.builtin.set_fact: zabbix_version: >- {{ [0,1] | map('extract', zabbix_version_result.json.result.split('.')) @@ -27,7 +27,7 @@ ansible_connection: httpapi # ansible_zabbix_auth_key: 8ec0d52432c15c91fcafe9888500cf9a607f44091ab554dbee860f6b44fac895 ansible_host: 127.0.0.1 - ansible_zabbix_url_path: '' + ansible_zabbix_url_path: "" ansible_httpapi_port: 8080 ansible_httpapi_use_ssl: false ansible_httpapi_validate_certs: false @@ -36,7 +36,7 @@ - debug: var=zabbix_version - name: check login to zabbix for Zabbix < 6.4 - uri: + ansible.builtin.uri: url: "{{ zabbix_api_server_url }}/api_jsonrpc.php" method: POST body: @@ -55,7 +55,7 @@ when: zabbix_version is version('6.4', '<') - name: check login to zabbix for Zabbix >= 6.4 - uri: + ansible.builtin.uri: url: "{{ zabbix_api_server_url }}/api_jsonrpc.php" method: POST body: diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_action/tasks/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_action/tasks/main.yml index 6893dfd56..446f7cd3b 100644 --- a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_action/tasks/main.yml +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_action/tasks/main.yml @@ -1,13 +1,6 @@ --- -- name: test - do not run tests for Zabbix 3.0 - meta: end_play - when: zabbix_version is version('3.0', '=') - - name: test - prepare example template for zabbix_action module - zabbix_template: - server_url: "{{ zabbix_api_server_url }} " - login_user: "{{ zabbix_api_login_user }}" - login_password: "{{ zabbix_api_login_pass }}" + community.zabbix.zabbix_template: template_name: ExampleTemplateForActionModule template_groups: - Templates @@ -15,10 +8,7 @@ register: zbxaction_prep_template - name: test - prepare example mediatype for zabbix_action module - zabbix_mediatype: - server_url: "{{ zabbix_api_server_url }} " - login_user: "{{ zabbix_api_login_user }}" - login_password: "{{ zabbix_api_login_pass }}" + community.zabbix.zabbix_mediatype: name: ExampleMediaTypeForActionModule smtp_email: zabbix@example.com type: email @@ -32,223 +22,139 @@ status: enabled name: ExampleTriggerAction event_source: trigger + notify_if_canceled: true esc_period: 60 conditions: - type: trigger_severity - operator: '>=' + operator: ">=" value: Information operations: - type: send_message subject: ExampleSubject - message: ExampleMessage + op_message: ExampleMessage media_type: ExampleMediaTypeForActionModule send_to_users: - Admin block: - - name: test - create new action - zabbix_action: - register: zbxaction_new + - name: test - create new action + community.zabbix.zabbix_action: + register: zbxaction_new - - assert: - that: zbxaction_new.changed is sameas True + - ansible.builtin.assert: + that: zbxaction_new.changed is sameas True - - name: test - create new action (again) - zabbix_action: - register: zbxaction_new + - name: test - create new action (again) + community.zabbix.zabbix_action: + register: zbxaction_new - - assert: - that: zbxaction_new.changed is sameas False + - ansible.builtin.assert: + that: zbxaction_new.changed is sameas False - - when: zabbix_version is version('3.4', '>=') - block: - name: test - update action with esc_period as string - zabbix_action: + community.zabbix.zabbix_action: esc_period: 2m register: zbxaction_escperiod_str - - assert: + - ansible.builtin.assert: that: zbxaction_escperiod_str.changed is sameas True - name: test - update action with esc_period as string (again) - zabbix_action: + community.zabbix.zabbix_action: esc_period: 2m register: zbxaction_escperiod_str - - assert: + - ansible.builtin.assert: that: zbxaction_escperiod_str.changed is sameas False - name: test - update action with esc_period as macro - zabbix_action: - esc_period: '{$MYMACRO}' + community.zabbix.zabbix_action: + esc_period: "{$MYMACRO}" register: zbxaction_escperiod_macro - - assert: + - ansible.builtin.assert: that: zbxaction_escperiod_macro.changed is sameas True - name: test - update action with esc_period as macro (again) - zabbix_action: - esc_period: '{$MYMACRO}' + community.zabbix.zabbix_action: + esc_period: "{$MYMACRO}" register: zbxaction_escperiod_macro - - assert: + - ansible.builtin.assert: that: zbxaction_escperiod_macro.changed is sameas False - - name: test - update action with esc_period - zabbix_action: - esc_period: 120 - register: zbxaction_escperiod - - - assert: - that: zbxaction_escperiod.changed is sameas True - - - name: test - update action with esc_period (again) - zabbix_action: - esc_period: 120 - register: zbxaction_escperiod - - - assert: - that: zbxaction_escperiod.changed is sameas False - - - name: test - update action with pause_in_maintenance - zabbix_action: - esc_period: 120 - pause_in_maintenance: false - register: zbxaction_maintpause - - - assert: - that: zbxaction_maintpause.changed is sameas True - - - name: test - update action with pause_in_maintenance (again) - zabbix_action: - esc_period: 120 - pause_in_maintenance: false - register: zbxaction_maintpause - - - assert: - that: zbxaction_maintpause.changed is sameas False - - - name: test - reset action to default - zabbix_action: - register: zbxaction_reset - - - assert: - that: zbxaction_reset.changed is sameas True - - - when: zabbix_version is version('5.0', '<') - block: - - name: test - update action with default_subject and default_message - zabbix_action: - default_subject: Example default subject - default_message: Example default message - register: zbxaction_def_msgsubj - - - assert: - that: zbxaction_def_msgsubj.changed is sameas True - - - name: test - update action with default_subject and default_message (again) - zabbix_action: - default_subject: Example default subject - default_message: Example default message - register: zbxaction_def_msgsubj - - - assert: - that: zbxaction_def_msgsubj.changed is sameas False - - - when: - - zabbix_version is version('3.2', '>=') - - zabbix_version is version('5.0', '<') - block: - - name: test - update action with recovery_default_subject and recovery_default_message - zabbix_action: - default_subject: Example default subject - default_message: Example default message - recovery_default_subject: Example recovery subject - recovery_default_message: Example recovery message - register: zbxaction_rec_msgsubj - - - assert: - that: zbxaction_rec_msgsubj.changed is sameas True - - - name: test - update action with recovery_default_subject and recovery_default_message (again) - zabbix_action: - default_subject: Example default subject - default_message: Example default message - recovery_default_subject: Example recovery subject - recovery_default_message: Example recovery message - register: zbxaction_rec_msgsubj - - - assert: - that: zbxaction_rec_msgsubj.changed is sameas False - - - when: - - zabbix_version is version('3.4', '>=') - - zabbix_version is version('5.0', '<') - block: - - name: test - update action with acknowledge_default_subject and acknowledge_default_message - zabbix_action: - default_subject: Example default subject - default_message: Example default message - recovery_default_subject: Example recovery subject - recovery_default_message: Example recovery message - acknowledge_default_subject: Example acknowledge subject - acknowledge_default_message: Example acknowledge message - register: zbxaction_ack_msgsubj - - - assert: - that: zbxaction_ack_msgsubj.changed is sameas True - - - name: test - update action with acknowledge_default_subject and acknowledge_default_message (again) - zabbix_action: - default_subject: Example default subject - default_message: Example default message - recovery_default_subject: Example recovery subject - recovery_default_message: Example recovery message - acknowledge_default_subject: Example acknowledge subject - acknowledge_default_message: Example acknowledge message - register: zbxaction_ack_msgsubj - - - assert: - that: zbxaction_ack_msgsubj.changed is sameas False + - name: test - update action with esc_period + community.zabbix.zabbix_action: + esc_period: 120 + register: zbxaction_escperiod + + - ansible.builtin.assert: + that: zbxaction_escperiod.changed is sameas True + + - name: test - update action with esc_period (again) + community.zabbix.zabbix_action: + esc_period: 120 + register: zbxaction_escperiod + + - ansible.builtin.assert: + that: zbxaction_escperiod.changed is sameas False + + - name: test - update action with pause_in_maintenance + community.zabbix.zabbix_action: + esc_period: 120 + pause_in_maintenance: false + register: zbxaction_maintpause + + - ansible.builtin.assert: + that: zbxaction_maintpause.changed is sameas True + + - name: test - update action with pause_in_maintenance (again) + community.zabbix.zabbix_action: + esc_period: 120 + pause_in_maintenance: false + register: zbxaction_maintpause + + - ansible.builtin.assert: + that: zbxaction_maintpause.changed is sameas False - name: test - reset action to default - zabbix_action: + community.zabbix.zabbix_action: register: zbxaction_reset - - assert: + - ansible.builtin.assert: that: zbxaction_reset.changed is sameas True - - name: test - disable action - zabbix_action: - status: disabled - register: zbxaction_disable + - name: test - disable action + community.zabbix.zabbix_action: + status: disabled + register: zbxaction_disable - - assert: - that: zbxaction_disable.changed is sameas True + - ansible.builtin.assert: + that: zbxaction_disable.changed is sameas True - - name: test - disable action (again) - zabbix_action: - status: disabled - register: zbxaction_disable + - name: test - disable action (again) + community.zabbix.zabbix_action: + status: disabled + register: zbxaction_disable - - assert: - that: zbxaction_disable.changed is sameas False + - ansible.builtin.assert: + that: zbxaction_disable.changed is sameas False - - name: test - delete action - zabbix_action: - state: absent - register: zbxaction_delete + - name: test - delete action + community.zabbix.zabbix_action: + state: absent + register: zbxaction_delete - - assert: - that: zbxaction_delete.changed is sameas True + - ansible.builtin.assert: + that: zbxaction_delete.changed is sameas True - - name: test - delete action (again) - zabbix_action: - state: absent - register: zbxaction_delete + - name: test - delete action (again) + community.zabbix.zabbix_action: + state: absent + register: zbxaction_delete - - assert: - that: zbxaction_delete.changed is sameas False + - ansible.builtin.assert: + that: zbxaction_delete.changed is sameas False - name: test - trigger actions with conditions module_defaults: @@ -257,244 +163,245 @@ status: enabled name: ExampleTriggerActionConditions event_source: trigger + notify_if_canceled: true esc_period: 60 operations: - type: send_message subject: ExampleSubject - message: ExampleMessage + op_message: ExampleMessage media_type: ExampleMediaTypeForActionModule send_to_users: - Admin block: - - name: test - create new action with multiple conditions - zabbix_action: - conditions: - - type: host_group - operator: '=' - value: Linux servers - - type: trigger_severity - operator: '>=' - value: Average - - type: event_tag_value - value: MyTag - operator: '=' - value2: MyTagValue - - type: time_period - operator: not in - value: 6-7,00:00-24:00 - register: zbxaction_conditions - - - assert: - that: zbxaction_conditions.changed is sameas True - - - name: test - create new action with multiple conditions (again) - zabbix_action: - conditions: - - type: host_group - operator: '=' - value: Linux servers - - type: trigger_severity - operator: '>=' - value: Average - - type: event_tag_value - value: MyTag - operator: '=' - value2: MyTagValue - - type: time_period - operator: not in - value: 6-7,00:00-24:00 - register: zbxaction_conditions - - - assert: - that: zbxaction_conditions.changed is sameas False - - - name: test - create new action with multiple conditions (reorder) - zabbix_action: - conditions: - - type: host_group - operator: '=' - value: Linux servers - - type: event_tag_value - value: MyTag - operator: '=' - value2: MyTagValue - - type: trigger_severity - operator: '>=' - value: Average - - type: time_period - operator: not in - value: 6-7,00:00-24:00 - register: zbxaction_conditions_reorder - - - assert: - that: zbxaction_conditions_reorder.changed is sameas False - - - name: test - update action with multiple conditions by removing one condition - zabbix_action: - conditions: - - type: host_group - operator: '=' - value: Linux servers - - type: event_tag_value - value: MyTag - operator: '=' - value2: MyTagValue - - type: trigger_severity - operator: '>=' - value: Average - register: zbxaction_conditions_delone - - - assert: - that: zbxaction_conditions_delone.changed is sameas True - - - name: test - update action with multiple conditions by changing operators - zabbix_action: - conditions: - - type: host_group - operator: '<>' - value: Linux servers - - type: event_tag_value - value: MyTag - operator: '<>' - value2: MyTagValue - - type: trigger_severity - operator: '<=' - value: Average - register: zbxaction_conditions_operators - - - assert: - that: zbxaction_conditions_operators.changed is sameas True - - - name: test - update action with multiple conditions with operator aliases - zabbix_action: - conditions: - - type: host_group - operator: does not equal - value: Linux servers - - type: event_tag_value - value: MyTag - operator: contains - value2: MyTagValue - - type: trigger_severity - operator: is less than or equals - value: Average - register: zbxaction_conditions_operator_aliases - - - assert: - that: zbxaction_conditions_operator_aliases.changed is sameas True - - - name: test - update action with multiple conditions and evaltype - zabbix_action: - conditions: - - type: host_group - operator: '<>' - value: Linux servers - - type: event_tag_value - value: MyTag - operator: '<>' - value2: MyTagValue - - type: trigger_severity - operator: '<=' - value: Average - eval_type: and - register: zbxaction_conditions_eval - - - assert: - that: zbxaction_conditions_eval.changed is sameas True - - - name: test - update action with multiple conditions and evaltype (again) - zabbix_action: - conditions: - - type: host_group - operator: '<>' - value: Linux servers - - type: event_tag_value - value: MyTag - operator: '<>' - value2: MyTagValue - - type: trigger_severity - operator: '<=' - value: Average - eval_type: and - register: zbxaction_conditions_eval - - - assert: - that: zbxaction_conditions_eval.changed is sameas False - - - name: test - update action with reduced conditions and formula - zabbix_action: - conditions: - - type: host_group - operator: '=' - value: Linux servers - formulaid: A - - type: trigger_severity - operator: '>=' - value: Average - formulaid: B - - type: event_tag_value - value: MyTag - operator: '<>' - value2: MyTagValue - formulaid: C - formula: A and (B or C) - register: zbxaction_conditions_formula - - - assert: - that: zbxaction_conditions_formula.changed is sameas True - - - name: test - update formula used in action with reduced conditions - zabbix_action: - conditions: - - type: host_group - operator: '=' - value: Linux servers - formulaid: A - - type: trigger_severity - operator: '>=' - value: Average - formulaid: B - - type: event_tag_value - value: MyTag - operator: '<>' - value2: MyTagValue - formulaid: C - formula: (A or B) or C - register: zbxaction_conditions_formula - - - assert: - that: zbxaction_conditions_formula.changed is sameas True - - - name: test - update formula used in action with reduced conditions (again) - zabbix_action: - conditions: - - type: host_group - operator: '=' - value: Linux servers - formulaid: A - - type: trigger_severity - operator: '>=' - value: Average - formulaid: B - - type: event_tag_value - value: MyTag - operator: '<>' - value2: MyTagValue - formulaid: C - formula: (A or B) or C - register: zbxaction_conditions_formula - - - assert: - that: zbxaction_conditions_formula.changed is sameas False - - - name: test - delete action - zabbix_action: - state: absent - register: zbxaction_delete - - - assert: - that: zbxaction_delete.changed is sameas True + - name: test - create new action with multiple conditions + community.zabbix.zabbix_action: + conditions: + - type: host_group + operator: "=" + value: Linux servers + - type: trigger_severity + operator: ">=" + value: Average + - type: event_tag_value + value: MyTag + operator: "=" + value2: MyTagValue + - type: time_period + operator: not in + value: 6-7,00:00-24:00 + register: zbxaction_conditions + + - ansible.builtin.assert: + that: zbxaction_conditions.changed is sameas True + + - name: test - create new action with multiple conditions (again) + community.zabbix.zabbix_action: + conditions: + - type: host_group + operator: "=" + value: Linux servers + - type: trigger_severity + operator: ">=" + value: Average + - type: event_tag_value + value: MyTag + operator: "=" + value2: MyTagValue + - type: time_period + operator: not in + value: 6-7,00:00-24:00 + register: zbxaction_conditions + + - ansible.builtin.assert: + that: zbxaction_conditions.changed is sameas False + + - name: test - create new action with multiple conditions (reorder) + community.zabbix.zabbix_action: + conditions: + - type: host_group + operator: "=" + value: Linux servers + - type: event_tag_value + value: MyTag + operator: "=" + value2: MyTagValue + - type: trigger_severity + operator: ">=" + value: Average + - type: time_period + operator: not in + value: 6-7,00:00-24:00 + register: zbxaction_conditions_reorder + + - ansible.builtin.assert: + that: zbxaction_conditions_reorder.changed is sameas False + + - name: test - update action with multiple conditions by removing one condition + community.zabbix.zabbix_action: + conditions: + - type: host_group + operator: "=" + value: Linux servers + - type: event_tag_value + value: MyTag + operator: "=" + value2: MyTagValue + - type: trigger_severity + operator: ">=" + value: Average + register: zbxaction_conditions_delone + + - ansible.builtin.assert: + that: zbxaction_conditions_delone.changed is sameas True + + - name: test - update action with multiple conditions by changing operators + community.zabbix.zabbix_action: + conditions: + - type: host_group + operator: "<>" + value: Linux servers + - type: event_tag_value + value: MyTag + operator: "<>" + value2: MyTagValue + - type: trigger_severity + operator: "<=" + value: Average + register: zbxaction_conditions_operators + + - ansible.builtin.assert: + that: zbxaction_conditions_operators.changed is sameas True + + - name: test - update action with multiple conditions with operator aliases + community.zabbix.zabbix_action: + conditions: + - type: host_group + operator: does not equal + value: Linux servers + - type: event_tag_value + value: MyTag + operator: contains + value2: MyTagValue + - type: trigger_severity + operator: is less than or equals + value: Average + register: zbxaction_conditions_operator_aliases + + - ansible.builtin.assert: + that: zbxaction_conditions_operator_aliases.changed is sameas True + + - name: test - update action with multiple conditions and evaltype + community.zabbix.zabbix_action: + conditions: + - type: host_group + operator: "<>" + value: Linux servers + - type: event_tag_value + value: MyTag + operator: "<>" + value2: MyTagValue + - type: trigger_severity + operator: "<=" + value: Average + eval_type: and + register: zbxaction_conditions_eval + + - ansible.builtin.assert: + that: zbxaction_conditions_eval.changed is sameas True + + - name: test - update action with multiple conditions and evaltype (again) + community.zabbix.zabbix_action: + conditions: + - type: host_group + operator: "<>" + value: Linux servers + - type: event_tag_value + value: MyTag + operator: "<>" + value2: MyTagValue + - type: trigger_severity + operator: "<=" + value: Average + eval_type: and + register: zbxaction_conditions_eval + + - ansible.builtin.assert: + that: zbxaction_conditions_eval.changed is sameas False + + - name: test - update action with reduced conditions and formula + community.zabbix.zabbix_action: + conditions: + - type: host_group + operator: "=" + value: Linux servers + formulaid: A + - type: trigger_severity + operator: ">=" + value: Average + formulaid: B + - type: event_tag_value + value: MyTag + operator: "<>" + value2: MyTagValue + formulaid: C + formula: A and (B or C) + register: zbxaction_conditions_formula + + - ansible.builtin.assert: + that: zbxaction_conditions_formula.changed is sameas True + + - name: test - update formula used in action with reduced conditions + community.zabbix.zabbix_action: + conditions: + - type: host_group + operator: "=" + value: Linux servers + formulaid: A + - type: trigger_severity + operator: ">=" + value: Average + formulaid: B + - type: event_tag_value + value: MyTag + operator: "<>" + value2: MyTagValue + formulaid: C + formula: (A or B) or C + register: zbxaction_conditions_formula + + - ansible.builtin.assert: + that: zbxaction_conditions_formula.changed is sameas True + + - name: test - update formula used in action with reduced conditions (again) + community.zabbix.zabbix_action: + conditions: + - type: host_group + operator: "=" + value: Linux servers + formulaid: A + - type: trigger_severity + operator: ">=" + value: Average + formulaid: B + - type: event_tag_value + value: MyTag + operator: "<>" + value2: MyTagValue + formulaid: C + formula: (A or B) or C + register: zbxaction_conditions_formula + + - ansible.builtin.assert: + that: zbxaction_conditions_formula.changed is sameas False + + - name: test - delete action + community.zabbix.zabbix_action: + state: absent + register: zbxaction_delete + + - ansible.builtin.assert: + that: zbxaction_delete.changed is sameas True - name: test - trigger actions with message operations module_defaults: @@ -503,234 +410,139 @@ status: enabled name: ExampleTriggerActionOperations event_source: trigger + notify_if_canceled: true esc_period: 60 conditions: - type: trigger_severity - operator: '>=' + operator: ">=" value: Average block: - - name: test - create new action with send_message operations - zabbix_action: - operations: - - type: send_message - send_to_users: - - Admin - subject: test_subject - message: test_message - media_type: ExampleMediaTypeForActionModule - operation_condition: not_acknowledged - esc_step_from: 1 - esc_step_to: 2 - - type: send_message - send_to_users: - - Admin - subject: test_subject - message: test_message - media_type: SMS - operation_condition: not_acknowledged - esc_step_from: 2 - esc_step_to: 0 - esc_period: 300 - register: zbxaction_ops - - - assert: - that: zbxaction_ops.changed is sameas True - - - name: test - create new action with send_message operations (again) - zabbix_action: - operations: - - type: send_message - send_to_users: - - Admin - subject: test_subject - message: test_message - media_type: ExampleMediaTypeForActionModule - operation_condition: not_acknowledged - esc_step_from: 1 - esc_step_to: 2 - - type: send_message - send_to_users: - - Admin - subject: test_subject - message: test_message - media_type: SMS - operation_condition: not_acknowledged - esc_step_from: 2 - esc_step_to: 0 - esc_period: 300 - register: zbxaction_ops - - - assert: - that: zbxaction_ops.changed is sameas False - - - name: test - delete action - zabbix_action: - state: absent - register: zbxaction_delete - - - assert: - that: zbxaction_delete.changed is sameas True - - - name: test - create new action with escalation steps 1-1 - zabbix_action: - operations: - - type: send_message - send_to_users: - - Admin - media_type: ExampleMediaTypeForActionModule - esc_step_from: 1 - esc_step_to: 1 - register: zbxaction_esc11 + - name: test - create new action with send_message operations + community.zabbix.zabbix_action: + operations: + - type: send_message + send_to_users: + - Admin + subject: test_subject + op_message: test_message + media_type: ExampleMediaTypeForActionModule + operation_condition: not_acknowledged + esc_step_from: 1 + esc_step_to: 2 + - type: send_message + send_to_users: + - Admin + subject: test_subject + op_message: test_message + media_type: SMS + operation_condition: not_acknowledged + esc_step_from: 2 + esc_step_to: 0 + esc_period: 300 + register: zbxaction_ops + + - ansible.builtin.assert: + that: zbxaction_ops.changed is sameas True + + - name: test - create new action with send_message operations (again) + community.zabbix.zabbix_action: + operations: + - type: send_message + send_to_users: + - Admin + subject: test_subject + op_message: test_message + media_type: ExampleMediaTypeForActionModule + operation_condition: not_acknowledged + esc_step_from: 1 + esc_step_to: 2 + - type: send_message + send_to_users: + - Admin + subject: test_subject + op_message: test_message + media_type: SMS + operation_condition: not_acknowledged + esc_step_from: 2 + esc_step_to: 0 + esc_period: 300 + register: zbxaction_ops + + - ansible.builtin.assert: + that: zbxaction_ops.changed is sameas False + + - name: test - delete action + community.zabbix.zabbix_action: + state: absent + register: zbxaction_delete + + - ansible.builtin.assert: + that: zbxaction_delete.changed is sameas True + + - name: test - create new action with escalation steps 1-1 + community.zabbix.zabbix_action: + operations: + - type: send_message + send_to_users: + - Admin + media_type: ExampleMediaTypeForActionModule + esc_step_from: 1 + esc_step_to: 1 + register: zbxaction_esc11 - - assert: - that: zbxaction_esc11.changed is sameas True + - ansible.builtin.assert: + that: zbxaction_esc11.changed is sameas True - - name: test - create new action with escalation steps 1-1 (again) - zabbix_action: - operations: - - type: send_message - send_to_users: - - Admin - media_type: ExampleMediaTypeForActionModule - esc_step_from: 1 - esc_step_to: 1 - register: zbxaction_esc11_again + - name: test - create new action with escalation steps 1-1 (again) + community.zabbix.zabbix_action: + operations: + - type: send_message + send_to_users: + - Admin + media_type: ExampleMediaTypeForActionModule + esc_step_from: 1 + esc_step_to: 1 + register: zbxaction_esc11_again - - assert: - that: zbxaction_esc11_again.changed is sameas False + - ansible.builtin.assert: + that: zbxaction_esc11_again.changed is sameas False + - name: test - update action with escalation steps 2-2 + community.zabbix.zabbix_action: + operations: + - type: send_message + send_to_users: + - Admin + media_type: ExampleMediaTypeForActionModule + esc_step_from: 2 + esc_step_to: 2 + register: zbxaction_esc22 - - name: test - update action with escalation steps 2-2 - zabbix_action: - operations: - - type: send_message - send_to_users: - - Admin - media_type: ExampleMediaTypeForActionModule - esc_step_from: 2 - esc_step_to: 2 - register: zbxaction_esc22 + - ansible.builtin.assert: + that: zbxaction_esc22.changed is sameas True - - assert: - that: zbxaction_esc22.changed is sameas True + - name: test - create new action with escalation steps 2-2 (again) + community.zabbix.zabbix_action: + operations: + - type: send_message + send_to_users: + - Admin + media_type: ExampleMediaTypeForActionModule + esc_step_from: 2 + esc_step_to: 2 + register: zbxaction_esc22_again - - name: test - create new action with escalation steps 2-2 (again) - zabbix_action: - operations: - - type: send_message - send_to_users: - - Admin - media_type: ExampleMediaTypeForActionModule - esc_step_from: 2 - esc_step_to: 2 - register: zbxaction_esc22_again - - - assert: - that: zbxaction_esc11_again.changed is sameas False - - - name: test - delete action - zabbix_action: - state: absent - register: zbxaction_delete - - - assert: - that: zbxaction_delete.changed is sameas True -- name: test - trigger actions with remote_script operations with < Zabbix 6.0 - when: zabbix_version is version('6.0', '<') - module_defaults: - community.zabbix.zabbix_action: - state: present - status: enabled - name: ExampleTriggerActionOperations - event_source: trigger - esc_period: 60 - conditions: - - type: trigger_severity - operator: '>=' - value: Average + - ansible.builtin.assert: + that: zbxaction_esc11_again.changed is sameas False - block: - - name: test - create new action with remote_command operations - zabbix_action: - operations: - - type: remote_command - command_type: custom_script - command: /usr/local/bin/do_something.sh - execute_on: agent - run_on_hosts: 0 - - type: remote_command - command_type: ssh - command: /usr/local/bin/do_something.sh - run_on_hosts: 0 - ssh_auth_type: password - username: root - password: zabbix - - type: remote_command - command_type: global_script - script_name: Ping - run_on_hosts: 0 - register: zbxaction_rmtcmd - - - assert: - that: zbxaction_rmtcmd.changed is sameas True - - - name: test - create new action with remote_command operations (again) - zabbix_action: - operations: - - type: remote_command - command_type: custom_script - command: /usr/local/bin/do_something.sh - execute_on: agent - run_on_hosts: 0 - - type: remote_command - command_type: ssh - command: /usr/local/bin/do_something.sh - run_on_hosts: 0 - ssh_auth_type: password - username: root - password: zabbix - - type: remote_command - command_type: global_script - script_name: Ping - run_on_hosts: 0 - register: zbxaction_rmtcmd - - - assert: - that: zbxaction_rmtcmd.changed is sameas False - - - name: test - update ssh remote_command auth in action with remote_command operations - zabbix_action: - operations: - - type: remote_command - command_type: custom_script - command: /usr/local/bin/do_something.sh - execute_on: agent - run_on_hosts: 0 - - type: remote_command - command_type: ssh - command: /usr/local/bin/do_something.sh - run_on_hosts: 0 - ssh_auth_type: public_key - username: root - ssh_privatekey_file: /etc/zabbix/.ssh/id_test - ssh_publickey_file: /etc/zabbix/.ssh/id_test.pub - - type: remote_command - command_type: global_script - script_name: Ping - run_on_hosts: 0 - register: zbxaction_rmtcmd - - - assert: - that: zbxaction_rmtcmd.changed is sameas True - - - name: test - delete action - zabbix_action: - state: absent - register: zbxaction_delete - - - assert: - that: zbxaction_delete.changed is sameas True + - name: test - delete action + community.zabbix.zabbix_action: + state: absent + register: zbxaction_delete + + - ansible.builtin.assert: + that: zbxaction_delete.changed is sameas True - name: test - discovery actions module_defaults: @@ -742,153 +554,153 @@ esc_period: 60 block: - - name: test - create new discovery action - zabbix_action: - conditions: - - type: host_IP - operator: '=' - value: '192.168.0.1-127' - - type: discovery_object - operator: '=' - value: host - - type: discovery_status - operator: '=' - value: 'discovered' - - type: uptime_or_downtime_duration - operator: '>=' - value: 1800 - operations: - - type: add_host - - type: add_to_host_group - host_groups: - - Linux servers - - type: link_to_template - templates: - - ExampleTemplateForActionModule - - type: enable_host - - type: set_host_inventory_mode - inventory: automatic - register: zbxaction_discovery - - - assert: - that: zbxaction_discovery.changed is sameas True - - - name: test - create new discovery action (again) - zabbix_action: - conditions: - - type: host_IP - operator: '=' - value: '192.168.0.1-127' - - type: discovery_object - operator: '=' - value: host - - type: discovery_status - operator: '=' - value: 'discovered' - - type: uptime_or_downtime_duration - operator: '>=' - value: 1800 - operations: - - type: add_host - - type: add_to_host_group - host_groups: - - Linux servers - - type: link_to_template - templates: - - ExampleTemplateForActionModule - - type: enable_host - - type: set_host_inventory_mode - inventory: automatic - register: zbxaction_discovery - - - assert: - that: zbxaction_discovery.changed is sameas False - - - name: test - update discovery action conditions and operations - zabbix_action: - conditions: - - type: host_IP - operator: '=' - value: '192.168.1.1-127' - - type: discovery_object - operator: '=' - value: host - - type: discovery_status - operator: '=' - value: 'discovered' - - type: uptime_or_downtime_duration - operator: '>=' - value: 2200 - operations: - - type: add_host - - type: add_to_host_group - host_groups: - - Linux servers - - Discovered hosts - - type: link_to_template - templates: - - ExampleTemplateForActionModule - - type: enable_host - - type: send_message - send_to_users: - - Admin - subject: test_subject - message: test_message - media_type: ExampleMediaTypeForActionModule - operation_condition: not_acknowledged - esc_step_from: 1 - esc_step_to: 2 - register: zbxaction_discovery_update - - - assert: - that: zbxaction_discovery_update.changed is sameas True - - - name: test - update discovery action conditions and operations (again) - zabbix_action: - conditions: - - type: host_IP - operator: '=' - value: '192.168.1.1-127' - - type: discovery_object - operator: '=' - value: host - - type: discovery_status - operator: '=' - value: 'discovered' - - type: uptime_or_downtime_duration - operator: '>=' - value: 2200 - operations: - - type: add_host - - type: add_to_host_group - host_groups: - - Linux servers - - Discovered hosts - - type: link_to_template - templates: - - ExampleTemplateForActionModule - - type: enable_host - - type: send_message - send_to_users: - - Admin - subject: test_subject - message: test_message - media_type: ExampleMediaTypeForActionModule - operation_condition: not_acknowledged - esc_step_from: 1 - esc_step_to: 2 - register: zbxaction_discovery_update + - name: test - create new discovery action + community.zabbix.zabbix_action: + conditions: + - type: host_IP + operator: "=" + value: "192.168.0.1-127" + - type: discovery_object + operator: "=" + value: host + - type: discovery_status + operator: "=" + value: "discovered" + - type: uptime_or_downtime_duration + operator: ">=" + value: 1800 + operations: + - type: add_host + - type: add_to_host_group + host_groups: + - Linux servers + - type: link_to_template + templates: + - ExampleTemplateForActionModule + - type: enable_host + - type: set_host_inventory_mode + inventory: automatic + register: zbxaction_discovery + + - ansible.builtin.assert: + that: zbxaction_discovery.changed is sameas True + + - name: test - create new discovery action (again) + community.zabbix.zabbix_action: + conditions: + - type: host_IP + operator: "=" + value: "192.168.0.1-127" + - type: discovery_object + operator: "=" + value: host + - type: discovery_status + operator: "=" + value: "discovered" + - type: uptime_or_downtime_duration + operator: ">=" + value: 1800 + operations: + - type: add_host + - type: add_to_host_group + host_groups: + - Linux servers + - type: link_to_template + templates: + - ExampleTemplateForActionModule + - type: enable_host + - type: set_host_inventory_mode + inventory: automatic + register: zbxaction_discovery + + - ansible.builtin.assert: + that: zbxaction_discovery.changed is sameas False + + - name: test - update discovery action conditions and operations + community.zabbix.zabbix_action: + conditions: + - type: host_IP + operator: "=" + value: "192.168.1.1-127" + - type: discovery_object + operator: "=" + value: host + - type: discovery_status + operator: "=" + value: "discovered" + - type: uptime_or_downtime_duration + operator: ">=" + value: 2200 + operations: + - type: add_host + - type: add_to_host_group + host_groups: + - Linux servers + - Discovered hosts + - type: link_to_template + templates: + - ExampleTemplateForActionModule + - type: enable_host + - type: send_message + send_to_users: + - Admin + subject: test_subject + op_message: test_message + media_type: ExampleMediaTypeForActionModule + operation_condition: not_acknowledged + esc_step_from: 1 + esc_step_to: 2 + register: zbxaction_discovery_update + + - ansible.builtin.assert: + that: zbxaction_discovery_update.changed is sameas True + + - name: test - update discovery action conditions and operations (again) + community.zabbix.zabbix_action: + conditions: + - type: host_IP + operator: "=" + value: "192.168.1.1-127" + - type: discovery_object + operator: "=" + value: host + - type: discovery_status + operator: "=" + value: "discovered" + - type: uptime_or_downtime_duration + operator: ">=" + value: 2200 + operations: + - type: add_host + - type: add_to_host_group + host_groups: + - Linux servers + - Discovered hosts + - type: link_to_template + templates: + - ExampleTemplateForActionModule + - type: enable_host + - type: send_message + send_to_users: + - Admin + subject: test_subject + op_message: test_message + media_type: ExampleMediaTypeForActionModule + operation_condition: not_acknowledged + esc_step_from: 1 + esc_step_to: 2 + register: zbxaction_discovery_update - - assert: - that: zbxaction_discovery_update.changed is sameas False + - ansible.builtin.assert: + that: zbxaction_discovery_update.changed is sameas False - - name: test - delete action - zabbix_action: - state: absent - register: zbxaction_delete + - name: test - delete action + community.zabbix.zabbix_action: + state: absent + register: zbxaction_delete - - assert: - that: zbxaction_delete.changed is sameas True + - ansible.builtin.assert: + that: zbxaction_delete.changed is sameas True - name: test - auto registration actions module_defaults: @@ -900,83 +712,83 @@ esc_period: 60 block: - - name: test - create new auto registration action - zabbix_action: - conditions: - - type: host_name - operator: like - value: zabbix - - type: host_metadata - operator: not like - value: somemetadata - operations: - - type: add_host - register: zbxaction_autoreg - - - assert: - that: zbxaction_autoreg.changed is sameas True - - - name: test - create new auto registration action (again) - zabbix_action: - conditions: - - type: host_name - operator: like - value: zabbix - - type: host_metadata - operator: not like - value: somemetadata - operations: - - type: add_host - register: zbxaction_autoreg - - - assert: - that: zbxaction_autoreg.changed is sameas False - - - name: test - update auto registration action - zabbix_action: - conditions: - - type: host_name - operator: like - value: zabbix - - type: host_metadata - operator: not like - value: somemetadata - - type: host_metadata - operator: like - value: somemetadata2 - operations: - - type: add_host - register: zbxaction_autoreg_update - - - assert: - that: zbxaction_autoreg_update.changed is sameas True - - - name: test - update auto registration action (again) - zabbix_action: - conditions: - - type: host_name - operator: like - value: zabbix - - type: host_metadata - operator: not like - value: somemetadata - - type: host_metadata - operator: like - value: somemetadata2 - operations: - - type: add_host - register: zbxaction_autoreg_update - - - assert: - that: zbxaction_autoreg_update.changed is sameas False - - - name: test - delete action - zabbix_action: - state: absent - register: zbxaction_delete - - - assert: - that: zbxaction_delete.changed is sameas True + - name: test - create new auto registration action + community.zabbix.zabbix_action: + conditions: + - type: host_name + operator: like + value: zabbix + - type: host_metadata + operator: not like + value: somemetadata + operations: + - type: add_host + register: zbxaction_autoreg + + - ansible.builtin.assert: + that: zbxaction_autoreg.changed is sameas True + + - name: test - create new auto registration action (again) + community.zabbix.zabbix_action: + conditions: + - type: host_name + operator: like + value: zabbix + - type: host_metadata + operator: not like + value: somemetadata + operations: + - type: add_host + register: zbxaction_autoreg + + - ansible.builtin.assert: + that: zbxaction_autoreg.changed is sameas False + + - name: test - update auto registration action + community.zabbix.zabbix_action: + conditions: + - type: host_name + operator: like + value: zabbix + - type: host_metadata + operator: not like + value: somemetadata + - type: host_metadata + operator: like + value: somemetadata2 + operations: + - type: add_host + register: zbxaction_autoreg_update + + - ansible.builtin.assert: + that: zbxaction_autoreg_update.changed is sameas True + + - name: test - update auto registration action (again) + community.zabbix.zabbix_action: + conditions: + - type: host_name + operator: like + value: zabbix + - type: host_metadata + operator: not like + value: somemetadata + - type: host_metadata + operator: like + value: somemetadata2 + operations: + - type: add_host + register: zbxaction_autoreg_update + + - ansible.builtin.assert: + that: zbxaction_autoreg_update.changed is sameas False + + - name: test - delete action + community.zabbix.zabbix_action: + state: absent + register: zbxaction_delete + + - ansible.builtin.assert: + that: zbxaction_delete.changed is sameas True - name: test - internal actions module_defaults: @@ -991,387 +803,224 @@ send_to_users: - Admin subject: test_subject - message: test_message - media_type: ExampleMediaTypeForActionModule - - block: - - name: test - create new internal action - zabbix_action: - conditions: - - type: host_template - operator: '=' - value: ExampleTemplateForActionModule - - type: event_type - operator: '=' - value: item in not supported state - register: zbxaction_internal - - - assert: - that: zbxaction_internal.changed is sameas True - - - name: test - create new internal action (again) - zabbix_action: - conditions: - - type: host_template - operator: '=' - value: ExampleTemplateForActionModule - - type: event_type - operator: '=' - value: item in not supported state - register: zbxaction_internal - - - assert: - that: zbxaction_internal.changed is sameas False - - - name: test - update internal action conditions - zabbix_action: - conditions: - - type: host_template - operator: '=' - value: ExampleTemplateForActionModule - - type: event_type - operator: '=' - value: item in not supported state - - type: event_type - operator: '=' - value: trigger in unknown state - register: zbxaction_internal_update - - - assert: - that: zbxaction_internal_update.changed is sameas True - - - name: test - update internal action conditions (again) - zabbix_action: - conditions: - - type: host_template - operator: '=' - value: ExampleTemplateForActionModule - - type: event_type - operator: '=' - value: item in not supported state - - type: event_type - operator: '=' - value: trigger in unknown state - register: zbxaction_internal_update - - - assert: - that: zbxaction_internal_update.changed is sameas False - - - name: test - delete action - zabbix_action: - state: absent - register: zbxaction_delete - - - assert: - that: zbxaction_delete.changed is sameas True - -- name: test - actions with recovery and acknowledge operations with < Zabbix 6.0 - when: - - zabbix_version is version('3.4', '>=') - - zabbix_version is version('6.0', '<') - module_defaults: - community.zabbix.zabbix_action: - state: present - status: enabled - name: ExampleTriggerActionRecAckOps - event_source: trigger - esc_period: 60 - conditions: - - type: trigger_severity - operator: '>=' - value: Information - operations: - - type: send_message - subject: ExampleSubject - message: ExampleMessage + op_message: test_message media_type: ExampleMediaTypeForActionModule - send_to_users: - - Admin block: - - name: test - create new action with recovery and acknowledge operations - zabbix_action: - recovery_operations: - - type: send_message - subject: ExampleSubject - message: ExampleMessage - media_type: ExampleMediaTypeForActionModule - send_to_users: - - Admin - - type: remote_command - command_type: custom_script - command: /usr/local/bin/do_something.sh - execute_on: agent - run_on_hosts: 0 - - type: remote_command - command_type: ssh - command: /usr/local/bin/do_something.sh - run_on_hosts: 0 - ssh_auth_type: password - username: root - password: zabbix - - type: notify_all_involved - subject: RecoverySubject - message: RecoveryMessage - acknowledge_operations: - - type: send_message - subject: ExampleSubject - message: ExampleMessage - media_type: ExampleMediaTypeForActionModule - send_to_users: - - Admin - - type: remote_command - command_type: ssh - command: /usr/local/bin/do_something.sh - run_on_hosts: 0 - ssh_auth_type: public_key - username: root - ssh_privatekey_file: /etc/zabbix/.ssh/id_test - ssh_publickey_file: /etc/zabbix/.ssh/id_test.pub - - type: remote_command - command_type: global_script - script_name: Ping - run_on_hosts: 0 - - type: notify_all_involved - subject: RecoverySubject - message: RecoveryMessage - media_type: ExampleMediaTypeForActionModule - register: zbxaction_recack_new - - - assert: - that: zbxaction_recack_new.changed is sameas True - - - name: test - create new action with recovery and acknowledge operations (again) - zabbix_action: - recovery_operations: - - type: send_message - subject: ExampleSubject - message: ExampleMessage - media_type: ExampleMediaTypeForActionModule - send_to_users: - - Admin - - type: remote_command - command_type: custom_script - command: /usr/local/bin/do_something.sh - execute_on: agent - run_on_hosts: 0 - - type: remote_command - command_type: ssh - command: /usr/local/bin/do_something.sh - run_on_hosts: 0 - ssh_auth_type: password - username: root - password: zabbix - - type: notify_all_involved - subject: RecoverySubject - message: RecoveryMessage - acknowledge_operations: - - type: send_message - subject: ExampleSubject - message: ExampleMessage - media_type: ExampleMediaTypeForActionModule - send_to_users: - - Admin - - type: remote_command - command_type: ssh - command: /usr/local/bin/do_something.sh - run_on_hosts: 0 - ssh_auth_type: public_key - username: root - ssh_privatekey_file: /etc/zabbix/.ssh/id_test - ssh_publickey_file: /etc/zabbix/.ssh/id_test.pub - - type: remote_command - command_type: global_script - script_name: Ping - run_on_hosts: 0 - - type: notify_all_involved - subject: RecoverySubject - message: RecoveryMessage - media_type: ExampleMediaTypeForActionModule - register: zbxaction_recack_new - - - assert: - that: zbxaction_recack_new.changed is sameas False - - - name: test - delete action - zabbix_action: - state: absent - register: zbxaction_delete - - - assert: - that: zbxaction_delete.changed is sameas True - -- name: test - actions with recovery and acknowledge operations with >= Zabbx 6.0 - when: - - zabbix_version is version('6.0', '>=') - module_defaults: + - name: test - create new internal action + community.zabbix.zabbix_action: + conditions: + - type: host_template + operator: "=" + value: ExampleTemplateForActionModule + - type: event_type + operator: "=" + value: item in not supported state + register: zbxaction_internal + + - ansible.builtin.assert: + that: zbxaction_internal.changed is sameas True + + - name: test - create new internal action (again) + community.zabbix.zabbix_action: + conditions: + - type: host_template + operator: "=" + value: ExampleTemplateForActionModule + - type: event_type + operator: "=" + value: item in not supported state + register: zbxaction_internal + + - ansible.builtin.assert: + that: zbxaction_internal.changed is sameas False + + - name: test - update internal action conditions + community.zabbix.zabbix_action: + conditions: + - type: host_template + operator: "=" + value: ExampleTemplateForActionModule + - type: event_type + operator: "=" + value: item in not supported state + - type: event_type + operator: "=" + value: trigger in unknown state + register: zbxaction_internal_update + + - ansible.builtin.assert: + that: zbxaction_internal_update.changed is sameas True + + - name: test - update internal action conditions (again) + community.zabbix.zabbix_action: + conditions: + - type: host_template + operator: "=" + value: ExampleTemplateForActionModule + - type: event_type + operator: "=" + value: item in not supported state + - type: event_type + operator: "=" + value: trigger in unknown state + register: zbxaction_internal_update + + - ansible.builtin.assert: + that: zbxaction_internal_update.changed is sameas False + + - name: test - delete action + community.zabbix.zabbix_action: + state: absent + register: zbxaction_delete + + - ansible.builtin.assert: + that: zbxaction_delete.changed is sameas True + +- module_defaults: community.zabbix.zabbix_action: state: present status: enabled name: ExampleTriggerActionRecAckOps event_source: trigger + notify_if_canceled: true esc_period: 60 conditions: - type: trigger_severity - operator: '>=' + operator: ">=" value: Information operations: - type: send_message subject: ExampleSubject - message: ExampleMessage + op_message: ExampleMessage media_type: ExampleMediaTypeForActionModule send_to_users: - Admin block: - - name: test - create new action with recovery and acknowledge operations - zabbix_action: - recovery_operations: - - type: send_message - subject: ExampleSubject - message: ExampleMessage - media_type: ExampleMediaTypeForActionModule - send_to_users: - - Admin - - type: notify_all_involved - subject: RecoverySubject - message: RecoveryMessage - acknowledge_operations: - - type: send_message - subject: ExampleSubject - message: ExampleMessage - media_type: ExampleMediaTypeForActionModule - send_to_users: - - Admin - - type: notify_all_involved - subject: RecoverySubject - message: RecoveryMessage - media_type: ExampleMediaTypeForActionModule - register: zbxaction_recack_new - - - assert: - that: zbxaction_recack_new.changed is sameas True - - - name: test - create new action with recovery and acknowledge operations (again) - zabbix_action: - recovery_operations: - - type: send_message - subject: ExampleSubject - message: ExampleMessage - media_type: ExampleMediaTypeForActionModule - send_to_users: - - Admin - - type: notify_all_involved - subject: RecoverySubject - message: RecoveryMessage - acknowledge_operations: - - type: send_message - subject: ExampleSubject - message: ExampleMessage - media_type: ExampleMediaTypeForActionModule - send_to_users: - - Admin - - type: notify_all_involved - subject: RecoverySubject - message: RecoveryMessage - media_type: ExampleMediaTypeForActionModule - register: zbxaction_recack_new - - - assert: - that: zbxaction_recack_new.changed is sameas False - - - when: zabbix_version is version('6.4', '>=') - block: - - name: test - update action with pause_symptoms off - zabbix_action: + - name: test - create new action with recovery and acknowledge operations + community.zabbix.zabbix_action: recovery_operations: - type: send_message subject: ExampleSubject - message: ExampleMessage + op_message: ExampleMessage media_type: ExampleMediaTypeForActionModule send_to_users: - Admin - type: notify_all_involved subject: RecoverySubject - message: RecoveryMessage + op_message: RecoveryMessage acknowledge_operations: - type: send_message subject: ExampleSubject - message: ExampleMessage + op_message: ExampleMessage media_type: ExampleMediaTypeForActionModule send_to_users: - Admin - type: notify_all_involved subject: RecoverySubject - message: RecoveryMessage + op_message: RecoveryMessage media_type: ExampleMediaTypeForActionModule - pause_symptoms: False - register: zbxaction_pause_symptoms + register: zbxaction_recack_new - - assert: - that: zbxaction_pause_symptoms.changed is sameas True + - ansible.builtin.assert: + that: zbxaction_recack_new.changed is sameas True - - name: test - update action with pause_symptoms off (again) - zabbix_action: + - name: test - create new action with recovery and acknowledge operations (again) + community.zabbix.zabbix_action: recovery_operations: - type: send_message subject: ExampleSubject - message: ExampleMessage + op_message: ExampleMessage media_type: ExampleMediaTypeForActionModule send_to_users: - Admin - type: notify_all_involved subject: RecoverySubject - message: RecoveryMessage + op_message: RecoveryMessage acknowledge_operations: - type: send_message subject: ExampleSubject - message: ExampleMessage + op_message: ExampleMessage media_type: ExampleMediaTypeForActionModule send_to_users: - Admin - type: notify_all_involved subject: RecoverySubject - message: RecoveryMessage + op_message: RecoveryMessage media_type: ExampleMediaTypeForActionModule - pause_symptoms: False - register: zbxaction_pause_symptoms - - - assert: - that: zbxaction_pause_symptoms.changed is sameas False - - - name: test - delete action - zabbix_action: - state: absent - register: zbxaction_delete - - - assert: - that: zbxaction_delete.changed is sameas True - -- name: test - Output error message when user sets application to conditions with >= Zabbix 5.4 - community.zabbix.zabbix_action: - name: ExampleApplicationAction - event_source: trigger - esc_period: 60 - conditions: - - type: application - operator: like - value: AnsibleTest - operations: - - type: send_message - subject: ExampleSubject - message: ExampleMessage - media_type: ExampleMediaTypeForActionModule - send_to_users: - - Admin - ignore_errors: true - register: zbxaction_application - -- assert: - that: - - zbxaction_application.failed is sameas True - - zbxaction_application.msg == "'application' is disabled for condition type since 5.4 version." - when: zabbix_version is version('5.4', '>=') + register: zbxaction_recack_new + + - ansible.builtin.assert: + that: zbxaction_recack_new.changed is sameas False + + - when: zabbix_version is version('6.4', '>=') + block: + - name: test - update action with pause_symptoms off + community.zabbix.zabbix_action: + recovery_operations: + - type: send_message + subject: ExampleSubject + op_message: ExampleMessage + media_type: ExampleMediaTypeForActionModule + send_to_users: + - Admin + - type: notify_all_involved + subject: RecoverySubject + op_message: RecoveryMessage + acknowledge_operations: + - type: send_message + subject: ExampleSubject + op_message: ExampleMessage + media_type: ExampleMediaTypeForActionModule + send_to_users: + - Admin + - type: notify_all_involved + subject: RecoverySubject + op_message: RecoveryMessage + media_type: ExampleMediaTypeForActionModule + pause_symptoms: False + register: zbxaction_pause_symptoms + + - ansible.builtin.assert: + that: zbxaction_pause_symptoms.changed is sameas True + + - name: test - update action with pause_symptoms off (again) + community.zabbix.zabbix_action: + recovery_operations: + - type: send_message + subject: ExampleSubject + op_message: ExampleMessage + media_type: ExampleMediaTypeForActionModule + send_to_users: + - Admin + - type: notify_all_involved + subject: RecoverySubject + op_message: RecoveryMessage + acknowledge_operations: + - type: send_message + subject: ExampleSubject + op_message: ExampleMessage + media_type: ExampleMediaTypeForActionModule + send_to_users: + - Admin + - type: notify_all_involved + subject: RecoverySubject + op_message: RecoveryMessage + media_type: ExampleMediaTypeForActionModule + pause_symptoms: False + register: zbxaction_pause_symptoms + + - ansible.builtin.assert: + that: zbxaction_pause_symptoms.changed is sameas False + + - name: test - delete action + community.zabbix.zabbix_action: + state: absent + register: zbxaction_delete + + - ansible.builtin.assert: + that: zbxaction_delete.changed is sameas True - name: delete ExampleApplicationAction action community.zabbix.zabbix_action: @@ -1379,14 +1028,13 @@ state: absent - name: test - cleanup example template for zabbix_action module - zabbix_template: + community.zabbix.zabbix_template: template_name: ExampleTemplateForActionModule - timeout: 20 state: absent register: zbxaction_prep_template - name: test - cleanup example mediatype for zabbix_action module - zabbix_mediatype: + community.zabbix.zabbix_mediatype: name: ExampleMediaTypeForActionModule type: email state: absent diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_screen/meta/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_api_info/meta/main.yml index acdb704c8..acdb704c8 100644 --- a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_screen/meta/main.yml +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_api_info/meta/main.yml diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_api_info/tasks/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_api_info/tasks/main.yml new file mode 100644 index 000000000..cb28929a4 --- /dev/null +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_api_info/tasks/main.yml @@ -0,0 +1,9 @@ +--- +- name: Retrieve API information + community.zabbix.zabbix_api_info: + register: zbxapiinfo_get + +- ansible.builtin.assert: + that: + - zbxapiinfo_get.failed is sameas False + - zbxapiinfo_get.api.version is version(zabbix_version, '>=') diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_authentication/tasks/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_authentication/tasks/main.yml index f6364f35a..37b1d2c9a 100644 --- a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_authentication/tasks/main.yml +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_authentication/tasks/main.yml @@ -1,10 +1,10 @@ --- - block: - - include_tasks: zabbix_authentication_tests.yml + - include_tasks: zabbix_authentication_tests.yml always: - - name: Cleanup - zabbix_user_directory: - name: TestUserDirectory - state: absent - ignore_errors: true + - name: Cleanup + community.zabbix.zabbix_user_directory: + name: TestUserDirectory + state: absent + ignore_errors: true diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_authentication/tasks/zabbix_authentication_tests.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_authentication/tasks/zabbix_authentication_tests.yml index effc1b900..90b8b7868 100644 --- a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_authentication/tasks/zabbix_authentication_tests.yml +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_authentication/tasks/zabbix_authentication_tests.yml @@ -1,71 +1,53 @@ --- -- name: test - do not run tests with < Zabbix 4.0 - meta: end_play - when: zabbix_version is version('4.0', '<') - -- when: zabbix_version is version('5.4', '<') - name: Unsupport Zabbix version (<5.4) - block: - - name: test - fail to update authentication setting - zabbix_authentication: - authentication_type: internal - ignore_errors: true - register: zbxauth_update - - - assert: - that: zbxauth_update.failed is sameas True - -- when: - - zabbix_version is version('5.4', '>=') - - zabbix_version is version('6.0', '<=') - name: support Zabbix version (>=5.4 <=6.0) +- when: zabbix_version is version('6.0', '=') + name: support Zabbix version (=6.0) block: - - name: test - update ldap_configured without mandatory paramters - zabbix_authentication: + - name: test - update ldap_configured without mandatory paramters + community.zabbix.zabbix_authentication: ldap_configured: true ignore_errors: true register: zbxauth_update - name: assert that authentication was NOT updated - assert: + ansible.builtin.assert: that: - zbxauth_update.failed is sameas True - zbxauth_update.msg == "Please set ldap_host, ldap_search_attribute and ldap_base_dn when you change a value of ldap_configured to true." - - name: test - update saml_auth_enabled without mandatory paramters - zabbix_authentication: + - name: test - update saml_auth_enabled without mandatory paramters + community.zabbix.zabbix_authentication: saml_auth_enabled: true ignore_errors: true register: zbxauth_update - name: assert that authentication was NOT updated - assert: + ansible.builtin.assert: that: - zbxauth_update.failed is sameas True - zbxauth_update.msg == "Please set saml_idp_entityid, saml_sso_url, saml_username_attribute and saml_sp_entityid when you change a value of saml_auth_enabled to true." - name: test - update all authentication setting - zabbix_authentication: + community.zabbix.zabbix_authentication: authentication_type: internal http_auth_enabled: true http_login_form: zabbix_login_form - http_strip_domains: 'comp,any' + http_strip_domains: "comp,any" http_case_sensitive: true ldap_configured: true - ldap_host: 'ldap://localhost' + ldap_host: "ldap://localhost" ldap_port: 389 - ldap_base_dn: 'ou=Users,ou=system' - ldap_search_attribute: 'uid' - ldap_bind_dn: 'uid=ldap_search,ou=system' + ldap_base_dn: "ou=Users,ou=system" + ldap_search_attribute: "uid" + ldap_bind_dn: "uid=ldap_search,ou=system" ldap_case_sensitive: true - ldap_bind_password: 'password' + ldap_bind_password: "password" saml_auth_enabled: true - saml_idp_entityid: '' - saml_sso_url: 'https://localhost/SAML2/SSO' - saml_slo_url: 'https://localhost/SAML2/SLO' - saml_username_attribute: 'uid' - saml_sp_entityid: 'https://localhost' - saml_nameid_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:entity' + saml_idp_entityid: "" + saml_sso_url: "https://localhost/SAML2/SSO" + saml_slo_url: "https://localhost/SAML2/SLO" + saml_username_attribute: "uid" + saml_sp_entityid: "https://localhost" + saml_nameid_format: "urn:oasis:names:tc:SAML:2.0:nameid-format:entity" saml_sign_messages: true saml_sign_assertions: true saml_sign_authn_requests: true @@ -83,11 +65,11 @@ register: zbxauth_update - name: assert that authentication was updated - assert: + ansible.builtin.assert: that: zbxauth_update.changed is sameas True - name: test - update all authentication setting (again) - zabbix_authentication: + community.zabbix.zabbix_authentication: authentication_type: internal http_auth_enabled: true http_login_form: zabbix_login_form @@ -96,20 +78,20 @@ - any http_case_sensitive: true ldap_configured: true - ldap_host: 'ldap://localhost' + ldap_host: "ldap://localhost" ldap_port: 389 - ldap_base_dn: 'ou=Users,ou=system' - ldap_search_attribute: 'uid' - ldap_bind_dn: 'uid=ldap_search,ou=system' + ldap_base_dn: "ou=Users,ou=system" + ldap_search_attribute: "uid" + ldap_bind_dn: "uid=ldap_search,ou=system" ldap_case_sensitive: true - ldap_bind_password: 'password' + ldap_bind_password: "password" saml_auth_enabled: true - saml_idp_entityid: '' - saml_sso_url: 'https://localhost/SAML2/SSO' - saml_slo_url: 'https://localhost/SAML2/SLO' - saml_username_attribute: 'uid' - saml_sp_entityid: 'https://localhost' - saml_nameid_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:entity' + saml_idp_entityid: "" + saml_sso_url: "https://localhost/SAML2/SSO" + saml_slo_url: "https://localhost/SAML2/SLO" + saml_username_attribute: "uid" + saml_sp_entityid: "https://localhost" + saml_nameid_format: "urn:oasis:names:tc:SAML:2.0:nameid-format:entity" saml_sign_messages: true saml_sign_assertions: true saml_sign_authn_requests: true @@ -127,31 +109,31 @@ register: zbxauth_update - name: assert that authentication was NOT updated - assert: + ansible.builtin.assert: that: zbxauth_update.changed is sameas False - name: test - initialize all authentication setting - zabbix_authentication: + community.zabbix.zabbix_authentication: authentication_type: internal http_auth_enabled: false http_login_form: zabbix_login_form http_strip_domains: [] http_case_sensitive: true ldap_configured: false - ldap_host: '' + ldap_host: "" ldap_port: 389 - ldap_base_dn: '' - ldap_search_attribute: '' - ldap_bind_dn: '' + ldap_base_dn: "" + ldap_search_attribute: "" + ldap_bind_dn: "" ldap_case_sensitive: true - ldap_bind_password: '' + ldap_bind_password: "" saml_auth_enabled: false - saml_idp_entityid: '' - saml_sso_url: '' - saml_slo_url: '' - saml_username_attribute: '' - saml_sp_entityid: '' - saml_nameid_format: '' + saml_idp_entityid: "" + saml_sso_url: "" + saml_slo_url: "" + saml_username_attribute: "" + saml_sp_entityid: "" + saml_nameid_format: "" saml_sign_messages: false saml_sign_assertions: false saml_sign_authn_requests: false @@ -166,62 +148,61 @@ register: zbxauth_update - name: assert that authentication was updated - assert: + ansible.builtin.assert: that: zbxauth_update.changed is sameas True -- when: - - zabbix_version is version('6.2', '=') +- when: zabbix_version is version('6.2', '=') name: support Zabbix version (=6.2) block: - name: test - create user directory - zabbix_user_directory: + community.zabbix.zabbix_user_directory: name: TestUserDirectory - host: 'test.com' + host: "test.com" port: 389 - base_dn: 'ou=Users,dc=example,dc=org' - search_attribute: 'uid' - - - name: test - update ldap_configured without mandatory paramters - zabbix_authentication: + base_dn: "ou=Users,dc=example,dc=org" + search_attribute: "uid" + + - name: test - update ldap_configured without mandatory paramters + community.zabbix.zabbix_authentication: ldap_configured: true ignore_errors: true register: zbxauth_update - name: assert that authentication was NOT updated - assert: + ansible.builtin.assert: that: - zbxauth_update.failed is sameas True - zbxauth_update.msg == "Please set ldap_userdirectory when you change a value of ldap_configured to true." - - name: test - update saml_auth_enabled without mandatory paramters - zabbix_authentication: + - name: test - update saml_auth_enabled without mandatory paramters + community.zabbix.zabbix_authentication: saml_auth_enabled: true ignore_errors: true register: zbxauth_update - name: assert that authentication was NOT updated - assert: + ansible.builtin.assert: that: - zbxauth_update.failed is sameas True - zbxauth_update.msg == "Please set saml_idp_entityid, saml_sso_url, saml_username_attribute and saml_sp_entityid when you change a value of saml_auth_enabled to true." - name: test - update all authentication setting - zabbix_authentication: + community.zabbix.zabbix_authentication: authentication_type: internal http_auth_enabled: true http_login_form: zabbix_login_form - http_strip_domains: 'comp,any' + http_strip_domains: "comp,any" http_case_sensitive: true ldap_configured: true ldap_case_sensitive: true ldap_userdirectory: TestUserDirectory saml_auth_enabled: true - saml_idp_entityid: '' - saml_sso_url: 'https://localhost/SAML2/SSO' - saml_slo_url: 'https://localhost/SAML2/SLO' - saml_username_attribute: 'uid' - saml_sp_entityid: 'https://localhost' - saml_nameid_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:entity' + saml_idp_entityid: "" + saml_sso_url: "https://localhost/SAML2/SSO" + saml_slo_url: "https://localhost/SAML2/SLO" + saml_username_attribute: "uid" + saml_sp_entityid: "https://localhost" + saml_nameid_format: "urn:oasis:names:tc:SAML:2.0:nameid-format:entity" saml_sign_messages: true saml_sign_assertions: true saml_sign_authn_requests: true @@ -239,11 +220,11 @@ register: zbxauth_update - name: assert that authentication was updated - assert: + ansible.builtin.assert: that: zbxauth_update.changed is sameas True - name: test - update all authentication setting (again) - zabbix_authentication: + community.zabbix.zabbix_authentication: authentication_type: internal http_auth_enabled: true http_login_form: zabbix_login_form @@ -255,12 +236,12 @@ ldap_case_sensitive: true ldap_userdirectory: TestUserDirectory saml_auth_enabled: true - saml_idp_entityid: '' - saml_sso_url: 'https://localhost/SAML2/SSO' - saml_slo_url: 'https://localhost/SAML2/SLO' - saml_username_attribute: 'uid' - saml_sp_entityid: 'https://localhost' - saml_nameid_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:entity' + saml_idp_entityid: "" + saml_sso_url: "https://localhost/SAML2/SSO" + saml_slo_url: "https://localhost/SAML2/SLO" + saml_username_attribute: "uid" + saml_sp_entityid: "https://localhost" + saml_nameid_format: "urn:oasis:names:tc:SAML:2.0:nameid-format:entity" saml_sign_messages: true saml_sign_assertions: true saml_sign_authn_requests: true @@ -278,11 +259,11 @@ register: zbxauth_update - name: assert that authentication was NOT updated - assert: + ansible.builtin.assert: that: zbxauth_update.changed is sameas False - name: test - initialize all authentication setting - zabbix_authentication: + community.zabbix.zabbix_authentication: authentication_type: internal http_auth_enabled: false http_login_form: zabbix_login_form @@ -291,12 +272,12 @@ ldap_configured: false ldap_case_sensitive: true saml_auth_enabled: false - saml_idp_entityid: '' - saml_sso_url: '' - saml_slo_url: '' - saml_username_attribute: '' - saml_sp_entityid: '' - saml_nameid_format: '' + saml_idp_entityid: "" + saml_sso_url: "" + saml_slo_url: "" + saml_username_attribute: "" + saml_sp_entityid: "" + saml_nameid_format: "" saml_sign_messages: false saml_sign_assertions: false saml_sign_authn_requests: false @@ -311,43 +292,43 @@ register: zbxauth_update - name: assert that authentication was updated - assert: + ansible.builtin.assert: that: zbxauth_update.changed is sameas True - name: test - delete user directory - zabbix_user_directory: + community.zabbix.zabbix_user_directory: name: TestUserDirectory state: absent - when: zabbix_version is version('6.4', '>=') name: support Zabbix version (>=6.4) block: - - name: test - update ldap_configured without mandatory paramters - zabbix_authentication: + - name: test - update ldap_configured without mandatory paramters + community.zabbix.zabbix_authentication: ldap_auth_enabled: true ignore_errors: true register: zbxauth_update - name: assert that authentication was NOT updated - assert: + ansible.builtin.assert: that: - zbxauth_update.failed is sameas True - zbxauth_update.msg == "Please set ldap_userdirectory when you change a value of ldap_auth_enabled to true." - name: test - create LDAP user directory - zabbix_user_directory: + community.zabbix.zabbix_user_directory: name: TestUserDirectory idp_type: ldap - host: 'test.ca' + host: "test.ca" port: 389 - base_dn: 'ou=Users,dc=example,dc=org' - search_attribute: 'uid' + base_dn: "ou=Users,dc=example,dc=org" + search_attribute: "uid" provision_status: True group_name: cn group_basedn: ou=Group,dc=example,dc=org group_member: member user_ref_attr: uid - group_filter: '(member=uid=%{ref},ou=Users,dc=example,dc=com)' + group_filter: "(member=uid=%{ref},ou=Users,dc=example,dc=com)" user_username: first_name user_lastname: last_name provision_media: @@ -361,11 +342,11 @@ - Guests - name: test - update all authentication setting - zabbix_authentication: + community.zabbix.zabbix_authentication: authentication_type: internal http_auth_enabled: true http_login_form: zabbix_login_form - http_strip_domains: 'comp,any' + http_strip_domains: "comp,any" http_case_sensitive: true ldap_auth_enabled: true ldap_case_sensitive: true @@ -385,15 +366,15 @@ register: zbxauth_update - name: assert that authentication was updated - assert: + ansible.builtin.assert: that: zbxauth_update.changed is sameas True - name: test - update all authentication setting (again) - zabbix_authentication: + community.zabbix.zabbix_authentication: authentication_type: internal http_auth_enabled: true http_login_form: zabbix_login_form - http_strip_domains: 'comp,any' + http_strip_domains: "comp,any" http_case_sensitive: true ldap_auth_enabled: true ldap_case_sensitive: true @@ -413,11 +394,11 @@ register: zbxauth_update - name: assert that authentication was NOT updated - assert: + ansible.builtin.assert: that: zbxauth_update.changed is sameas False - name: test - initialize all authentication setting - zabbix_authentication: + community.zabbix.zabbix_authentication: authentication_type: internal http_auth_enabled: false http_login_form: zabbix_login_form @@ -435,5 +416,5 @@ register: zbxauth_update - name: assert that authentication was updated - assert: + ansible.builtin.assert: that: zbxauth_update.changed is sameas True diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_autoregister/tasks/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_autoregister/tasks/main.yml index 3dcf93dbe..797ad2c2c 100644 --- a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_autoregister/tasks/main.yml +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_autoregister/tasks/main.yml @@ -1,108 +1,87 @@ --- -- name: test - do not run tests with < Zabbix 4.0 - meta: end_play - when: zabbix_version is version('4.0', '<') - -- when: zabbix_version is version('4.4', '<') - name: Unsupport Zabbix version (<4.4) - block: - - name: test fail to update autoregistration - community.zabbix.zabbix_autoregister: - tls_accept: "tls_with_psk" - tls_psk_identity: 'PSK 001' - tls_psk: "11111595725ac58dd977beef14b97461a7c1045b9a1c923453302c5473193478" - register: zbxautoregister_update_result - ignore_errors: true - - - assert: - that: zbxautoregister_update_result.failed is sameas True - -- when: zabbix_version is version('4.4', '>=') - name: Support Zabbix version (>=4.4) - block: - - name: test update autoregistration with no parameter - community.zabbix.zabbix_autoregister: - register: zbxautoregister_update_result - ignore_errors: true - - - assert: - that: zbxautoregister_update_result.failed is sameas True - - - name: test update autoregistration with all parameters - community.zabbix.zabbix_autoregister: - tls_accept: - - unsecure - - tls_with_psk - tls_psk_identity: 'PSK 001' - tls_psk: "11111595725ac58dd977beef14b97461a7c1045b9a1c923453302c5473193478" - register: zbxautoregister_update_result - - - assert: - that: zbxautoregister_update_result.changed is sameas True - - - name: test update autoregistration with all parameters (again) - community.zabbix.zabbix_autoregister: - tls_accept: - - unsecure - - tls_with_psk - tls_psk_identity: 'PSK 001' - tls_psk: "11111595725ac58dd977beef14b97461a7c1045b9a1c923453302c5473193478" - register: zbxautoregister_update_result - - - assert: - that: zbxautoregister_update_result.changed is sameas True - - - name: test update autoregistration with only tls_accept - community.zabbix.zabbix_autoregister: - tls_accept: "tls_with_psk" - register: zbxautoregister_update_result - - - assert: - that: zbxautoregister_update_result.changed is sameas True - - - name: test update autoregistration with only tls_accept (again) - community.zabbix.zabbix_autoregister: - tls_accept: - - tls_with_psk - register: zbxautoregister_update_result - - - assert: - that: zbxautoregister_update_result.changed is sameas False - - - name: test update autoregistration with only tls_accept (unsecure) - community.zabbix.zabbix_autoregister: - tls_accept: - - unsecure - register: zbxautoregister_update_result - - - assert: - that: zbxautoregister_update_result.changed is sameas True - - - name: test fail to update autoregistration with only tls_accept (tls_with_psk) - community.zabbix.zabbix_autoregister: - tls_accept: "tls_with_psk" - register: zbxautoregister_update_result - ignore_errors: true - - - assert: - that: zbxautoregister_update_result.failed is sameas True - - - name: test fail to update autoregistration with only tls_accept and tls_psk_identity (tls_with_psk) - community.zabbix.zabbix_autoregister: - tls_accept: "tls_with_psk" - tls_psk_identity: 'PSK 001' - register: zbxautoregister_update_result - ignore_errors: true - - - assert: - that: zbxautoregister_update_result.failed is sameas True - - - name: test fail to update autoregistration with only tls_accept and tls_psk (tls_with_psk) - community.zabbix.zabbix_autoregister: - tls_accept: "tls_with_psk" - tls_psk: "11111595725ac58dd977beef14b97461a7c1045b9a1c923453302c5473193478" - register: zbxautoregister_update_result - ignore_errors: true - - - assert: - that: zbxautoregister_update_result.failed is sameas True +- name: test update autoregistration with no parameter + community.zabbix.zabbix_autoregister: + register: zbxautoregister_update_result + ignore_errors: true + +- ansible.builtin.assert: + that: zbxautoregister_update_result.failed is sameas True + +- name: test update autoregistration with all parameters + community.zabbix.zabbix_autoregister: + tls_accept: + - unsecure + - tls_with_psk + tls_psk_identity: "PSK 001" + tls_psk: "11111595725ac58dd977beef14b97461a7c1045b9a1c923453302c5473193478" + register: zbxautoregister_update_result + +- ansible.builtin.assert: + that: zbxautoregister_update_result.changed is sameas True + +- name: test update autoregistration with all parameters (again) + community.zabbix.zabbix_autoregister: + tls_accept: + - unsecure + - tls_with_psk + tls_psk_identity: "PSK 001" + tls_psk: "11111595725ac58dd977beef14b97461a7c1045b9a1c923453302c5473193478" + register: zbxautoregister_update_result + +- ansible.builtin.assert: + that: zbxautoregister_update_result.changed is sameas True + +- name: test update autoregistration with only tls_accept + community.zabbix.zabbix_autoregister: + tls_accept: "tls_with_psk" + register: zbxautoregister_update_result + +- ansible.builtin.assert: + that: zbxautoregister_update_result.changed is sameas True + +- name: test update autoregistration with only tls_accept (again) + community.zabbix.zabbix_autoregister: + tls_accept: + - tls_with_psk + register: zbxautoregister_update_result + +- ansible.builtin.assert: + that: zbxautoregister_update_result.changed is sameas False + +- name: test update autoregistration with only tls_accept (unsecure) + community.zabbix.zabbix_autoregister: + tls_accept: + - unsecure + register: zbxautoregister_update_result + +- ansible.builtin.assert: + that: zbxautoregister_update_result.changed is sameas True + +- name: test fail to update autoregistration with only tls_accept (tls_with_psk) + community.zabbix.zabbix_autoregister: + tls_accept: "tls_with_psk" + register: zbxautoregister_update_result + ignore_errors: true + +- ansible.builtin.assert: + that: zbxautoregister_update_result.failed is sameas True + +- name: test fail to update autoregistration with only tls_accept and tls_psk_identity (tls_with_psk) + community.zabbix.zabbix_autoregister: + tls_accept: "tls_with_psk" + tls_psk_identity: "PSK 001" + register: zbxautoregister_update_result + ignore_errors: true + +- ansible.builtin.assert: + that: zbxautoregister_update_result.failed is sameas True + +- name: test fail to update autoregistration with only tls_accept and tls_psk (tls_with_psk) + community.zabbix.zabbix_autoregister: + tls_accept: "tls_with_psk" + tls_psk: "11111595725ac58dd977beef14b97461a7c1045b9a1c923453302c5473193478" + register: zbxautoregister_update_result + ignore_errors: true + +- ansible.builtin.assert: + that: zbxautoregister_update_result.failed is sameas True diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_discovery_rule/tasks/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_discovery_rule/tasks/main.yml index 16062a52e..cbf13b391 100644 --- a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_discovery_rule/tasks/main.yml +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_discovery_rule/tasks/main.yml @@ -1,8 +1,4 @@ --- -- name: test - do not run tests for Zabbix 3.0 - meta: end_play - when: zabbix_version is version('3.0', '=') - - name: test - Zabbix discovery rule module_defaults: community.zabbix.zabbix_discovery_rule: @@ -11,270 +7,269 @@ iprange: 192.168.1.1-255 dchecks: - type: ICMP - delay: "{{ 3600 if zabbix_version is version('3.4', '<=') else omit }}" block: - - name: test - create new Zabbix discovery rule (checkmode) - zabbix_discovery_rule: - check_mode: true - register: drule_new_checkmode - - - name: assert that drule will be created (checkmode) - assert: - that: drule_new_checkmode is changed - - - name: test - create new Zabbix discovery rule - zabbix_discovery_rule: - register: drule_new - - - name: assert that drule was created - assert: - that: drule_new is changed - - - name: test - create same Zabbix discovery rule - zabbix_discovery_rule: - register: drule_exists - - - name: assert that nothing has been changed - assert: - that: not drule_exists is changed - - - name: test - update Zabbix discovery rule iprange (checkmode) - zabbix_discovery_rule: - iprange: - - 192.168.1.1-255 - - 10.0.0.1-255 - check_mode: true - register: drule_iprange_update_checkmode - - - name: assert that iprange will be changed - assert: - that: drule_iprange_update_checkmode is changed - - - name: test - update Zabbix discovery rule iprange - zabbix_discovery_rule: - iprange: - - 192.168.1.1-255 - - 10.0.0.1-255 - register: drule_iprange_update - - - name: assert that iprange has been changed - assert: - that: drule_iprange_update is changed - - - name: test - reset Zabbix discovery rule to default - zabbix_discovery_rule: - register: drule_reset - - - name: assert that iprange has been changed - assert: - that: drule_reset is changed - - - name: test - update Zabbix discovery rule status - zabbix_discovery_rule: - status: disabled - register: drule_status_update - - - name: assert that iprange has been changed - assert: - that: drule_status_update is changed - - - name: test - reset Zabbix discovery rule to default - zabbix_discovery_rule: - register: drule_reset - - - name: assert that iprange has been changed - assert: - that: drule_reset is changed - - - name: test - update Zabbix discovery rule dchecks - zabbix_discovery_rule: - dchecks: - - type: ICMP - - type: Zabbix - key: "system.hostname" - ports: "10050" - uniq: true - host_source: discovery - register: drule_dchecks_update - - - name: assert that dcheck has been changed - assert: - that: drule_dchecks_update is changed - - - name: test - update Zabbix discovery rule dchecks ssh - zabbix_discovery_rule: - dchecks: - - type: ICMP - - type: SSH - ports: "22" - register: drule_dchecks_ssh_update - - - name: assert that dcheck has been changed - assert: - that: drule_dchecks_ssh_update is changed - - - name: test - update Zabbix discovery rule dchecks ldap - zabbix_discovery_rule: - dchecks: - - type: ICMP - - type: SSH - ports: "22" - - type: LDAP - ports: "389" - register: drule_dchecks_ldap_update - - - name: assert that dcheck has been changed - assert: - that: drule_dchecks_ldap_update is changed - - - name: test - update Zabbix discovery rule dchecks smtp - zabbix_discovery_rule: - dchecks: - - type: ICMP - - type: SSH - ports: "22" - - type: LDAP - ports: "389" - - type: SMTP - ports: 25,465,587 - register: drule_dchecks_smtp_update - - - name: assert that dcheck has been changed - assert: - that: drule_dchecks_smtp_update is changed - - - name: test - update Zabbix discovery rule dchecks http - zabbix_discovery_rule: - dchecks: - - type: ICMP - - type: SSH - ports: "22" - - type: LDAP - ports: "389" - - type: SMTP - ports: 25,465,587 - - type: HTTP - ports: 80,8080 - register: drule_dchecks_http_update - - - name: assert that dcheck has been changed - assert: - that: drule_dchecks_http_update is changed - - - name: test - remove Zabbix discovery rule dchecks - zabbix_discovery_rule: - dchecks: - - type: ICMP - register: drule_dchecks_remove_update - - - name: assert that dcheck has been changed - assert: - that: drule_dchecks_remove_update is changed - - - name: test - update Zabbix discovery rule snmp dcheck - zabbix_discovery_rule: - dchecks: - - type: SNMPv2 - snmp_community: CUSTOMER@snmp-readonly - ports: "161" - key: iso.3.6.1.2.1.1.1.0 - uniq: false - host_source: discovery - name_source: discovery - register: drule_snmp_update - - - name: assert that snmp dcheck has been changed - assert: - that: drule_snmp_update is changed - - - name: test - update Zabbix discovery rule snmp3 dcheck - zabbix_discovery_rule: - dchecks: - - type: SNMPv3 - snmp_community: CUSTOMER@snmp3-readonly - ports: "161" - key: iso.3.6.1.2.1.1.1.0 - snmpv3_contextname: "ContextName" - snmpv3_securityname: "SecurityName" - snmpv3_securitylevel: authPriv - snmpv3_authprotocol: SHA - snmpv3_authpassphrase: "SeCrEt" - snmpv3_privprotocol: AES - snmpv3_privpassphrase: "TopSecret" - uniq: false - host_source: DNS - name_source: None - register: drule_snmp3_update - - - name: assert that snmp3 dcheck has been changed - assert: - that: drule_snmp3_update is changed - - - name: test - reset Zabbix discovery rule to default - zabbix_discovery_rule: - register: drule_reset - - - name: assert that iprange has been changed - assert: - that: drule_reset is changed - - - name: test - create new active Zabbix proxy server - zabbix_proxy: - proxy_name: ACME_proxy - status: active - state: present - register: zbxproxy_active - - - name: assert that proxy was created - assert: - that: zbxproxy_active is changed - - - name: test - update Zabbix discovery rule proxy - zabbix_discovery_rule: - proxy: ACME_proxy - register: drule_proxy_update - - - name: assert that proxy has been changed - assert: - that: drule_proxy_update is changed - - - name: test - update Zabbix discovery rule proxy (again) - zabbix_discovery_rule: - proxy: ACME_proxy - register: drule_proxy_update_again - - - name: assert that nothing has been changed - assert: - that: not drule_proxy_update_again is changed + - name: test - create new Zabbix discovery rule (checkmode) + community.zabbix.zabbix_discovery_rule: + check_mode: true + register: drule_new_checkmode + + - name: assert that drule will be created (checkmode) + ansible.builtin.assert: + that: drule_new_checkmode is changed + + - name: test - create new Zabbix discovery rule + community.zabbix.zabbix_discovery_rule: + register: drule_new + + - name: assert that drule was created + ansible.builtin.assert: + that: drule_new is changed + + - name: test - create same Zabbix discovery rule + community.zabbix.zabbix_discovery_rule: + register: drule_exists + + - name: assert that nothing has been changed + ansible.builtin.assert: + that: not drule_exists is changed + + - name: test - update Zabbix discovery rule iprange (checkmode) + community.zabbix.zabbix_discovery_rule: + iprange: + - 192.168.1.1-255 + - 10.0.0.1-255 + check_mode: true + register: drule_iprange_update_checkmode + + - name: assert that iprange will be changed + ansible.builtin.assert: + that: drule_iprange_update_checkmode is changed + + - name: test - update Zabbix discovery rule iprange + community.zabbix.zabbix_discovery_rule: + iprange: + - 192.168.1.1-255 + - 10.0.0.1-255 + register: drule_iprange_update + + - name: assert that iprange has been changed + ansible.builtin.assert: + that: drule_iprange_update is changed + + - name: test - reset Zabbix discovery rule to default + community.zabbix.zabbix_discovery_rule: + register: drule_reset + + - name: assert that iprange has been changed + ansible.builtin.assert: + that: drule_reset is changed + + - name: test - update Zabbix discovery rule status + community.zabbix.zabbix_discovery_rule: + status: disabled + register: drule_status_update + + - name: assert that iprange has been changed + ansible.builtin.assert: + that: drule_status_update is changed + + - name: test - reset Zabbix discovery rule to default + community.zabbix.zabbix_discovery_rule: + register: drule_reset + + - name: assert that iprange has been changed + ansible.builtin.assert: + that: drule_reset is changed + + - name: test - update Zabbix discovery rule dchecks + community.zabbix.zabbix_discovery_rule: + dchecks: + - type: ICMP + - type: Zabbix + key: "system.hostname" + ports: "10050" + uniq: true + host_source: discovery + register: drule_dchecks_update + + - name: assert that dcheck has been changed + ansible.builtin.assert: + that: drule_dchecks_update is changed + + - name: test - update Zabbix discovery rule dchecks ssh + community.zabbix.zabbix_discovery_rule: + dchecks: + - type: ICMP + - type: SSH + ports: "22" + register: drule_dchecks_ssh_update + + - name: assert that dcheck has been changed + ansible.builtin.assert: + that: drule_dchecks_ssh_update is changed + + - name: test - update Zabbix discovery rule dchecks ldap + community.zabbix.zabbix_discovery_rule: + dchecks: + - type: ICMP + - type: SSH + ports: "22" + - type: LDAP + ports: "389" + register: drule_dchecks_ldap_update + + - name: assert that dcheck has been changed + ansible.builtin.assert: + that: drule_dchecks_ldap_update is changed + + - name: test - update Zabbix discovery rule dchecks smtp + community.zabbix.zabbix_discovery_rule: + dchecks: + - type: ICMP + - type: SSH + ports: "22" + - type: LDAP + ports: "389" + - type: SMTP + ports: 25,465,587 + register: drule_dchecks_smtp_update + + - name: assert that dcheck has been changed + ansible.builtin.assert: + that: drule_dchecks_smtp_update is changed + + - name: test - update Zabbix discovery rule dchecks http + community.zabbix.zabbix_discovery_rule: + dchecks: + - type: ICMP + - type: SSH + ports: "22" + - type: LDAP + ports: "389" + - type: SMTP + ports: 25,465,587 + - type: HTTP + ports: 80,8080 + register: drule_dchecks_http_update + + - name: assert that dcheck has been changed + ansible.builtin.assert: + that: drule_dchecks_http_update is changed + + - name: test - remove Zabbix discovery rule dchecks + community.zabbix.zabbix_discovery_rule: + dchecks: + - type: ICMP + register: drule_dchecks_remove_update + + - name: assert that dcheck has been changed + ansible.builtin.assert: + that: drule_dchecks_remove_update is changed + + - name: test - update Zabbix discovery rule snmp dcheck + community.zabbix.zabbix_discovery_rule: + dchecks: + - type: SNMPv2 + snmp_community: CUSTOMER@snmp-readonly + ports: "161" + key: iso.3.6.1.2.1.1.1.0 + uniq: false + host_source: discovery + name_source: discovery + register: drule_snmp_update + + - name: assert that snmp dcheck has been changed + ansible.builtin.assert: + that: drule_snmp_update is changed + + - name: test - update Zabbix discovery rule snmp3 dcheck + community.zabbix.zabbix_discovery_rule: + dchecks: + - type: SNMPv3 + snmp_community: CUSTOMER@snmp3-readonly + ports: "161" + key: iso.3.6.1.2.1.1.1.0 + snmpv3_contextname: "ContextName" + snmpv3_securityname: "SecurityName" + snmpv3_securitylevel: authPriv + snmpv3_authprotocol: SHA + snmpv3_authpassphrase: "SeCrEt" + snmpv3_privprotocol: AES + snmpv3_privpassphrase: "TopSecret" + uniq: false + host_source: DNS + name_source: None + register: drule_snmp3_update + + - name: assert that snmp3 dcheck has been changed + ansible.builtin.assert: + that: drule_snmp3_update is changed + + - name: test - reset Zabbix discovery rule to default + community.zabbix.zabbix_discovery_rule: + register: drule_reset + + - name: assert that iprange has been changed + ansible.builtin.assert: + that: drule_reset is changed + + - name: test - create new active Zabbix proxy server + community.zabbix.zabbix_proxy: + proxy_name: ACME_proxy + status: active + state: present + register: zbxproxy_active + + - name: assert that proxy was created + ansible.builtin.assert: + that: zbxproxy_active is changed + + - name: test - update Zabbix discovery rule proxy + community.zabbix.zabbix_discovery_rule: + proxy: ACME_proxy + register: drule_proxy_update + + - name: assert that proxy has been changed + ansible.builtin.assert: + that: drule_proxy_update is changed + + - name: test - update Zabbix discovery rule proxy (again) + community.zabbix.zabbix_discovery_rule: + proxy: ACME_proxy + register: drule_proxy_update_again + + - name: assert that nothing has been changed + ansible.builtin.assert: + that: not drule_proxy_update_again is changed - name: test - delete Zabbix discovery rule - zabbix_discovery_rule: + community.zabbix.zabbix_discovery_rule: name: ACME state: absent register: drule_delete - name: assert that proxy has been deleted - assert: + ansible.builtin.assert: that: drule_delete is changed - name: test - delete Zabbix discovery rule (again) - zabbix_discovery_rule: + community.zabbix.zabbix_discovery_rule: name: ACME state: absent register: drule_delete_again - name: assert that nothing has been changed - assert: + ansible.builtin.assert: that: not drule_delete_again is changed # Cleanup - name: delete active Zabbix proxy server - zabbix_proxy: + community.zabbix.zabbix_proxy: proxy_name: ACME_proxy state: absent register: zbxproxy_delete - name: assert that proxy has been deleted - assert: + ansible.builtin.assert: that: zbxproxy_delete is changed diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_globalmacro/tasks/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_globalmacro/tasks/main.yml index ce49f0f86..bc15fec2c 100644 --- a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_globalmacro/tasks/main.yml +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_globalmacro/tasks/main.yml @@ -1,6 +1,6 @@ --- - name: test - attempt to create new global macro - zabbix_globalmacro: + community.zabbix.zabbix_globalmacro: macro_name: zbxgmacro_test01 macro_value: 123 macro_type: text @@ -8,11 +8,11 @@ register: zbxgmacro_new - name: assert that macro was created - assert: + ansible.builtin.assert: that: zbxgmacro_new is changed - name: test - attempt to create same global macro - zabbix_globalmacro: + community.zabbix.zabbix_globalmacro: macro_name: zbxgmacro_test01 macro_value: 123 macro_type: text @@ -20,11 +20,11 @@ register: zbxgmacro_existing - name: assert that nothing has been changed - assert: + ansible.builtin.assert: that: not zbxgmacro_existing is changed - name: test - attempt to create same global macro in zabbix native format - zabbix_globalmacro: + community.zabbix.zabbix_globalmacro: macro_name: "{$zbxgmacro_test01}" macro_value: 123 macro_type: text @@ -32,22 +32,22 @@ register: zbxgmacro_existing_native - name: assert that nothing has been changed - assert: + ansible.builtin.assert: that: not zbxgmacro_existing_native is changed - name: test - attempt to create new global macro in zabbix native format - zabbix_globalmacro: + community.zabbix.zabbix_globalmacro: macro_name: "{$ZBXGMACRO_TEST02}" macro_value: abcd macro_type: text register: zbxgmacro_new_native - name: assert that nothing macro was created - assert: + ansible.builtin.assert: that: zbxgmacro_new_native is changed - name: test - attempt to update global macro with string value while force=no - zabbix_globalmacro: + community.zabbix.zabbix_globalmacro: macro_name: zbxgmacro_test01 macro_value: abc macro_type: text @@ -55,44 +55,44 @@ register: zbxgmacro_update_noforce - name: assert that nothing has been changed - assert: + ansible.builtin.assert: that: not zbxgmacro_update_noforce is changed - name: test - attempt to update global macro with string value - zabbix_globalmacro: + community.zabbix.zabbix_globalmacro: macro_name: zbxgmacro_test01 macro_value: abc macro_type: text register: zbxgmacro_update - name: assert that global macro was updated - assert: + ansible.builtin.assert: that: zbxgmacro_update is changed - name: test - attempt to create global macro with context - zabbix_globalmacro: + community.zabbix.zabbix_globalmacro: macro_name: low_space_limit:/home macro_value: 10 macro_type: text register: zbxgmacro_context_new - name: assert that macro was created - assert: + ansible.builtin.assert: that: zbxgmacro_context_new is changed - name: test - attempt to create same global macro with context and verify that it was converted to uppercase - zabbix_globalmacro: + community.zabbix.zabbix_globalmacro: macro_name: LOW_SPACE_LIMIT:/home macro_value: 10 macro_type: text register: zbxgmacro_context_existing - name: assert that nothing has been changed - assert: + ansible.builtin.assert: that: not zbxgmacro_context_existing is changed - name: test - attempt to delete all global macros - zabbix_globalmacro: + community.zabbix.zabbix_globalmacro: macro_name: "{{ item }}" state: absent loop: @@ -102,71 +102,66 @@ register: zbxgmacro_delete_existing - name: assert that all macros have been deleted - assert: + ansible.builtin.assert: that: item.changed is sameas True loop: "{{ zbxgmacro_delete_existing.results }}" - name: test - attempt to delete non-existing global macro - zabbix_globalmacro: + community.zabbix.zabbix_globalmacro: macro_name: zbxgmacro_test01 state: absent register: zbxgmacro_delete_missing - name: assert that nothing has been changed - assert: + ansible.builtin.assert: that: not zbxgmacro_delete_missing is changed - name: test - attempt to create secret global macro - zabbix_globalmacro: + community.zabbix.zabbix_globalmacro: macro_name: zbxgmacro_test_secret macro_value: 123 macro_type: secret macro_description: Global Macro description register: zbxgmacro_secret -- assert: +- ansible.builtin.assert: that: zbxgmacro_secret.changed is sameas True - name: test - attempt to create same global macro - zabbix_globalmacro: + community.zabbix.zabbix_globalmacro: macro_name: zbxgmacro_test_secret macro_value: 123 macro_type: secret macro_description: Global Macro description register: zbxgmacro_secret -- assert: +- ansible.builtin.assert: that: zbxgmacro_secret.changed is sameas True - when: zabbix_version is version('5.0', '>=') - -- assert: - that: zbxgmacro_secret.changed is sameas False - when: zabbix_version is version('5.0', '<') - name: test - attempt to create vault global macro - zabbix_globalmacro: + community.zabbix.zabbix_globalmacro: macro_name: zbxgmacro_test_vault macro_value: path/to/vault:zabbix macro_type: vault macro_description: Global Macro description register: zbxgmacro_vault -- assert: +- ansible.builtin.assert: that: zbxgmacro_vault.changed is sameas True - name: test - attempt to create same global macro - zabbix_globalmacro: + community.zabbix.zabbix_globalmacro: macro_name: zbxgmacro_test_vault macro_value: path/to/vault:zabbix macro_type: vault macro_description: Global Macro description register: zbxgmacro_vault -- assert: +- ansible.builtin.assert: that: zbxgmacro_vault.changed is sameas False - name: delete all global macros - zabbix_globalmacro: + community.zabbix.zabbix_globalmacro: macro_name: "{{ item }}" state: absent loop: diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group/tasks/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group/tasks/main.yml index 0f099d7c1..b45711a25 100644 --- a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group/tasks/main.yml +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group/tasks/main.yml @@ -1,17 +1,17 @@ --- - name: test - create new Zabbix group - zabbix_group: + community.zabbix.zabbix_group: host_groups: - zbxgrp_example_group01 state: present register: zbxgrp_new - name: assert that group was created - assert: + ansible.builtin.assert: that: zbxgrp_new is changed - name: test - create simple zabbix host to assign to group - zabbix_host: + community.zabbix.zabbix_host: host_name: zbxgrp_example_host01 host_groups: - zbxgrp_example_group01 @@ -23,33 +23,33 @@ register: zbxgrp_host_assignement - name: assert that host was assigned successfully - assert: + ansible.builtin.assert: that: zbxgrp_host_assignement is changed - name: test - create same Zabbix group once again - zabbix_group: + community.zabbix.zabbix_group: host_groups: - zbxgrp_example_group01 state: present register: zbxgrp_existing - name: assert that nothing has been changed - assert: + ansible.builtin.assert: that: not zbxgrp_existing is changed - name: test - attempt to create new Zabbix group matching name of default Zabbix group - zabbix_group: + community.zabbix.zabbix_group: host_groups: - Linux servers state: present register: zbxgrp_default_existing - name: assert that nothing has been changed - assert: + ansible.builtin.assert: that: not zbxgrp_default_existing is changed - name: test - attempt to delete host group while its only group host has assigned - zabbix_group: + community.zabbix.zabbix_group: host_groups: - zbxgrp_example_group01 state: absent @@ -57,32 +57,32 @@ ignore_errors: true - name: assert that group deletion failed - assert: + ansible.builtin.assert: that: zbxgrp_existing_delete_failed is failed - name: delete helper zabbix host - zabbix_host: + community.zabbix.zabbix_host: host_name: zbxgrp_example_host01 state: absent - name: test - attempt to delete previously created zabbix group - zabbix_group: + community.zabbix.zabbix_group: host_groups: - zbxgrp_example_group01 state: absent register: zbxgrp_existing_delete - name: assert that group was deleted - assert: + ansible.builtin.assert: that: zbxgrp_existing_delete is changed - name: test - attempt to delete non-existing zabbix group - zabbix_group: + community.zabbix.zabbix_group: host_groups: - zbxgrp_example_group01 state: absent register: zbxgrp_missing_delete - name: assert that nothing has been changed - assert: + ansible.builtin.assert: that: not zbxgrp_missing_delete is changed diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group_events_info/files/trigger_testing.json b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group_events_info/files/trigger_testing.json new file mode 100644 index 000000000..a642483f4 --- /dev/null +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group_events_info/files/trigger_testing.json @@ -0,0 +1,48 @@ +{ + "zabbix_export": { + "version": "6.0", + "date": "2023-09-05T13:58:23Z", + "groups": [ + { + "uuid": "6932cc6c283949ee8d4c316e2f30af5f", + "name": "Templates" + } + ], + "templates": [ + { + "uuid": "641c10c5445245edb59050c3518e76a0", + "template": "Trigger testing", + "name": "Trigger testing", + "groups": [ + { + "name": "Templates" + } + ], + "items": [ + { + "uuid": "0dce402f6f0c44cfb7796c1ea6c4bb86", + "name": "Test Item", + "type": "CALCULATED", + "key": "test", + "delay": "10s", + "params": "1", + "triggers": [ + { + "uuid": "11b2645a369946dcaa00b6edc578089f", + "expression": "last(/Trigger testing/test)=0", + "name": "Ok Trigger", + "priority": "AVERAGE" + }, + { + "uuid": "f17f4b4f7fe444dfb856bc9d6366d0fe", + "expression": "last(/Trigger testing/test)=1", + "name": "Problem Trigger", + "priority": "AVERAGE" + } + ] + } + ] + } + ] + } +} diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group_events_info/meta/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group_events_info/meta/main.yml new file mode 100644 index 000000000..acdb704c8 --- /dev/null +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group_events_info/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - setup_zabbix diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group_events_info/tasks/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group_events_info/tasks/main.yml new file mode 100644 index 000000000..601f5421f --- /dev/null +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group_events_info/tasks/main.yml @@ -0,0 +1,58 @@ +--- +- name: Import trigger test template + zabbix_template: + template_json: "{{ lookup('file', 'trigger_testing.json') }}" + state: present + +- name: Create host group + zabbix_group: + state: present + host_groups: + - Example group + +- name: Create new host with template + zabbix_host: + host_name: Example host + link_templates: + - Trigger testing + host_groups: + - Example group + +- name: Wait a minute to ensure triggers are firing + ansible.builtin.wait_for: + timeout: 60 + +- name: Get hostgroup events + zabbix_group_events_info: + hostgroup_name: Example group + trigger_severity: not_classified + register: hostgroup_events_results + +- name: Assert that trigger results are as expected + ansible.builtin.assert: + that: + - hostgroup_events_results.triggers_ok[0].description == "Ok Trigger" + - hostgroup_events_results.triggers_ok[0].value == "0" + - hostgroup_events_results.triggers_ok[0].status == "0" + # TODO: Need to figure out why this periodically fails for no reason. False Alarm + # - hostgroup_events_results.triggers_problem[0].description == "Problem Trigger" + # - hostgroup_events_results.triggers_problem[0].value == "1" + # - hostgroup_events_results.triggers_problem[0].status == "0" + # - hostgroup_events_results.triggers_problem[0].last_event.acknowledged == "0" + # - hostgroup_events_results.triggers_problem[0].last_event.value == "1" + +- name: Clean up host + zabbix_host: + host_name: Example host + state: absent + +- name: Clean up host group + zabbix_group: + host_groups: + - Example group + state: absent + +- name: Clean up template + zabbix_template: + template_name: "Trigger testing" + state: absent diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group_info/tasks/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group_info/tasks/main.yml index 624679603..51c03af3b 100644 --- a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group_info/tasks/main.yml +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group_info/tasks/main.yml @@ -1,6 +1,6 @@ --- - name: test - create new Zabbix group - zabbix_group: + community.zabbix.zabbix_group: host_groups: - zbxgrp_example_group01 - zbxgrp_example_group02 @@ -8,7 +8,7 @@ register: zbxgrp_new - name: assert that group was created - assert: + ansible.builtin.assert: that: zbxgrp_new is changed - name: test - get one hostgroup info @@ -18,7 +18,7 @@ register: get_hostgorup_info_result - name: assert that one group was get - assert: + ansible.builtin.assert: that: - get_hostgorup_info_result.host_groups | length == 1 - get_hostgorup_info_result.host_groups.0.name == 'zbxgrp_example_group01' @@ -31,14 +31,14 @@ register: get_hostgorup_info_result - name: assert that two group was get - assert: + ansible.builtin.assert: that: - get_hostgorup_info_result.host_groups | length == 2 - get_hostgorup_info_result.host_groups.0.name == 'zbxgrp_example_group01' - get_hostgorup_info_result.host_groups.1.name == 'zbxgrp_example_group02' - name: test - delete Zabbix group - zabbix_group: + community.zabbix.zabbix_group: host_groups: - zbxgrp_example_group01 - zbxgrp_example_group02 @@ -46,5 +46,5 @@ register: delete_zbxgrp - name: assert that group was deleted - assert: + ansible.builtin.assert: that: delete_zbxgrp is changed diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/main.yml index 20755061f..c4675797f 100644 --- a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/main.yml +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/main.yml @@ -12,8 +12,12 @@ # tear down stuff set up earlier - include_tasks: zabbix_host_teardown.yml always: - - name: "cleanup if tests failed" - zabbix_host: - host_name: ExampleHost - state: absent - ignore_errors: true + - name: "cleanup if tests failed" + community.zabbix.zabbix_host: + host_name: "{{ item }}" + state: absent + ignore_errors: true + with_items: + - ExampleHost + - ExampleHost1 + - ExampleHost2 diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_doc.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_doc.yml index 4415e2ca1..c84050dcf 100644 --- a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_doc.yml +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_doc.yml @@ -2,7 +2,7 @@ # These two tests are close to documentation example - name: Create a new host or update an existing host's info - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost1 visible_name: ExampleName description: My ExampleHost Description @@ -10,8 +10,8 @@ - Linux servers - Zabbix servers link_templates: - - "{{ 'IMAP Service' if zabbix_version | float >= 5.2 else 'Template App IMAP Service' }}" - - "{{ 'NTP Service' if zabbix_version | float >= 5.2 else 'Template App NTP Service' }}" + - "IMAP Service" + - "NTP Service" status: enabled state: present inventory_mode: manual @@ -41,11 +41,11 @@ dns: "" port: "12345" macros: - - macro: '{$EXAMPLEMACRO}' + - macro: "{$EXAMPLEMACRO}" value: ExampleMacroValue - macro: EXAMPLEMACRO2 value: ExampleMacroValue2 - description: Example desc that work only with Zabbix 4.4 and higher + description: Example desc tags: - tag: ExampleHostsTag - tag: ExampleHostsTag2 @@ -53,7 +53,7 @@ register: zabbix_host1 - name: Update an existing host's tls settings - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost2 visible_name: ExampleName2 interfaces: @@ -71,7 +71,7 @@ register: zabbix_host2 - name: expect both to succeed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - "zabbix_host2 is changed" diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_setup.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_setup.yml index 15e3e2fa5..924119467 100644 --- a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_setup.yml +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_setup.yml @@ -2,14 +2,12 @@ # set up a zabbix proxy to test zabbix_host with - name: Create a new proxy - zabbix_proxy: + community.zabbix.zabbix_proxy: proxy_name: ExampleProxy description: ExampleProxy status: active state: present interface: - type: 0 - main: 1 useip: 1 ip: 10.5.6.7 dns: "" @@ -17,7 +15,7 @@ register: zabbix_proxy - name: Create Templates - zabbix_template: + community.zabbix.zabbix_template: template_name: "{{ item }}" template_groups: - Templates diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_teardown.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_teardown.yml index 7eedcf12d..1617f449f 100644 --- a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_teardown.yml +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_teardown.yml @@ -2,12 +2,12 @@ # remove zabbix_proxy (hopefully) created earlier - name: remove proxy - zabbix_proxy: + community.zabbix.zabbix_proxy: proxy_name: ExampleProxy state: absent - name: remove Templates - zabbix_template: + community.zabbix.zabbix_template: template_name: "{{ item }}" state: absent with_items: diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_tests.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_tests.yml index d72dbe318..a4829a051 100644 --- a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_tests.yml +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_tests.yml @@ -1,7 +1,6 @@ --- - name: "test: create host with many options set" - zabbix_host: - timeout: 30 # slower with py2.7 + community.zabbix.zabbix_host: host_name: ExampleHost visible_name: ExampleName description: My ExampleHost Description @@ -9,8 +8,8 @@ - Linux servers - Zabbix servers link_templates: - - "{{ 'IMAP Service' if zabbix_version | float >= 5.2 else 'Template App IMAP Service' }}" - - "{{ 'NTP Service' if zabbix_version | float >= 5.2 else 'Template App NTP Service' }}" + - "IMAP Service" + - "NTP Service" status: enabled state: present inventory_mode: manual @@ -45,7 +44,7 @@ macros: - macro: MACRO1 value: test1 - - macro: '{$MACRO2}' + - macro: "{$MACRO2}" value: test2 tags: - tag: Tag1 @@ -54,13 +53,12 @@ register: zabbix_host1 - name: expect to succeed and that things changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: try to create the same host with the same settings" - zabbix_host: - timeout: 30 # slower with py2.7 + community.zabbix.zabbix_host: host_name: ExampleHost visible_name: ExampleName description: My ExampleHost Description @@ -68,8 +66,8 @@ - Linux servers - Zabbix servers link_templates: - - "{{ 'IMAP Service' if zabbix_version | float >= 5.2 else 'Template App IMAP Service' }}" - - "{{ 'NTP Service' if zabbix_version | float >= 5.2 else 'Template App NTP Service' }}" + - "IMAP Service" + - "NTP Service" status: enabled state: present inventory_mode: manual @@ -104,7 +102,7 @@ macros: - macro: MACRO1 value: test1 - - macro: '{$MACRO2}' + - macro: "{$MACRO2}" value: test2 tags: - tag: Tag1 @@ -113,14 +111,13 @@ register: zabbix_host1 - name: updating with same values should be idempotent - assert: + ansible.builtin.assert: that: - "not zabbix_host1 is changed" - name: "test: try to create the same host with the same settings and force false" - zabbix_host: + community.zabbix.zabbix_host: force: false - timeout: 30 # slower with py2.7 host_name: ExampleHost visible_name: ExampleName description: My ExampleHost Description @@ -128,8 +125,8 @@ - Linux servers - Zabbix servers link_templates: - - "{{ 'IMAP Service' if zabbix_version | float >= 5.2 else 'Template App IMAP Service' }}" - - "{{ 'NTP Service' if zabbix_version | float >= 5.2 else 'Template App NTP Service' }}" + - "IMAP Service" + - "NTP Service" status: enabled state: present inventory_mode: manual @@ -164,14 +161,13 @@ register: zabbix_host1 - name: updating with same values and force false should be idempotent - assert: + ansible.builtin.assert: that: - "not zabbix_host1 is changed" - name: "test: try to create the same host changing one parameter in the inventory with force false" - zabbix_host: + community.zabbix.zabbix_host: force: false - timeout: 30 # slower with py2.7 host_name: ExampleHost visible_name: ExampleName description: My ExampleHost Description @@ -179,8 +175,8 @@ - Linux servers - Zabbix servers link_templates: - - "{{ 'IMAP Service' if zabbix_version | float >= 5.2 else 'Template App IMAP Service' }}" - - "{{ 'NTP Service' if zabbix_version | float >= 5.2 else 'Template App NTP Service' }}" + - "IMAP Service" + - "NTP Service" status: enabled state: present inventory_mode: manual @@ -215,56 +211,56 @@ register: zabbix_host1 - name: changing the value of an already defined inventory should work and mark task as changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: change visible_name" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost visible_name: "ExampleName Changed" register: zabbix_host1 - name: expect to succeed and that things changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: change visible_name (again)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost visible_name: "ExampleName Changed" register: zabbix_host1 - name: updating with same values should be idempotent - assert: + ansible.builtin.assert: that: - "not zabbix_host1 is changed" - name: "test: change description" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost description: "My ExampleHost Description Changed" register: zabbix_host1 - name: expect to succeed and that things changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: change description (again)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost description: "My ExampleHost Description Changed" register: zabbix_host1 - name: updating with same values should be idempotent - assert: + ansible.builtin.assert: that: - "not zabbix_host1 is changed" - name: "test: change host groups (adding one group)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost host_groups: - Linux servers @@ -273,12 +269,12 @@ register: zabbix_host1 - name: expect to succeed and that things changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: change host groups (remove one group)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost host_groups: - Linux servers @@ -286,12 +282,12 @@ register: zabbix_host1 - name: expect to succeed and that things changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: change host groups (add one group using force=no)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost host_groups: - Virtual machines @@ -299,13 +295,12 @@ register: zabbix_host1 - name: expect to succeed and that things changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - - name: "test: change host groups (check whether we are at three groups)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost host_groups: - Linux servers @@ -314,12 +309,12 @@ register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "not zabbix_host1 is changed" - name: "test: change host groups (attempt to remove all host groups)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost # list with empty value, expected: host_groups: @@ -328,136 +323,133 @@ ignore_errors: true - name: expect to fail - assert: + ansible.builtin.assert: that: - "zabbix_host1 is failed" - name: "test: change host linked templates (same as before)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost link_templates: - - "{{ 'IMAP Service' if zabbix_version | float >= 5.2 else 'Template App IMAP Service' }}" - - "{{ 'NTP Service' if zabbix_version | float >= 5.2 else 'Template App NTP Service' }}" + - "IMAP Service" + - "NTP Service" register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "not zabbix_host1 is changed" - name: "test: change host linked templates (add one template)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost link_templates: - - "{{ 'IMAP Service' if zabbix_version | float >= 5.2 else 'Template App IMAP Service' }}" - - "{{ 'NTP Service' if zabbix_version | float >= 5.2 else 'Template App NTP Service' }}" - - "{{ 'HTTP Service' if zabbix_version | float >= 5.2 else 'Template App HTTP Service' }}" + - "IMAP Service" + - "NTP Service" + - "HTTP Service" register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: change host linked templates (add one template, using force=no)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost link_templates: - - "{{ 'LDAP Service' if zabbix_version | float >= 5.2 else 'Template App LDAP Service' }}" + - "LDAP Service" force: false register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: change host linked templates (make sure we are at 4 templates)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost link_templates: - - "{{ 'IMAP Service' if zabbix_version | float >= 5.2 else 'Template App IMAP Service' }}" - - "{{ 'NTP Service' if zabbix_version | float >= 5.2 else 'Template App NTP Service' }}" - - "{{ 'HTTP Service' if zabbix_version | float >= 5.2 else 'Template App HTTP Service' }}" - - "{{ 'LDAP Service' if zabbix_version | float >= 5.2 else 'Template App LDAP Service' }}" + - "IMAP Service" + - "NTP Service" + - "HTTP Service" + - "LDAP Service" register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "not zabbix_host1 is changed" - name: "test: change host linked templates (remove all templates)" - zabbix_host: - timeout: 60 # slower with py2.7 + community.zabbix.zabbix_host: host_name: ExampleHost - link_templates: - - + link_templates: [] register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: change host linked templates (check we have no templates left)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost - link_templates: - - + link_templates: [] register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "not zabbix_host1 is changed" - name: "test: change host status" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost status: disabled register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: change host status (again)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost status: disabled register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "not zabbix_host1 is changed" - name: "test: change host inventory mode" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost inventory_mode: automatic register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: change host inventory mode" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost inventory_mode: automatic register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "not zabbix_host1 is changed" - name: "test: change host inventory data (one field)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost inventory_zabbix: tag: test-tag-two @@ -470,12 +462,12 @@ register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: change host inventory data (again)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost inventory_zabbix: tag: test-tag-two @@ -488,45 +480,45 @@ register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "not zabbix_host1 is changed" - name: "test: remove host proxy" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost - proxy: '' + proxy: "" register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: add host proxy" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost proxy: ExampleProxy register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: add host proxy (again)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost proxy: ExampleProxy register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "not zabbix_host1 is changed" - name: "test: change tls certificate settings" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost tls_connect: 4 tls_accept: 4 @@ -535,12 +527,12 @@ register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: change tls certificate settings (again)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost tls_connect: 4 tls_accept: 4 @@ -549,12 +541,12 @@ register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "not zabbix_host1 is changed" - name: "test: change tls psk (write-only) settings" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost tls_connect: 2 tls_accept: 2 @@ -563,11 +555,11 @@ register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: zabbix_host1 is changed - name: "test: change tls psk (write-only) settings (again)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost tls_connect: 2 tls_accept: 2 @@ -576,17 +568,11 @@ register: zabbix_host1 - name: expect to succeed and that things have changed (tls_psk makes module non-idempotent) - assert: + ansible.builtin.assert: that: zabbix_host1 is changed - when: zabbix_version is version('5.4', '>=') - -- name: expect to succeed and that things have not changed - assert: - that: zabbix_host1 is not changed - when: zabbix_version is version('5.4', '<') - name: "test: change interface settings (remove one)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost interfaces: - type: 1 @@ -598,12 +584,12 @@ register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: change interface settings (again)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost interfaces: - type: 1 @@ -615,12 +601,12 @@ register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "not zabbix_host1 is changed" - name: "test: change interface settings (add one interface using force=no)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost interfaces: - type: 4 @@ -633,12 +619,12 @@ register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: change interface settings (verify that we are at two interfaces)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost interfaces: - type: 1 @@ -656,12 +642,12 @@ register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "not zabbix_host1 is changed" - name: "test: configure interface to useip=1 but provide no ip" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost interfaces: - type: 1 @@ -677,12 +663,12 @@ ignore_errors: true - name: expect to fail - assert: + ansible.builtin.assert: that: - "zabbix_host1 is failed" - name: "test: configure interface to useip=0 but provide no dns" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost interfaces: - type: 1 @@ -699,217 +685,214 @@ ignore_errors: true - name: expect to fail - assert: + ansible.builtin.assert: + that: + - "zabbix_host1 is failed" + +- name: "test: configure SNMPv2 interface without details (fail)" + community.zabbix.zabbix_host: + host_name: ExampleHost + interfaces: + - type: 1 + main: 1 + useip: 1 + ip: 10.1.1.1 + port: "10050" + - type: 2 + main: 1 + useip: 1 + ip: 10.1.1.1 + port: "161" + register: zabbix_host1 + ignore_errors: true + +- name: expect to fail + ansible.builtin.assert: that: - "zabbix_host1 is failed" -- when: zabbix_version is version("5.0", ">=") - block: - - name: "test: configure SNMPv2 interface without details (fail)" - zabbix_host: - host_name: ExampleHost - interfaces: - - type: 1 - main: 1 - useip: 1 - ip: 10.1.1.1 - port: "10050" - - type: 2 - main: 1 - useip: 1 - ip: 10.1.1.1 - port: "161" - register: zabbix_host1 - ignore_errors: true - - - name: expect to fail - assert: - that: - - "zabbix_host1 is failed" - - - name: "test: configure details for SNMPv2 interface" - zabbix_host: - host_name: ExampleHost - interfaces: - - type: 1 - main: 1 - useip: 1 - ip: 10.1.1.1 - port: "10050" - - type: 2 - main: 1 - useip: 1 - ip: 10.1.1.1 - port: "161" - details: - version: 2 - community: Community String - register: zabbix_host1 - - - name: expect to succeed and that things have changed - assert: - that: - - "zabbix_host1 is changed" - - - name: "test: configure details for SNMPv2 interface (again)" - zabbix_host: - host_name: ExampleHost - interfaces: - - type: 1 - main: 1 - useip: 1 - ip: 10.1.1.1 - port: "10050" - - type: 2 - main: 1 - useip: 1 - ip: 10.1.1.1 - port: "161" - details: - version: 2 - community: Community String - register: zabbix_host1 - - - name: expect to succeed and that things have not changed - assert: - that: - - "zabbix_host1 is not changed" - - - name: "test: configure SNMPv2 interface with the same options and force=False " - zabbix_host: - host_name: ExampleHost - force: False - interfaces: - - type: 1 - main: 1 - useip: 1 - ip: 10.1.1.1 - port: "10050" - - type: 2 - main: 1 - useip: 1 - ip: 10.1.1.1 - port: "161" - details: - version: 2 - community: Community String - register: zabbix_host1 - - - name: expect to succeed and that things have not changed - assert: - that: - - "zabbix_host1 is not changed" - - - name: "test: update details for SNMPv2 interface with bulk sub option" - zabbix_host: - host_name: ExampleHost - interfaces: - - type: 1 - main: 1 - useip: 1 - ip: 10.1.1.1 - port: "10050" - - type: 2 - main: 1 - useip: 1 - ip: 10.1.1.1 - port: "161" - details: - version: 2 - community: Community String - bulk: 0 - register: zabbix_host1 - - - name: expect to succeed and that things have changed - assert: - that: - - "zabbix_host1 is changed" - - - name: "test: configure details for SNMPv3 interface" - zabbix_host: - host_name: ExampleHost - interfaces: - - type: 1 - main: 1 - useip: 1 - ip: 10.1.1.1 - port: "10050" - - type: 2 - main: 1 - useip: 1 - ip: 10.1.1.1 - port: "161" - details: - version: 3 - contextname: snmp_context - securityname: SNMP3 sec name - securitylevel: 0 - register: zabbix_host1 - - - name: expect to succeed and that things have changed - assert: - that: - - "zabbix_host1 is changed" - - - name: "test: configure details for SNMPv3 interface (again)" - zabbix_host: - host_name: ExampleHost - interfaces: - - type: 1 - main: 1 - useip: 1 - ip: 10.1.1.1 - port: "10050" - - type: 2 - main: 1 - useip: 1 - ip: 10.1.1.1 - port: "161" - details: - version: 3 - contextname: snmp_context - securityname: SNMP3 sec name - securitylevel: 0 - register: zabbix_host1 - - - name: expect to succeed and that things have not changed - assert: - that: - - "zabbix_host1 is not changed" - - - name: "test: update details for SNMPv3 interface" - zabbix_host: - host_name: ExampleHost - interfaces: - - type: 1 - main: 1 - useip: 1 - ip: 10.1.1.1 - port: "10050" - - type: 2 - main: 1 - useip: 1 - ip: 10.1.1.1 - port: "161" - details: - version: 3 - contextname: snmp_context - securityname: SNMP3 sec name - securitylevel: 2 - authprotocol: "{{ 2 if zabbix_version | float >= 5.4 else 0 }}" - authpassphrase: secret_auth_passphrase - privprotocol: "{{ 2 if zabbix_version | float >= 5.4 else 0 }}" - privpassphrase: secret_priv_passphrase - register: zabbix_host1 - - - name: expect to succeed and that things have changed - assert: - that: - - "zabbix_host1 is changed" - -# https://github.com/ansible-collections/community.zabbix/pull/391 +- name: "test: configure details for SNMPv2 interface" + community.zabbix.zabbix_host: + host_name: ExampleHost + interfaces: + - type: 1 + main: 1 + useip: 1 + ip: 10.1.1.1 + port: "10050" + - type: 2 + main: 1 + useip: 1 + ip: 10.1.1.1 + port: "161" + details: + version: 2 + community: Community String + register: zabbix_host1 + +- name: expect to succeed and that things have changed + ansible.builtin.assert: + that: + - "zabbix_host1 is changed" + +- name: "test: configure details for SNMPv2 interface (again)" + community.zabbix.zabbix_host: + host_name: ExampleHost + interfaces: + - type: 1 + main: 1 + useip: 1 + ip: 10.1.1.1 + port: "10050" + - type: 2 + main: 1 + useip: 1 + ip: 10.1.1.1 + port: "161" + details: + version: 2 + community: Community String + register: zabbix_host1 + +- name: expect to succeed and that things have not changed + ansible.builtin.assert: + that: + - "zabbix_host1 is not changed" + +- name: "test: configure SNMPv2 interface with the same options and force=False " + community.zabbix.zabbix_host: + host_name: ExampleHost + force: False + interfaces: + - type: 1 + main: 1 + useip: 1 + ip: 10.1.1.1 + port: "10050" + - type: 2 + main: 1 + useip: 1 + ip: 10.1.1.1 + port: "161" + details: + version: 2 + community: Community String + register: zabbix_host1 + +- name: expect to succeed and that things have not changed + ansible.builtin.assert: + that: + - "zabbix_host1 is not changed" + +- name: "test: update details for SNMPv2 interface with bulk sub option" + community.zabbix.zabbix_host: + host_name: ExampleHost + interfaces: + - type: 1 + main: 1 + useip: 1 + ip: 10.1.1.1 + port: "10050" + - type: 2 + main: 1 + useip: 1 + ip: 10.1.1.1 + port: "161" + details: + version: 2 + community: Community String + bulk: 0 + register: zabbix_host1 + +- name: expect to succeed and that things have changed + ansible.builtin.assert: + that: + - "zabbix_host1 is changed" + +- name: "test: configure details for SNMPv3 interface" + community.zabbix.zabbix_host: + host_name: ExampleHost + interfaces: + - type: 1 + main: 1 + useip: 1 + ip: 10.1.1.1 + port: "10050" + - type: 2 + main: 1 + useip: 1 + ip: 10.1.1.1 + port: "161" + details: + version: 3 + contextname: snmp_context + securityname: SNMP3 sec name + securitylevel: 0 + register: zabbix_host1 + +- name: expect to succeed and that things have changed + ansible.builtin.assert: + that: + - "zabbix_host1 is changed" + +- name: "test: configure details for SNMPv3 interface (again)" + community.zabbix.zabbix_host: + host_name: ExampleHost + interfaces: + - type: 1 + main: 1 + useip: 1 + ip: 10.1.1.1 + port: "10050" + - type: 2 + main: 1 + useip: 1 + ip: 10.1.1.1 + port: "161" + details: + version: 3 + contextname: snmp_context + securityname: SNMP3 sec name + securitylevel: 0 + register: zabbix_host1 + +- name: expect to succeed and that things have not changed + ansible.builtin.assert: + that: + - "zabbix_host1 is not changed" + +- name: "test: update details for SNMPv3 interface" + community.zabbix.zabbix_host: + host_name: ExampleHost + interfaces: + - type: 1 + main: 1 + useip: 1 + ip: 10.1.1.1 + port: "10050" + - type: 2 + main: 1 + useip: 1 + ip: 10.1.1.1 + port: "161" + details: + version: 3 + contextname: snmp_context + securityname: SNMP3 sec name + securitylevel: 2 + authprotocol: "{{ 2 if zabbix_version | float >= 5.4 else 0 }}" + authpassphrase: secret_auth_passphrase + privprotocol: "{{ 2 if zabbix_version | float >= 5.4 else 0 }}" + privpassphrase: secret_priv_passphrase + register: zabbix_host1 + +- name: expect to succeed and that things have changed + ansible.builtin.assert: + that: + - "zabbix_host1 is changed" + - name: "reset interfaces to two of the same type" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost interfaces: - type: "1" @@ -922,12 +905,12 @@ register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "reset interfaces to two of the same type (again)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost interfaces: - type: "1" @@ -940,12 +923,12 @@ register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is not changed" - name: "test: add IPMI settings" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost ipmi_authtype: 2 ipmi_privilege: 4 @@ -954,12 +937,12 @@ register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: add IPMI settings again" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost ipmi_authtype: 2 ipmi_privilege: 4 @@ -968,22 +951,22 @@ register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is not changed" - name: "test: verify that an empty change is idempotent" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is not changed" - name: "test: IPMI set default values" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost ipmi_authtype: -1 ipmi_privilege: 2 @@ -992,12 +975,12 @@ register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: IPMI set default values (again)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost ipmi_authtype: -1 ipmi_privilege: 2 @@ -1006,380 +989,366 @@ register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is not changed" - name: "test: change host inventory mode to disabled" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost inventory_mode: disabled register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: change host inventory mode to manual" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost inventory_mode: manual register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: add new set of user macros to the host" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost macros: - - macro: '{$NEWMACRO1}' + - macro: "{$NEWMACRO1}" value: test123 - macro: NEWMACRO2 value: abc register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: add new set of user macros to the host (again - lowercase)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost macros: - - macro: '{$newmacro1}' + - macro: "{$newmacro1}" value: test123 - macro: newmacro2 value: abc register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is not changed" - name: "test: update one of the user macros present on the host" - zabbix_host: + community.zabbix.zabbix_host: + host_name: ExampleHost + macros: + - macro: "{$NEWMACRO1}" + value: test1234 + - macro: NEWMACRO2 + value: abc + register: zabbix_host1 + +- name: expect to succeed and that things have changed + ansible.builtin.assert: + that: + - "zabbix_host1 is changed" + +- name: "test: update one of the user macros with description" + community.zabbix.zabbix_host: host_name: ExampleHost macros: - - macro: '{$NEWMACRO1}' + - macro: "{$NEWMACRO1}" value: test1234 + description: Example Description - macro: NEWMACRO2 value: abc register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" -# The description of tag is available since Zabbix version 4.4 -- when: zabbix_version is version("4.4", ">=") - block: - - name: "test: update one of the user macros with description" - zabbix_host: - host_name: ExampleHost - macros: - - macro: '{$NEWMACRO1}' - value: test1234 - description: Example Description - - macro: NEWMACRO2 - value: abc - register: zabbix_host1 - - - name: expect to succeed and that things have changed - assert: - that: - - "zabbix_host1 is changed" - - - name: "test: update one of the user macros with description (again)" - zabbix_host: - host_name: ExampleHost - macros: - - macro: '{$NEWMACRO1}' - value: test1234 - description: Example Description - - macro: NEWMACRO2 - value: abc - register: zabbix_host1 - - - name: expect to succeed and that things have not changed - assert: - that: - - "zabbix_host1 is not changed" - - - name: "test: update one of the user macros by removing description" - zabbix_host: - host_name: ExampleHost - macros: - - macro: '{$NEWMACRO1}' - value: test1234 - - macro: NEWMACRO2 - value: abc - register: zabbix_host1 - - - name: expect to succeed and that things have changed - assert: - that: - - "zabbix_host1 is changed" +- name: "test: update one of the user macros with description (again)" + community.zabbix.zabbix_host: + host_name: ExampleHost + macros: + - macro: "{$NEWMACRO1}" + value: test1234 + description: Example Description + - macro: NEWMACRO2 + value: abc + register: zabbix_host1 + +- name: expect to succeed and that things have not changed + ansible.builtin.assert: + that: + - "zabbix_host1 is not changed" + +- name: "test: update one of the user macros by removing description" + community.zabbix.zabbix_host: + host_name: ExampleHost + macros: + - macro: "{$NEWMACRO1}" + value: test1234 + - macro: NEWMACRO2 + value: abc + register: zabbix_host1 + +- name: expect to succeed and that things have changed + ansible.builtin.assert: + that: + - "zabbix_host1 is changed" - name: "test: add user macro while keeping previous ones with force=no" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost force: false macros: - - macro: '{$NEWMACRO3}' + - macro: "{$NEWMACRO3}" value: testing register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: add user macro while keeping previous ones with force=no (again)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost force: false macros: - - macro: '{$NEWMACRO3}' + - macro: "{$NEWMACRO3}" value: testing register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is not changed" - name: "test: add the same user macros (again)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost macros: - - macro: '{$NEWMACRO1}' + - macro: "{$NEWMACRO1}" value: test1234 - macro: NEWMACRO2 value: abc - - macro: '{$NEWMACRO3}' + - macro: "{$NEWMACRO3}" value: testing register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is not changed" -# type for macros added in 5.0 -- when: zabbix_version is version("5.0", ">=") - block: - - name: "test: add new user macro with type secret" - zabbix_host: - host_name: ExampleHost - macros: - - macro: '{$NEWMACROSECRET}' - value: secretvalue - type: secret - register: zabbix_host1 - - - name: expect to succeed and that things have changed - assert: - that: - - "zabbix_host1 is changed" - - - name: "test: add new user macro with type secret (again)" - zabbix_host: - host_name: ExampleHost - macros: - - macro: '{$NEWMACROSECRET}' - value: secretvalue - type: secret - register: zabbix_host1 - - - name: expect to succeed and that things have changed as it has secret value - assert: - that: - - "zabbix_host1 is changed" +- name: "test: add new user macro with type secret" + community.zabbix.zabbix_host: + host_name: ExampleHost + macros: + - macro: "{$NEWMACROSECRET}" + value: secretvalue + type: secret + register: zabbix_host1 + +- name: expect to succeed and that things have changed + ansible.builtin.assert: + that: + - "zabbix_host1 is changed" + +- name: "test: add new user macro with type secret (again)" + community.zabbix.zabbix_host: + host_name: ExampleHost + macros: + - macro: "{$NEWMACROSECRET}" + value: secretvalue + type: secret + register: zabbix_host1 + +- name: expect to succeed and that things have changed as it has secret value + ansible.builtin.assert: + that: + - "zabbix_host1 is changed" - name: "test: wipe out all of the user macros" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost macros: [] register: zabbix_host1 - name: expect to succeed and that things have changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: wipe out all of the user macros (again)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost macros: [] register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is not changed" -# The tag function is available since Zabbix version 4.4 -- when: zabbix_version is version("4.4", ">=") - block: - - name: "test: add new set of tags to the host" - zabbix_host: - host_name: ExampleHost - tags: - - tag: NEWTAG1 - - tag: NewTag2 - value: abc - register: zabbix_host1 - - - name: expect to succeed and that things have changed - assert: - that: - - "zabbix_host1 is changed" - - - name: "test: add new set of tags to the host (again)" - zabbix_host: - host_name: ExampleHost - tags: - - tag: NEWTAG1 - - tag: NewTag2 - value: abc - register: zabbix_host1 - - - name: expect to succeed and that things have not changed - assert: - that: - - "zabbix_host1 is not changed" - - - name: "test: update one of the tags present on the host" - zabbix_host: - host_name: ExampleHost - tags: - - tag: NEWTAG1 - - tag: NewTag2 - value: abcd - register: zabbix_host1 - - - name: expect to succeed and that things have changed - assert: - that: - - "zabbix_host1 is changed" - - - name: "test: add tag while keeping previous ones with force=no" - zabbix_host: - host_name: ExampleHost - force: false - tags: - - tag: newtag3 - value: testing - register: zabbix_host1 - - - name: expect to succeed and that things have changed - assert: - that: - - "zabbix_host1 is changed" - - - name: "test: add the same tags (again)" - zabbix_host: - host_name: ExampleHost - tags: - - tag: NEWTAG1 - - tag: NewTag2 - value: abcd - - tag: newtag3 - value: testing - register: zabbix_host1 - - - name: expect to succeed and that things have not changed - assert: - that: - - "zabbix_host1 is not changed" - - - name: "test: wipe out all of the tags" - zabbix_host: - host_name: ExampleHost - tags: [] - register: zabbix_host1 - - - name: expect to succeed and that things have changed - assert: - that: - - "zabbix_host1 is changed" +- name: "test: add new set of tags to the host" + community.zabbix.zabbix_host: + host_name: ExampleHost + tags: + - tag: NEWTAG1 + - tag: NewTag2 + value: abc + register: zabbix_host1 + +- name: expect to succeed and that things have changed + ansible.builtin.assert: + that: + - "zabbix_host1 is changed" + +- name: "test: add new set of tags to the host (again)" + community.zabbix.zabbix_host: + host_name: ExampleHost + tags: + - tag: NEWTAG1 + - tag: NewTag2 + value: abc + register: zabbix_host1 + +- name: expect to succeed and that things have not changed + ansible.builtin.assert: + that: + - "zabbix_host1 is not changed" + +- name: "test: update one of the tags present on the host" + community.zabbix.zabbix_host: + host_name: ExampleHost + tags: + - tag: NEWTAG1 + - tag: NewTag2 + value: abcd + register: zabbix_host1 + +- name: expect to succeed and that things have changed + ansible.builtin.assert: + that: + - "zabbix_host1 is changed" + +- name: "test: add tag while keeping previous ones with force=no" + community.zabbix.zabbix_host: + host_name: ExampleHost + force: false + tags: + - tag: newtag3 + value: testing + register: zabbix_host1 + +- name: expect to succeed and that things have changed + ansible.builtin.assert: + that: + - "zabbix_host1 is changed" + +- name: "test: add the same tags (again)" + community.zabbix.zabbix_host: + host_name: ExampleHost + tags: + - tag: NEWTAG1 + - tag: NewTag2 + value: abcd + - tag: newtag3 + value: testing + register: zabbix_host1 + +- name: expect to succeed and that things have not changed + ansible.builtin.assert: + that: + - "zabbix_host1 is not changed" + +- name: "test: wipe out all of the tags" + community.zabbix.zabbix_host: + host_name: ExampleHost + tags: [] + register: zabbix_host1 + +- name: expect to succeed and that things have changed + ansible.builtin.assert: + that: + - "zabbix_host1 is changed" - name: "test: wipe out all of the tags (again)" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost tags: [] register: zabbix_host1 - name: expect to succeed and that things have not changed - assert: + ansible.builtin.assert: that: - "zabbix_host1 is not changed" - name: "test: attempt to delete host created earlier" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost state: absent register: zabbix_host1 - name: deleting a host is a change, right? - assert: + ansible.builtin.assert: that: - "zabbix_host1 is changed" - name: "test: attempt deleting a non-existant host" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHost state: absent register: zabbix_host1 - name: deleting a non-existant host is not a change, right? - assert: + ansible.builtin.assert: that: - "not zabbix_host1 is changed" -- when: zabbix_version is version('5.2', '>=') - block: - - name: "test: create host without host interfaces" - zabbix_host: - host_name: ExampleHost - visible_name: ExampleName - description: My ExampleHost Description - host_groups: - - Linux servers - status: disabled - state: present - register: zbx_host_create_interfaceless - - - name: verify host was created without interfaces - assert: - that: zbx_host_create_interfaceless is changed - - - name: "test: create host without host interfaces (again)" - zabbix_host: - server_url: "{{ zabbix_api_server_url }}" - login_user: "{{ zabbix_api_login_user }}" - login_password: "{{ zabbix_api_login_pass }}" - host_name: ExampleHost - visible_name: ExampleName - description: My ExampleHost Description - host_groups: - - Linux servers - status: disabled - state: present - register: zbx_host_create_interfaceless - - - name: expect to succeed and that things have not changed - assert: - that: zbx_host_create_interfaceless is not changed - - - name: "cleanup" - zabbix_host: - host_name: ExampleHost - state: absent +- name: "test: create host without host interfaces" + community.zabbix.zabbix_host: + host_name: ExampleHost + visible_name: ExampleName + description: My ExampleHost Description + host_groups: + - Linux servers + status: disabled + state: present + register: zbx_host_create_interfaceless + +- name: verify host was created without interfaces + ansible.builtin.assert: + that: zbx_host_create_interfaceless is changed + +- name: "test: create host without host interfaces (again)" + community.zabbix.zabbix_host: + host_name: ExampleHost + visible_name: ExampleName + description: My ExampleHost Description + host_groups: + - Linux servers + status: disabled + state: present + register: zbx_host_create_interfaceless + +- name: expect to succeed and that things have not changed + ansible.builtin.assert: + that: zbx_host_create_interfaceless is not changed + +- name: "cleanup" + community.zabbix.zabbix_host: + host_name: ExampleHost + state: absent diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host_info/tasks/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host_info/tasks/main.yml index dfcaf097d..72c2f6364 100644 --- a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host_info/tasks/main.yml +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host_info/tasks/main.yml @@ -1,6 +1,6 @@ --- - name: "test - Prepare host for zabbix_host_info module" - zabbix_host: + community.zabbix.zabbix_host: host_name: ExampleHostForHostInfoModule visible_name: ExampleHostForHostInfoModuleName description: Test Host @@ -8,7 +8,7 @@ - Linux servers - Hypervisors link_templates: - - "{{ 'Zabbix server health' if zabbix_version | float >= 5.4 else 'Template App Zabbix Server' }}" + - Zabbix server health status: enabled inventory_mode: manual inventory_zabbix: @@ -24,7 +24,7 @@ state: present register: prepare_host_result -- assert: +- ansible.builtin.assert: that: - prepare_host_result.changed is sameas true @@ -35,7 +35,7 @@ environment: ZABBIX_VALIDATE_CERTS: false -- assert: +- ansible.builtin.assert: that: - env_vars_usage.hosts[0].name == "ExampleHostForHostInfoModuleName" @@ -46,53 +46,11 @@ block: - name: "test - Gather all facts of zabbix host" - zabbix_host_info: + community.zabbix.zabbix_host_info: register: gather_all_facts_result - - when: zabbix_version is version('4.0', '<=') - assert: - that: - - gather_all_facts_result.hosts | length == 1 - - gather_all_facts_result.hosts.0.host == "ExampleHostForHostInfoModule" - - gather_all_facts_result.hosts.0.name == "ExampleHostForHostInfoModuleName" - - gather_all_facts_result.hosts.0.description == "Test Host" - - gather_all_facts_result.hosts.0.groups.0.name == "Linux servers" - - gather_all_facts_result.hosts.0.groups.1.name == "Hypervisors" - - gather_all_facts_result.hosts.0.parentTemplates.0.name == "Template App Zabbix Server" - - gather_all_facts_result.hosts.0.status == "0" - - gather_all_facts_result.hosts.0.inventory.inventory_mode == "0" - - gather_all_facts_result.hosts.0.inventory.tag == "tag1" - - gather_all_facts_result.hosts.0.inventory.os == "Linux" - - gather_all_facts_result.hosts.0.hostinterfaces.0.dns == "" - - gather_all_facts_result.hosts.0.hostinterfaces.0.ip == "192.168.0.1" - - gather_all_facts_result.hosts.0.hostinterfaces.0.main == "1" - - gather_all_facts_result.hosts.0.hostinterfaces.0.port == "10050" - - gather_all_facts_result.hosts.0.hostinterfaces.0.type == "1" - - gather_all_facts_result.hosts.0.hostinterfaces.0.useip == "1" - - - when: zabbix_version is version('4.4', '>=') and zabbix_version is version('5.0', '<=') - assert: - that: - - gather_all_facts_result.hosts | length == 1 - - gather_all_facts_result.hosts.0.host == "ExampleHostForHostInfoModule" - - gather_all_facts_result.hosts.0.name == "ExampleHostForHostInfoModuleName" - - gather_all_facts_result.hosts.0.description == "Test Host" - - gather_all_facts_result.hosts.0.groups.0.name == "Linux servers" - - gather_all_facts_result.hosts.0.groups.1.name == "Hypervisors" - - gather_all_facts_result.hosts.0.parentTemplates.0.name == "Template App Zabbix Server" - - gather_all_facts_result.hosts.0.status == "0" - - gather_all_facts_result.hosts.0.inventory_mode == "0" - - gather_all_facts_result.hosts.0.inventory.tag == "tag1" - - gather_all_facts_result.hosts.0.inventory.os == "Linux" - - gather_all_facts_result.hosts.0.hostinterfaces.0.dns == "" - - gather_all_facts_result.hosts.0.hostinterfaces.0.ip == "192.168.0.1" - - gather_all_facts_result.hosts.0.hostinterfaces.0.main == "1" - - gather_all_facts_result.hosts.0.hostinterfaces.0.port == "10050" - - gather_all_facts_result.hosts.0.hostinterfaces.0.type == "1" - - gather_all_facts_result.hosts.0.hostinterfaces.0.useip == "1" - - when: zabbix_version is version('5.4', '>=') and zabbix_version is version('6.2', '<') - assert: + ansible.builtin.assert: that: - gather_all_facts_result.hosts | length == 1 - gather_all_facts_result.hosts.0.host == "ExampleHostForHostInfoModule" @@ -113,7 +71,7 @@ - gather_all_facts_result.hosts.0.hostinterfaces.0.useip == "1" - when: zabbix_version is version('6.2', '>=') - assert: + ansible.builtin.assert: that: - gather_all_facts_result.hosts | length == 1 - gather_all_facts_result.hosts.0.host == "ExampleHostForHostInfoModule" @@ -134,52 +92,57 @@ - gather_all_facts_result.hosts.0.hostinterfaces.0.useip == "1" - name: "test - Gather facts of zabbix host with host_inventory" - zabbix_host_info: + community.zabbix.zabbix_host_info: host_inventory: - tag - os register: gather_facts_with_host_inventory_result - - when: zabbix_version is version('3.4', '<=') - assert: - that: - - gather_facts_with_host_inventory_result.hosts.0.inventory | length == 3 - - gather_facts_with_host_inventory_result.hosts.0.inventory.tag == "tag1" - - gather_facts_with_host_inventory_result.hosts.0.inventory.os == "Linux" - - - when: zabbix_version is version('4.0', '>=') - assert: + - ansible.builtin.assert: that: - gather_facts_with_host_inventory_result.hosts.0.inventory | length == 2 - gather_facts_with_host_inventory_result.hosts.0.inventory.tag == "tag1" - gather_facts_with_host_inventory_result.hosts.0.inventory.os == "Linux" - name: "test - Partial match of zabbix host name" - zabbix_host_info: + community.zabbix.zabbix_host_info: host_name: HostForHostInfo exact_match: false register: partial_match_result - - assert: + - ansible.builtin.assert: that: - partial_match_result.hosts | length == 1 - name: "test - Exact match of zabbix host name" - zabbix_host_info: + community.zabbix.zabbix_host_info: exact_match: true register: exact_match_result - - assert: + - ansible.builtin.assert: that: - exact_match_result.hosts | length == 1 - name: "test - Exact match of zabbix host name(expectations - host not found)" - zabbix_host_info: + community.zabbix.zabbix_host_info: host_name: HostForHostInfo exact_match: true register: exact_match_host_not_found_result ignore_errors: true - - assert: + - ansible.builtin.assert: that: - exact_match_host_not_found_result.failed is sameas true + +- name: Get all hosts + community.zabbix.zabbix_host_info: + register: get_all_hosts_result + +- ansible.builtin.assert: + that: + - get_all_hosts_result.hosts | length == 2 + +- name: Clean up test host + community.zabbix.zabbix_host: + host_name: ExampleHostForHostInfoModule + state: absent diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_hostmacro/tasks/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_hostmacro/tasks/main.yml index 1a9d81eff..adc4d0402 100644 --- a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_hostmacro/tasks/main.yml +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_hostmacro/tasks/main.yml @@ -1,6 +1,6 @@ --- - name: create helper zabbix host - zabbix_host: + community.zabbix.zabbix_host: host_name: zbx_hmacro_host01 host_groups: - Linux servers @@ -10,97 +10,105 @@ dns: zbx_hmacro_host01 - name: test - attempt to create new host macro - zabbix_hostmacro: + community.zabbix.zabbix_hostmacro: host_name: zbx_hmacro_host01 macro_name: zbxhmacro_test01 macro_value: 123 + macro_description: Global Macro description register: zbxhmacro_new - name: assert that macro was created - assert: + ansible.builtin.assert: that: zbxhmacro_new is changed - name: test - attempt to create same host macro - zabbix_hostmacro: + community.zabbix.zabbix_hostmacro: host_name: zbx_hmacro_host01 macro_name: zbxhmacro_test01 macro_value: 123 + macro_description: Global Macro description register: zbxhmacro_existing - name: assert that nothing has been changed - assert: + ansible.builtin.assert: that: not zbxhmacro_existing is changed - name: test - attempt to create same host macro in zabbix native format - zabbix_hostmacro: + community.zabbix.zabbix_hostmacro: host_name: zbx_hmacro_host01 macro_name: "{$ZBXHMACRO_TEST01}" macro_value: 123 + macro_description: Global Macro description register: zbxhmacro_existing_native - name: assert that nothing has been changed - assert: + ansible.builtin.assert: that: not zbxhmacro_existing_native is changed - name: test - attempt to create new host macro in zabbix native format - zabbix_hostmacro: + community.zabbix.zabbix_hostmacro: host_name: zbx_hmacro_host01 macro_name: "{$ZBXHMACRO_TEST02}" macro_value: abcd + macro_description: Global Macro description register: zbxhmacro_new_native - name: assert that nothing macro was created - assert: + ansible.builtin.assert: that: zbxhmacro_new_native is changed - name: test - attempt to update host macro with string value while force=no - zabbix_hostmacro: + community.zabbix.zabbix_hostmacro: host_name: zbx_hmacro_host01 macro_name: zbxhmacro_test01 macro_value: abc + macro_description: Global Macro description force: false register: zbxhmacro_update_noforce - name: assert that nothing has been changed - assert: + ansible.builtin.assert: that: not zbxhmacro_update_noforce is changed - name: test - attempt to update host macro with string value - zabbix_hostmacro: + community.zabbix.zabbix_hostmacro: host_name: zbx_hmacro_host01 macro_name: zbxhmacro_test01 macro_value: abc + macro_description: Global Macro description register: zbxhmacro_update ignore_errors: true - name: assert that host macro was updated - assert: + ansible.builtin.assert: that: zbxhmacro_update is changed - name: test - attempt to create host macro with context - zabbix_hostmacro: + community.zabbix.zabbix_hostmacro: host_name: zbx_hmacro_host01 macro_name: low_space_limit:/home macro_value: 10 + macro_description: Global Macro description register: zbxhmacro_context_new - name: assert that macro was created - assert: + ansible.builtin.assert: that: zbxhmacro_context_new is changed - name: test - attempt to create same host macro with context and verify that it was converted to uppercase - zabbix_hostmacro: + community.zabbix.zabbix_hostmacro: host_name: zbx_hmacro_host01 macro_name: LOW_SPACE_LIMIT:/home macro_value: 10 + macro_description: Global Macro description register: zbxhmacro_context_existing - name: assert that nothing has been changed - assert: + ansible.builtin.assert: that: not zbxhmacro_context_existing is changed - name: test - attempt to delete all host macros - zabbix_hostmacro: + community.zabbix.zabbix_hostmacro: host_name: zbx_hmacro_host01 macro_name: "{{ item }}" state: absent @@ -111,53 +119,51 @@ register: zbxhmacro_delete_existing - name: assert that all macros have been deleted - assert: + ansible.builtin.assert: that: item.changed is sameas True loop: "{{ zbxhmacro_delete_existing.results }}" - name: test - attempt to delete non-existing host macro - zabbix_hostmacro: + community.zabbix.zabbix_hostmacro: host_name: zbx_hmacro_host01 macro_name: zbxhmacro_test01 state: absent register: zbxhmacro_delete_missing - name: assert that nothing has been changed - assert: + ansible.builtin.assert: that: not zbxhmacro_delete_missing is changed -- name: test - do not run host macro secret tests for Zabbix < 5.0 - meta: end_play - when: zabbix_version is version('5.0', '<') - - name: test - attempt to create host macro with type secret - zabbix_hostmacro: + community.zabbix.zabbix_hostmacro: host_name: zbx_hmacro_host01 macro_name: zbxhmacro_test03 macro_value: abcd macro_type: secret + macro_description: Global Macro description register: zbxhmacro_update ignore_errors: true - name: assert that host macro was updated - assert: + ansible.builtin.assert: that: zbxhmacro_update is changed - name: test - attempt to update host macro with type secret with same value - zabbix_hostmacro: + community.zabbix.zabbix_hostmacro: host_name: zbx_hmacro_host01 macro_name: zbxhmacro_test03 macro_value: abcd macro_type: secret + macro_description: Global Macro description register: zbxhmacro_update ignore_errors: true - name: assert that host macro was updated - assert: + ansible.builtin.assert: that: zbxhmacro_update is changed - name: test - attempt to delete host macros type secret - zabbix_hostmacro: + community.zabbix.zabbix_hostmacro: host_name: zbx_hmacro_host01 macro_name: "{{ item }}" state: absent @@ -166,6 +172,6 @@ register: zbxhmacro_delete_existing - name: assert that all macros have been deleted - assert: + ansible.builtin.assert: that: item.changed is sameas True loop: "{{ zbxhmacro_delete_existing.results }}" diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_housekeeping/tasks/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_housekeeping/tasks/main.yml index 6189c1d77..242b11927 100644 --- a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_housekeeping/tasks/main.yml +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_housekeeping/tasks/main.yml @@ -1,96 +1,77 @@ --- -- name: test - do not run tests with < Zabbix 4.0 - meta: end_play - when: zabbix_version is version('4.0', '<') +- name: test update housekeeping parameters. + community.zabbix.zabbix_housekeeping: + hk_events_mode: yes + hk_events_trigger: 365d + hk_events_service: 1w + hk_events_internal: 86400s + hk_events_discovery: 48h + hk_events_autoreg: 1440m + hk_services_mode: yes + hk_services: 365d + hk_audit_mode: yes + hk_audit: 365d + hk_sessions_mode: yes + hk_sessions: 365d + hk_history_mode: yes + hk_history_global: yes + hk_history: 365d + hk_trends_mode: yes + hk_trends_global: yes + hk_trends: 365d + compression_status: off + compress_older: 7d + register: zbxhk_update_result -- when: zabbix_version is version('5.2', '<') - name: Unsupport Zabbix version (<5.2) - block: - - name: test fail to update housekeeping - community.zabbix.zabbix_housekeeping: - hk_events_mode: true - register: zbxhk_update_result - ignore_errors: true +- ansible.builtin.assert: + that: zbxhk_update_result.changed is sameas True - - assert: - that: zbxhk_update_result.failed is sameas True +- name: test update housekeeping parameters (again). + community.zabbix.zabbix_housekeeping: + hk_events_mode: yes + hk_events_trigger: 365d + hk_events_service: 1w + hk_events_internal: 86400s + hk_events_discovery: 48h + hk_events_autoreg: 1440m + hk_services_mode: yes + hk_services: 365d + hk_audit_mode: yes + hk_audit: 365d + hk_sessions_mode: yes + hk_sessions: 365d + hk_history_mode: yes + hk_history_global: yes + hk_history: 365d + hk_trends_mode: yes + hk_trends_global: yes + hk_trends: 365d + compression_status: off + compress_older: 7d + register: zbxhk_update_result -- when: zabbix_version is version('5.2', '>=') - name: Support Zabbix version (>=5.2) - block: - - name: test update housekeeping parameters. - community.zabbix.zabbix_housekeeping: - hk_events_mode: yes - hk_events_trigger: 365d - hk_events_service: 1w - hk_events_internal: 86400s - hk_events_discovery: 48h - hk_events_autoreg: 1440m - hk_services_mode: yes - hk_services: 365d - hk_audit_mode: yes - hk_audit: 365d - hk_sessions_mode: yes - hk_sessions: 365d - hk_history_mode: yes - hk_history_global: yes - hk_history: 365d - hk_trends_mode: yes - hk_trends_global: yes - hk_trends: 365d - compression_status: off - compress_older: 7d - register: zbxhk_update_result +- ansible.builtin.assert: + that: zbxhk_update_result.changed is sameas False - - assert: - that: zbxhk_update_result.changed is sameas True - - - name: test update housekeeping parameters (again). - community.zabbix.zabbix_housekeeping: - hk_events_mode: yes - hk_events_trigger: 365d - hk_events_service: 1w - hk_events_internal: 86400s - hk_events_discovery: 48h - hk_events_autoreg: 1440m - hk_services_mode: yes - hk_services: 365d - hk_audit_mode: yes - hk_audit: 365d - hk_sessions_mode: yes - hk_sessions: 365d - hk_history_mode: yes - hk_history_global: yes - hk_history: 365d - hk_trends_mode: yes - hk_trends_global: yes - hk_trends: 365d - compression_status: off - compress_older: 7d - register: zbxhk_update_result - - - assert: - that: zbxhk_update_result.changed is sameas False - - - name: initialize housekeeping setting. - community.zabbix.zabbix_housekeeping: - hk_events_mode: yes - hk_events_trigger: 365d - hk_events_service: 1d - hk_events_internal: 1d - hk_events_discovery: 1d - hk_events_autoreg: 1d - hk_services_mode: yes - hk_services: 365d - hk_audit_mode: yes - hk_audit: 365d - hk_sessions_mode: yes - hk_sessions: 365d - hk_history_mode: yes - hk_history_global: no - hk_history: 365d - hk_trends_mode: yes - hk_trends_global: no - hk_trends: 365d - compression_status: off - compress_older: 7d +- name: initialize housekeeping setting. + community.zabbix.zabbix_housekeeping: + hk_events_mode: yes + hk_events_trigger: 365d + hk_events_service: 1d + hk_events_internal: 1d + hk_events_discovery: 1d + hk_events_autoreg: 1d + hk_services_mode: yes + hk_services: 365d + hk_audit_mode: yes + hk_audit: 365d + hk_sessions_mode: yes + hk_sessions: 365d + hk_history_mode: yes + hk_history_global: no + hk_history: 365d + hk_trends_mode: yes + hk_trends_global: no + hk_trends: 365d + compression_status: off + compress_older: 7d diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_maintenance/tasks/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_maintenance/tasks/main.yml index 0daca8d13..1b9c6f6bd 100644 --- a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_maintenance/tasks/main.yml +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_maintenance/tasks/main.yml @@ -1,7 +1,7 @@ --- # New host create test from here - name: "test - Create a new host" - zabbix_host: + community.zabbix.zabbix_host: host_name: example host_groups: - Linux servers @@ -14,24 +14,24 @@ port: 10050 register: create_host_result -- assert: +- ansible.builtin.assert: that: - create_host_result.changed is sameas true - name: "test - Create maintenance with a host_name param" - zabbix_maintenance: + community.zabbix.zabbix_maintenance: name: maintenance host_name: example state: present register: create_maintenance_host_name_result -- assert: +- ansible.builtin.assert: that: - create_maintenance_host_name_result.changed is sameas true # This check doesn't modify maintenace object and thus will be changed=false unless there are hosts without visible name defined - name: "test - Create maintenance with a host_name param and disabled visible_name" - zabbix_maintenance: + community.zabbix.zabbix_maintenance: name: maintenance host_name: example visible_name: false @@ -40,12 +40,12 @@ # BUGGED: sometimes when test "lags" and some time passes since previous tasks, # maintenance_start will not match and be updated, thus resulting in changed -# - assert: +# - ansible.builtin.assert: # that: # - create_maintenance_host_name_result.changed is sameas false - name: "test - Create maintenance with a host_name param(again - expectations: false change will occur)" - zabbix_maintenance: + community.zabbix.zabbix_maintenance: name: maintenance host_name: example state: present @@ -53,12 +53,12 @@ # BUGGED: sometimes when test "lags" and some time passes since previous tasks, # maintenance_start will not match and be updated, thus resulting in changed -# - assert: +# - ansible.builtin.assert: # that: # - create_maintenance_host_name_again_result.changed is sameas false - name: "test - Update maintenance with a desc param" - zabbix_maintenance: + community.zabbix.zabbix_maintenance: name: maintenance host_name: example desc: "test description" @@ -67,12 +67,12 @@ - debug: msg="{{ update_maintenance_desc_result }}" -- assert: +- ansible.builtin.assert: that: - update_maintenance_desc_result.changed is sameas true - name: "test - Update maintenance with a desc param(again - expectations: no change will occur)" - zabbix_maintenance: + community.zabbix.zabbix_maintenance: name: maintenance host_name: example desc: "test description" @@ -81,12 +81,12 @@ # BUGGED: sometimes when test "lags" and some time passes since previous tasks, # maintenance_start will not match and be updated, thus resulting in changed -# - assert: +# - ansible.builtin.assert: # that: # - update_maintenance_desc_again_result.changed is sameas false - name: "test - Update maintenance with a collect_data" - zabbix_maintenance: + community.zabbix.zabbix_maintenance: name: maintenance host_name: example desc: "test description" @@ -94,12 +94,12 @@ state: present register: update_maintenance_collect_data_result -- assert: +- ansible.builtin.assert: that: - update_maintenance_collect_data_result.changed is sameas true - name: "test - Update maintenance with a collect_data(again - expectations: no change will occur)" - zabbix_maintenance: + community.zabbix.zabbix_maintenance: name: maintenance host_name: example desc: "test description" @@ -109,12 +109,12 @@ # BUGGED: sometimes when test "lags" and some time passes since previous tasks, # maintenance_start will not match and be updated, thus resulting in changed -# - assert: +# - ansible.builtin.assert: # that: # - update_maintenance_collect_data_again_result.changed is sameas false - name: "test - Update maintenance with a minutes param" - zabbix_maintenance: + community.zabbix.zabbix_maintenance: name: maintenance host_name: example desc: "test description" @@ -123,12 +123,12 @@ state: present register: update_maintenance_minutes_result -- assert: +- ansible.builtin.assert: that: - update_maintenance_minutes_result.changed is sameas true - name: "test - Update maintenance with a minutes param(again - expectations: no change will occur)" - zabbix_maintenance: + community.zabbix.zabbix_maintenance: name: maintenance host_name: example desc: "test description" @@ -139,12 +139,12 @@ # BUGGED: sometimes when test "lags" and some time passes since previous tasks, # maintenance_start will not match and be updated, thus resulting in changed -# - assert: +# - ansible.builtin.assert: # that: # - update_maintenance_minutes_again_result.changed is sameas false - name: "test - Update maintenance with a host_groups param" - zabbix_maintenance: + community.zabbix.zabbix_maintenance: name: maintenance host_name: example host_groups: @@ -156,12 +156,12 @@ state: present register: update_maintenance_host_groups_result -- assert: +- ansible.builtin.assert: that: - update_maintenance_host_groups_result.changed is sameas true - name: "test - Update maintenance with a host_groups param(again - expectations: no change will occur)" - zabbix_maintenance: + community.zabbix.zabbix_maintenance: name: maintenance host_name: example host_groups: @@ -175,12 +175,12 @@ # BUGGED: sometimes when test "lags" and some time passes since previous tasks, # maintenance_start will not match and be updated, thus resulting in changed -# - assert: +# - ansible.builtin.assert: # that: # - update_maintenance_host_groups_again_result.changed is sameas false - name: "test - Update maintenance with change host_name to host_names param" - zabbix_maintenance: + community.zabbix.zabbix_maintenance: name: maintenance host_names: - example @@ -194,12 +194,12 @@ state: present register: update_maintenance_host_names_result -- assert: +- ansible.builtin.assert: that: - update_maintenance_host_names_result.changed is sameas true - name: "test - Update maintenance with change host_name to host_names param(again - expectations: no change will occur)" - zabbix_maintenance: + community.zabbix.zabbix_maintenance: name: maintenance host_names: - example @@ -215,12 +215,12 @@ # BUGGED: sometimes when test "lags" and some time passes since previous tasks, # maintenance_start will not match and be updated, thus resulting in changed -# - assert: +# - ansible.builtin.assert: # that: # - update_maintenance_host_names_again_result.changed is sameas false - name: "test - Update maintenance with tags" - zabbix_maintenance: + community.zabbix.zabbix_maintenance: name: maintenance host_names: - example @@ -229,7 +229,7 @@ - Linux servers - Hypervisors desc: "test description" - collect_data: yes # required for tags + collect_data: yes # required for tags minutes: 90 state: present tags: @@ -241,12 +241,12 @@ operator: 0 register: update_maintenance_host_tags -- assert: +- ansible.builtin.assert: that: - update_maintenance_host_tags.changed is sameas true - name: "test - Update maintenance with tags (again)" - zabbix_maintenance: + community.zabbix.zabbix_maintenance: name: maintenance host_names: - example @@ -269,12 +269,12 @@ # BUGGED: sometimes when test "lags" and some time passes since previous tasks, # maintenance_start will not match and be updated, thus resulting in changed -#- assert: +#- ansible.builtin.assert: # that: # - update_maintenance_host_tags.changed is sameas false - name: "test - Delete maintenance" - zabbix_maintenance: + community.zabbix.zabbix_maintenance: name: maintenance host_name: example state: absent @@ -282,23 +282,23 @@ tags: - cleanup -- assert: +- ansible.builtin.assert: that: - delete_maintenance_result.changed is sameas true - name: "test - Delete maintenance(again - expectations: no change will occur)" - zabbix_maintenance: + community.zabbix.zabbix_maintenance: name: maintenance host_name: example state: absent register: delete_maintenance_again_result -- assert: +- ansible.builtin.assert: that: - delete_maintenance_again_result.changed is sameas false - name: "test - Delete testing host" - zabbix_host: + community.zabbix.zabbix_host: host_name: example state: absent tags: diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_mediatype/tasks/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_mediatype/tasks/main.yml index 4daffebdd..a49166d37 100644 --- a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_mediatype/tasks/main.yml +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_mediatype/tasks/main.yml @@ -8,156 +8,152 @@ smtp_email: zabbix@example.com block: - - name: test - create new email mediatype without authentication - zabbix_mediatype: - register: zbxmediatype_new - - - assert: - that: zbxmediatype_new.changed is sameas True - - - name: test - create new email mediatype without authentication (again) - zabbix_mediatype: - register: zbxmediatype_new - - - assert: - that: zbxmediatype_new.changed is sameas False - - - name: test - update email mediatype smtp information - zabbix_mediatype: - smtp_helo: example.com - smtp_server: mail.example.com - smtp_server_port: 465 - register: zbxmediatype_smtp - - - assert: - that: zbxmediatype_smtp.changed is sameas True - - - name: test - update email mediatype smtp information (again) - zabbix_mediatype: - smtp_helo: example.com - smtp_server: mail.example.com - smtp_server_port: 465 - register: zbxmediatype_smtp - - - assert: - that: zbxmediatype_smtp.changed is sameas False - - - name: test - reset email mediatype smtp information to default - zabbix_mediatype: - register: zbxmediatype_reset - - - assert: - that: zbxmediatype_reset.changed is sameas True - - - name: test - update email mediatype with authentication without credentials (fail) - zabbix_mediatype: - smtp_authentication: true - smtp_security: STARTTLS - register: zbxmediatype_auth_fail - ignore_errors: true - - - assert: - that: zbxmediatype_auth_fail.failed is sameas True - - - name: test - update email mediatype with authentication - zabbix_mediatype: - smtp_authentication: true - smtp_security: STARTTLS - username: zabbix - password: Ex4mP!3 - register: zbxmediatype_auth - - - assert: - that: zbxmediatype_auth.changed is sameas True - - - name: test - update email mediatype with authentication (again) - zabbix_mediatype: - smtp_authentication: true - smtp_security: STARTTLS - username: zabbix - password: Ex4mP!3 - register: zbxmediatype_auth - - - assert: - that: zbxmediatype_auth.changed is sameas False - - - name: test - update email mediatype with SSL/TLS and host/peer verification - zabbix_mediatype: - smtp_authentication: true - smtp_security: SSL/TLS - smtp_verify_host: true - smtp_verify_peer: true - username: zabbix - password: Ex4mP!3 - register: zbxmediatype_verif - - - assert: - that: zbxmediatype_verif.changed is sameas True - - - name: test - update email mediatype with SSL/TLS and host/peer verification (again) - zabbix_mediatype: - smtp_authentication: true - smtp_security: SSL/TLS - smtp_verify_host: true - smtp_verify_peer: true - username: zabbix - password: Ex4mP!3 - register: zbxmediatype_verif - - - assert: - that: zbxmediatype_verif.changed is sameas False - - - when: zabbix_version is version('3.4', '>=') - block: + - name: test - create new email mediatype without authentication + community.zabbix.zabbix_mediatype: + register: zbxmediatype_new + + - ansible.builtin.assert: + that: zbxmediatype_new.changed is sameas True + + - name: test - create new email mediatype without authentication (again) + community.zabbix.zabbix_mediatype: + register: zbxmediatype_new + + - ansible.builtin.assert: + that: zbxmediatype_new.changed is sameas False + + - name: test - update email mediatype smtp information + community.zabbix.zabbix_mediatype: + smtp_helo: example.com + smtp_server: mail.example.com + smtp_server_port: 465 + register: zbxmediatype_smtp + + - ansible.builtin.assert: + that: zbxmediatype_smtp.changed is sameas True + + - name: test - update email mediatype smtp information (again) + community.zabbix.zabbix_mediatype: + smtp_helo: example.com + smtp_server: mail.example.com + smtp_server_port: 465 + register: zbxmediatype_smtp + + - ansible.builtin.assert: + that: zbxmediatype_smtp.changed is sameas False + + - name: test - reset email mediatype smtp information to default + community.zabbix.zabbix_mediatype: + register: zbxmediatype_reset + + - ansible.builtin.assert: + that: zbxmediatype_reset.changed is sameas True + + - name: test - update email mediatype with authentication without credentials (fail) + community.zabbix.zabbix_mediatype: + smtp_authentication: true + smtp_security: STARTTLS + register: zbxmediatype_auth_fail + ignore_errors: true + + - ansible.builtin.assert: + that: zbxmediatype_auth_fail.failed is sameas True + + - name: test - update email mediatype with authentication + community.zabbix.zabbix_mediatype: + smtp_authentication: true + smtp_security: STARTTLS + username: zabbix + password: Ex4mP!3 + register: zbxmediatype_auth + + - ansible.builtin.assert: + that: zbxmediatype_auth.changed is sameas True + + - name: test - update email mediatype with authentication (again) + community.zabbix.zabbix_mediatype: + smtp_authentication: true + smtp_security: STARTTLS + username: zabbix + password: Ex4mP!3 + register: zbxmediatype_auth + + - ansible.builtin.assert: + that: zbxmediatype_auth.changed is sameas False + + - name: test - update email mediatype with SSL/TLS and host/peer verification + community.zabbix.zabbix_mediatype: + smtp_authentication: true + smtp_security: SSL/TLS + smtp_verify_host: true + smtp_verify_peer: true + username: zabbix + password: Ex4mP!3 + register: zbxmediatype_verif + + - ansible.builtin.assert: + that: zbxmediatype_verif.changed is sameas True + + - name: test - update email mediatype with SSL/TLS and host/peer verification (again) + community.zabbix.zabbix_mediatype: + smtp_authentication: true + smtp_security: SSL/TLS + smtp_verify_host: true + smtp_verify_peer: true + username: zabbix + password: Ex4mP!3 + register: zbxmediatype_verif + + - ansible.builtin.assert: + that: zbxmediatype_verif.changed is sameas False + - name: test - reset email mediatype smtp information to default - zabbix_mediatype: + community.zabbix.zabbix_mediatype: register: zbxmediatype_reset - - assert: + - ansible.builtin.assert: that: zbxmediatype_reset.changed is sameas True - name: test - update email mediatype concurrent settings - zabbix_mediatype: + community.zabbix.zabbix_mediatype: max_sessions: 99 max_attempts: 10 attempt_interval: 30s register: zbxmediatype_concur - - assert: + - ansible.builtin.assert: that: zbxmediatype_concur.changed is sameas True - name: test - update email mediatype concurrent settings (again) - zabbix_mediatype: + community.zabbix.zabbix_mediatype: max_sessions: 99 max_attempts: 10 attempt_interval: 30s register: zbxmediatype_concur - - assert: + - ansible.builtin.assert: that: zbxmediatype_concur.changed is sameas False - name: test - update email mediatype concurrent settings above range (fail) - zabbix_mediatype: + community.zabbix.zabbix_mediatype: max_sessions: 102 max_attempts: 101 attempt_interval: 61m register: zbxmediatype_concur_fail ignore_errors: true - - assert: + - ansible.builtin.assert: that: zbxmediatype_concur_fail.failed is sameas True - - when: zabbix_version is version('5.0', '>=') - block: - name: test - reset email mediatype smtp information to default - zabbix_mediatype: + community.zabbix.zabbix_mediatype: register: zbxmediatype_reset - - assert: + - ansible.builtin.assert: that: zbxmediatype_reset.changed is sameas True - name: test - update email mediatype with message templates - zabbix_mediatype: + community.zabbix.zabbix_mediatype: message_templates: - eventsource: triggers recovery: operations @@ -177,11 +173,11 @@ body: "Internal event started at {EVEN.TIME} on {EVENT.DATE}\r\nEvent name: {EVENT.NAME}\r\n" register: zbxmediatype_msg_templates - - assert: + - ansible.builtin.assert: that: zbxmediatype_msg_templates.changed is sameas True - name: test - update email mediatype with message templates (again) - zabbix_mediatype: + community.zabbix.zabbix_mediatype: message_templates: - eventsource: triggers recovery: operations @@ -201,11 +197,11 @@ body: "Internal event started at {EVEN.TIME} on {EVENT.DATE}\r\nEvent name: {EVENT.NAME}\r\n" register: zbxmediatype_msg_templates - - assert: + - ansible.builtin.assert: that: zbxmediatype_msg_templates.changed is sameas False - name: test - update subject of message template in email mediatype - zabbix_mediatype: + community.zabbix.zabbix_mediatype: message_templates: - eventsource: triggers recovery: operations @@ -225,11 +221,11 @@ body: "Internal event started at {EVEN.TIME} on {EVENT.DATE}\r\nEvent name: {EVENT.NAME}\r\n" register: zbxmediatype_msg_templates - - assert: + - ansible.builtin.assert: that: zbxmediatype_msg_templates.changed is sameas True - name: test - update message of message template in email mediatype - zabbix_mediatype: + community.zabbix.zabbix_mediatype: message_templates: - eventsource: triggers recovery: operations @@ -249,11 +245,11 @@ body: "Internal event started at {EVEN.TIME} on {EVENT.DATE}\r\nEvent name: {EVENT.NAME}\r\n" register: zbxmediatype_msg_templates - - assert: + - ansible.builtin.assert: that: zbxmediatype_msg_templates.changed is sameas True - name: test - update subject and message of message template in email mediatype (again) - zabbix_mediatype: + community.zabbix.zabbix_mediatype: message_templates: - eventsource: triggers recovery: operations @@ -273,40 +269,40 @@ body: "Internal event started at {EVEN.TIME} on {EVENT.DATE}\r\nEvent name: {EVENT.NAME}\r\n" register: zbxmediatype_msg_templates - - assert: + - ansible.builtin.assert: that: zbxmediatype_msg_templates.changed is sameas False - - name: test - disable email mediatype - zabbix_mediatype: - status: disabled - register: zbxmediatype_disable + - name: test - disable email mediatype + community.zabbix.zabbix_mediatype: + status: disabled + register: zbxmediatype_disable - - assert: - that: zbxmediatype_disable.changed is sameas True + - ansible.builtin.assert: + that: zbxmediatype_disable.changed is sameas True - - name: test - disable email mediatype (again) - zabbix_mediatype: - status: disabled - register: zbxmediatype_disable + - name: test - disable email mediatype (again) + community.zabbix.zabbix_mediatype: + status: disabled + register: zbxmediatype_disable - - assert: - that: zbxmediatype_disable.changed is sameas False + - ansible.builtin.assert: + that: zbxmediatype_disable.changed is sameas False - - name: test - delete email mediatype - zabbix_mediatype: - state: absent - register: zbxmediatype_delete + - name: test - delete email mediatype + community.zabbix.zabbix_mediatype: + state: absent + register: zbxmediatype_delete - - assert: - that: zbxmediatype_delete.changed is sameas True + - ansible.builtin.assert: + that: zbxmediatype_delete.changed is sameas True - - name: test - delete email mediatype (again) - zabbix_mediatype: - state: absent - register: zbxmediatype_delete + - name: test - delete email mediatype (again) + community.zabbix.zabbix_mediatype: + state: absent + register: zbxmediatype_delete - - assert: - that: zbxmediatype_delete.changed is sameas False + - ansible.builtin.assert: + that: zbxmediatype_delete.changed is sameas False - name: test - script mediatypes module_defaults: @@ -316,59 +312,59 @@ type: script block: - - name: test - create new script mediatype - zabbix_mediatype: - script_name: /usr/local/bin/script.sh - register: zbxmediatype_script_new - - - assert: - that: zbxmediatype_script_new.changed is sameas True - - - name: test - create new script mediatype (again) - zabbix_mediatype: - script_name: /usr/local/bin/script.sh - register: zbxmediatype_script_new - - - assert: - that: zbxmediatype_script_new.changed is sameas False - - - name: test - update script mediatype with script parameters - zabbix_mediatype: - script_name: /usr/local/bin/script.sh - script_params: - - '-p test' - - '-q' - register: zbxmediatype_script_params - - - assert: - that: zbxmediatype_script_params.changed is sameas True - - - name: test - update script mediatype with script parameters (again) - zabbix_mediatype: - script_name: /usr/local/bin/script.sh - script_params: - - '-p test' - - '-q' - register: zbxmediatype_script_params - - - assert: - that: zbxmediatype_script_params.changed is sameas False - - - name: test - remove script mediatype parameters - zabbix_mediatype: - script_name: /usr/local/bin/script.sh - register: zbxmediatype_script_params_rev - - - assert: - that: zbxmediatype_script_params_rev.changed is sameas True - - - name: test - delete script mediatype - zabbix_mediatype: - state: absent - register: zbxmediatype_delete - - - assert: - that: zbxmediatype_delete.changed is sameas True + - name: test - create new script mediatype + community.zabbix.zabbix_mediatype: + script_name: /usr/local/bin/script.sh + register: zbxmediatype_script_new + + - ansible.builtin.assert: + that: zbxmediatype_script_new.changed is sameas True + + - name: test - create new script mediatype (again) + community.zabbix.zabbix_mediatype: + script_name: /usr/local/bin/script.sh + register: zbxmediatype_script_new + + - ansible.builtin.assert: + that: zbxmediatype_script_new.changed is sameas False + + - name: test - update script mediatype with script parameters + community.zabbix.zabbix_mediatype: + script_name: /usr/local/bin/script.sh + script_params: + - "-p test" + - "-q" + register: zbxmediatype_script_params + + - ansible.builtin.assert: + that: zbxmediatype_script_params.changed is sameas True + + - name: test - update script mediatype with script parameters (again) + community.zabbix.zabbix_mediatype: + script_name: /usr/local/bin/script.sh + script_params: + - "-p test" + - "-q" + register: zbxmediatype_script_params + + - ansible.builtin.assert: + that: zbxmediatype_script_params.changed is sameas False + + - name: test - remove script mediatype parameters + community.zabbix.zabbix_mediatype: + script_name: /usr/local/bin/script.sh + register: zbxmediatype_script_params_rev + + - ansible.builtin.assert: + that: zbxmediatype_script_params_rev.changed is sameas True + + - name: test - delete script mediatype + community.zabbix.zabbix_mediatype: + state: absent + register: zbxmediatype_delete + + - ansible.builtin.assert: + that: zbxmediatype_delete.changed is sameas True - name: test - sms mediatypes module_defaults: @@ -378,148 +374,63 @@ type: sms block: - - name: test - create new sms mediatype - zabbix_mediatype: - gsm_modem: /dev/ttyS0 - register: zbxmediatype_sms_new + - name: test - create new sms mediatype + community.zabbix.zabbix_mediatype: + gsm_modem: /dev/ttyS0 + register: zbxmediatype_sms_new - - assert: - that: zbxmediatype_sms_new.changed is sameas True + - ansible.builtin.assert: + that: zbxmediatype_sms_new.changed is sameas True - - name: test - create new sms mediatype (again) - zabbix_mediatype: - gsm_modem: /dev/ttyS0 - register: zbxmediatype_sms_new + - name: test - create new sms mediatype (again) + community.zabbix.zabbix_mediatype: + gsm_modem: /dev/ttyS0 + register: zbxmediatype_sms_new - - assert: - that: zbxmediatype_sms_new.changed is sameas False + - ansible.builtin.assert: + that: zbxmediatype_sms_new.changed is sameas False - - when: zabbix_version is version('3.4', '>=') - block: - name: test - update sms mediatype with concurrent settings - zabbix_mediatype: + community.zabbix.zabbix_mediatype: gsm_modem: /dev/ttyS0 max_sessions: 1 max_attempts: 3 attempt_interval: 30 register: zbxmediatype_sms_concur - - assert: + - ansible.builtin.assert: that: zbxmediatype_sms_concur.changed is sameas True - name: test - update sms mediatype with concurrent settings (again) - zabbix_mediatype: + community.zabbix.zabbix_mediatype: gsm_modem: /dev/ttyS0 max_sessions: 1 max_attempts: 3 attempt_interval: 30 register: zbxmediatype_sms_concur - - assert: + - ansible.builtin.assert: that: zbxmediatype_sms_concur.changed is sameas False - name: test - update sms mediatype with invalid max sessions (fail) - zabbix_mediatype: + community.zabbix.zabbix_mediatype: gsm_modem: /dev/ttyS0 max_sessions: 2 register: zbxmediatype_sms_fail ignore_errors: true - - assert: + - ansible.builtin.assert: that: zbxmediatype_sms_fail.failed is sameas True - - name: test - delete sms mediatype - zabbix_mediatype: - state: absent - register: zbxmediatype_delete + - name: test - delete sms mediatype + community.zabbix.zabbix_mediatype: + state: absent + register: zbxmediatype_delete - - assert: - that: zbxmediatype_delete.changed is sameas True - -- name: test - jabber mediatypes - when: zabbix_version is version('4.2', '<=') - module_defaults: - community.zabbix.zabbix_mediatype: - state: present - name: Example jabber - type: jabber - - block: - - name: test - create new jabber mediatype - zabbix_mediatype: - username: zabbix - password: Ex4mP!3 - register: zbxmediatype_jabber_new - - - assert: - that: zbxmediatype_jabber_new.changed is sameas True - - - name: test - create new jabber mediatype (again) - zabbix_mediatype: - username: zabbix - password: Ex4mP!3 - register: zbxmediatype_jabber_new - - - assert: - that: zbxmediatype_jabber_new.changed is sameas False - - - name: test - delete jabber mediatype - zabbix_mediatype: - state: absent - register: zbxmediatype_delete - - - assert: - that: zbxmediatype_delete.changed is sameas True - -- name: test - ez_texting mediatypes - when: zabbix_version is version('4.2', '<=') - module_defaults: - community.zabbix.zabbix_mediatype: - state: present - name: Example ez_texting - type: ez_texting - - block: - - name: test - create new ez_texting mediatype - zabbix_mediatype: - username: zabbix - password: Ex4mP!3 - message_text_limit: USA - register: zbxmediatype_ez_texting_new - - - assert: - that: zbxmediatype_ez_texting_new.changed is sameas True - - - name: test - create new ez_texting mediatype (again) - zabbix_mediatype: - username: zabbix - password: Ex4mP!3 - message_text_limit: USA - register: zbxmediatype_ez_texting_new - - - assert: - that: zbxmediatype_ez_texting_new.changed is sameas False - - - name: test - update ez_texting mediatype with text limit - zabbix_mediatype: - username: zabbix - password: Ex4mP!3 - message_text_limit: Canada - register: zbxmediatype_ez_texting_update - - - assert: - that: zbxmediatype_ez_texting_update.changed is sameas True - - - name: test - delete ez_texting mediatype - zabbix_mediatype: - state: absent - register: zbxmediatype_delete - - - assert: - that: zbxmediatype_delete.changed is sameas True + - ansible.builtin.assert: + that: zbxmediatype_delete.changed is sameas True - name: test - email mediatypes - when: zabbix_version is version('4.4', '>=') module_defaults: community.zabbix.zabbix_mediatype: state: present @@ -528,151 +439,150 @@ webhook_script: "return 'Hello, world!';" block: - - name: test - create new webhook mediatype - zabbix_mediatype: - register: zbxmediatype_webhook_new - - - assert: - that: zbxmediatype_webhook_new.changed is sameas True - - - name: test - create new webhook mediatype (again) - zabbix_mediatype: - register: zbxmediatype_webhook_new - - - assert: - that: zbxmediatype_webhook_new.changed is sameas False - - - name: test - update webhook mediatype with process_tags - zabbix_mediatype: - process_tags: true - register: zbxmediatype_webhook_tags - - - assert: - that: zbxmediatype_webhook_tags.changed is sameas True - - - name: test - update webhook mediatype with process_tags (again) - zabbix_mediatype: - process_tags: true - register: zbxmediatype_webhook_tags - - - assert: - that: zbxmediatype_webhook_tags.changed is sameas False - - # supported since 4.4 - - name: test - update webhook mediatype with description - zabbix_mediatype: - process_tags: true - description: My custom webhook mediatype - register: zbxmediatype_webhook_desc - - - assert: - that: zbxmediatype_webhook_desc.changed is sameas True - - - name: test - update webhook mediatype with description (again) - zabbix_mediatype: - process_tags: true - description: My custom webhook mediatype - register: zbxmediatype_webhook_desc - - - assert: - that: zbxmediatype_webhook_desc.changed is sameas False - - - name: test - update webhook mediatype with event_menu without name and url (fail) - zabbix_mediatype: - process_tags: true - description: My custom webhook mediatype - event_menu: true - register: zbxmediatype_webhook_eventmenu - ignore_errors: true - - - assert: - that: zbxmediatype_webhook_eventmenu.failed is sameas True - - - name: test - update webhook mediatype with event_menu - zabbix_mediatype: - process_tags: true - description: My custom webhook mediatype - event_menu: true - event_menu_name: Example entry name - event_menu_url: '{EVENT.TAGS.__message_link}' - register: zbxmediatype_webhook_eventmenu - - - assert: - that: zbxmediatype_webhook_eventmenu.changed is sameas True - - - name: test - update webhook mediatype with event_menu (again) - zabbix_mediatype: - process_tags: true - description: My custom webhook mediatype - event_menu: true - event_menu_name: Example entry name - event_menu_url: '{EVENT.TAGS.__message_link}' - register: zbxmediatype_webhook_eventmenu - - - assert: - that: zbxmediatype_webhook_eventmenu.changed is sameas False - - - name: test - reset webhook mediatype to default - zabbix_mediatype: - register: zbxmediatype_reset - - - assert: - that: zbxmediatype_reset.changed is sameas True - - - name: test - update webhook mediatype with webhook_params - zabbix_mediatype: - webhook_params: - - name: param1 - value: value1 - register: zbxmediatype_webhook_params - - - assert: - that: zbxmediatype_webhook_params.changed is sameas True - - - name: test - update webhook mediatype with webhook_params (again) - zabbix_mediatype: - webhook_params: - - name: param1 - value: value1 - register: zbxmediatype_webhook_params - - - assert: - that: zbxmediatype_webhook_params.changed is sameas False - - - name: test - update webhook mediatype with webhook_params (reorder) - zabbix_mediatype: - webhook_params: - - name: z.param2 - value: xyz - - name: param1 - value: value1 - - name: b.param3 - - name: a.param4 - value: abc - register: zbxmediatype_webhook_params - - - assert: - that: zbxmediatype_webhook_params.changed is sameas True - - - name: test - update webhook mediatype with webhook_params (reorder again) - zabbix_mediatype: - webhook_params: - - name: param1 - value: value1 - - name: a.param4 - value: abc - - name: b.param3 - - name: z.param2 - value: xyz - register: zbxmediatype_webhook_params - - - assert: - that: zbxmediatype_webhook_params.changed is sameas False - - - name: test - delete webhook mediatype - zabbix_mediatype: - state: absent - register: zbxmediatype_delete - - - assert: - that: zbxmediatype_delete.changed is sameas True + - name: test - create new webhook mediatype + community.zabbix.zabbix_mediatype: + register: zbxmediatype_webhook_new + + - ansible.builtin.assert: + that: zbxmediatype_webhook_new.changed is sameas True + + - name: test - create new webhook mediatype (again) + community.zabbix.zabbix_mediatype: + register: zbxmediatype_webhook_new + + - ansible.builtin.assert: + that: zbxmediatype_webhook_new.changed is sameas False + + - name: test - update webhook mediatype with process_tags + community.zabbix.zabbix_mediatype: + process_tags: true + register: zbxmediatype_webhook_tags + + - ansible.builtin.assert: + that: zbxmediatype_webhook_tags.changed is sameas True + + - name: test - update webhook mediatype with process_tags (again) + community.zabbix.zabbix_mediatype: + process_tags: true + register: zbxmediatype_webhook_tags + + - ansible.builtin.assert: + that: zbxmediatype_webhook_tags.changed is sameas False + + - name: test - update webhook mediatype with description + community.zabbix.zabbix_mediatype: + process_tags: true + description: My custom webhook mediatype + register: zbxmediatype_webhook_desc + + - ansible.builtin.assert: + that: zbxmediatype_webhook_desc.changed is sameas True + + - name: test - update webhook mediatype with description (again) + community.zabbix.zabbix_mediatype: + process_tags: true + description: My custom webhook mediatype + register: zbxmediatype_webhook_desc + + - ansible.builtin.assert: + that: zbxmediatype_webhook_desc.changed is sameas False + + - name: test - update webhook mediatype with event_menu without name and url (fail) + community.zabbix.zabbix_mediatype: + process_tags: true + description: My custom webhook mediatype + event_menu: true + register: zbxmediatype_webhook_eventmenu + ignore_errors: true + + - ansible.builtin.assert: + that: zbxmediatype_webhook_eventmenu.failed is sameas True + + - name: test - update webhook mediatype with event_menu + community.zabbix.zabbix_mediatype: + process_tags: true + description: My custom webhook mediatype + event_menu: true + event_menu_name: Example entry name + event_menu_url: "{EVENT.TAGS.__message_link}" + register: zbxmediatype_webhook_eventmenu + + - ansible.builtin.assert: + that: zbxmediatype_webhook_eventmenu.changed is sameas True + + - name: test - update webhook mediatype with event_menu (again) + community.zabbix.zabbix_mediatype: + process_tags: true + description: My custom webhook mediatype + event_menu: true + event_menu_name: Example entry name + event_menu_url: "{EVENT.TAGS.__message_link}" + register: zbxmediatype_webhook_eventmenu + + - ansible.builtin.assert: + that: zbxmediatype_webhook_eventmenu.changed is sameas False + + - name: test - reset webhook mediatype to default + community.zabbix.zabbix_mediatype: + register: zbxmediatype_reset + + - ansible.builtin.assert: + that: zbxmediatype_reset.changed is sameas True + + - name: test - update webhook mediatype with webhook_params + community.zabbix.zabbix_mediatype: + webhook_params: + - name: param1 + value: value1 + register: zbxmediatype_webhook_params + + - ansible.builtin.assert: + that: zbxmediatype_webhook_params.changed is sameas True + + - name: test - update webhook mediatype with webhook_params (again) + community.zabbix.zabbix_mediatype: + webhook_params: + - name: param1 + value: value1 + register: zbxmediatype_webhook_params + + - ansible.builtin.assert: + that: zbxmediatype_webhook_params.changed is sameas False + + - name: test - update webhook mediatype with webhook_params (reorder) + community.zabbix.zabbix_mediatype: + webhook_params: + - name: z.param2 + value: xyz + - name: param1 + value: value1 + - name: b.param3 + - name: a.param4 + value: abc + register: zbxmediatype_webhook_params + + - ansible.builtin.assert: + that: zbxmediatype_webhook_params.changed is sameas True + + - name: test - update webhook mediatype with webhook_params (reorder again) + community.zabbix.zabbix_mediatype: + webhook_params: + - name: param1 + value: value1 + - name: a.param4 + value: abc + - name: b.param3 + - name: z.param2 + value: xyz + register: zbxmediatype_webhook_params + + - ansible.builtin.assert: + that: zbxmediatype_webhook_params.changed is sameas False + + - name: test - delete webhook mediatype + community.zabbix.zabbix_mediatype: + state: absent + register: zbxmediatype_delete + + - ansible.builtin.assert: + that: zbxmediatype_delete.changed is sameas True diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_module_defaults_group/tasks/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_module_defaults_group/tasks/main.yml index 5b861810a..04b19f2d4 100644 --- a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_module_defaults_group/tasks/main.yml +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_module_defaults_group/tasks/main.yml @@ -7,11 +7,11 @@ state: present block: - name: Create host group - zabbix_group: + community.zabbix.zabbix_group: register: _grp - name: Create host - zabbix_host: + community.zabbix.zabbix_host: host_name: Example Host interfaces: - type: agent @@ -20,7 +20,7 @@ register: _host - name: Assert that resources were correctly created - assert: + ansible.builtin.assert: that: - _grp is changed - _host is changed @@ -33,16 +33,16 @@ state: absent block: - name: Delete host - zabbix_host: + community.zabbix.zabbix_host: host_name: Example Host register: _host - name: Delete host group - zabbix_group: + community.zabbix.zabbix_group: register: _grp - name: Assert that resources were correctly deleted - assert: + ansible.builtin.assert: that: - _grp is changed - _host is changed diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_proxy/tasks/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_proxy/tasks/main.yml index ee96e6e80..86ece24f3 100644 --- a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_proxy/tasks/main.yml +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_proxy/tasks/main.yml @@ -1,6 +1,6 @@ --- - name: test - create new passive Zabbix proxy server - zabbix_proxy: + community.zabbix.zabbix_proxy: proxy_name: zbxproxy_example01 description: Example Zabbix Proxy state: present @@ -13,11 +13,11 @@ register: zbxproxy_new - name: assert that proxy was created - assert: + ansible.builtin.assert: that: zbxproxy_new is changed - name: test - create same passive Zabbix proxy server - zabbix_proxy: + community.zabbix.zabbix_proxy: proxy_name: zbxproxy_example01 description: Example Zabbix Proxy state: present @@ -30,11 +30,11 @@ register: zbxproxy_existing - name: assert that nothing has been changed - assert: + ansible.builtin.assert: that: not zbxproxy_existing is changed - name: test - update Zabbix proxy server description - zabbix_proxy: + community.zabbix.zabbix_proxy: proxy_name: zbxproxy_example01 description: Example Zabbix Proxy desc state: present @@ -47,11 +47,11 @@ register: zbxproxy_desc_update - name: assert that description has been updated - assert: + ansible.builtin.assert: that: zbxproxy_desc_update is changed - name: test - update Zabbix proxy server interface - zabbix_proxy: + community.zabbix.zabbix_proxy: proxy_name: zbxproxy_example01 description: Example Zabbix Proxy desc state: present @@ -64,11 +64,11 @@ register: zbxproxy_interface_update - name: assert that interface has been updated - assert: + ansible.builtin.assert: that: zbxproxy_interface_update is changed - name: test - update Zabbix proxy server description & interface (again) - zabbix_proxy: + community.zabbix.zabbix_proxy: proxy_name: zbxproxy_example01 description: Example Zabbix Proxy desc state: present @@ -81,11 +81,11 @@ register: zbxproxy_desc_interface_update - name: assert that nothing has been changed - assert: + ansible.builtin.assert: that: not zbxproxy_desc_interface_update is changed - name: test - update Zabbix proxy server interface to use only ip - zabbix_proxy: + community.zabbix.zabbix_proxy: proxy_name: zbxproxy_example01 description: Example Zabbix Proxy desc state: present @@ -97,11 +97,11 @@ register: zbxproxy_interface_onlyip - name: assert that interface has been updated - assert: + ansible.builtin.assert: that: zbxproxy_interface_onlyip is changed - name: test - update Zabbix proxy server interface to use only ip again - zabbix_proxy: + community.zabbix.zabbix_proxy: proxy_name: zbxproxy_example01 description: Example Zabbix Proxy desc state: present @@ -113,11 +113,11 @@ register: zbxproxy_interface_onlyip_again - name: assert that nothing has been changed - assert: + ansible.builtin.assert: that: not zbxproxy_interface_onlyip_again is changed - name: test - update Zabbix proxy server interface to use only dns - zabbix_proxy: + community.zabbix.zabbix_proxy: proxy_name: zbxproxy_example01 description: Example Zabbix Proxy desc state: present @@ -129,11 +129,11 @@ register: zbxproxy_interface_onlydns - name: assert that interface has been updated - assert: + ansible.builtin.assert: that: zbxproxy_interface_onlydns is changed - name: test - update Zabbix proxy server interface to use only dns again - zabbix_proxy: + community.zabbix.zabbix_proxy: proxy_name: zbxproxy_example01 description: Example Zabbix Proxy desc state: present @@ -145,11 +145,11 @@ register: zbxproxy_interface_onlydns_again - name: assert that nothing has been changed - assert: + ansible.builtin.assert: that: not zbxproxy_interface_onlydns_again is changed - name: test - update Zabbix proxy server interface to fail - zabbix_proxy: + community.zabbix.zabbix_proxy: proxy_name: zbxproxy_example01 description: Example Zabbix Proxy desc state: present @@ -162,11 +162,11 @@ ignore_errors: true - name: assert that module has failed - assert: + ansible.builtin.assert: that: zbxproxy_interface_fail is failed - name: test - update Zabbix proxy server to be active - zabbix_proxy: + community.zabbix.zabbix_proxy: proxy_name: zbxproxy_example01 description: Example Zabbix Proxy state: present @@ -174,11 +174,11 @@ register: zbxproxy_active_update - name: assert that proxy was updated - assert: + ansible.builtin.assert: that: zbxproxy_active_update is changed - name: test - update Zabbix proxy server to be active (again) - zabbix_proxy: + community.zabbix.zabbix_proxy: proxy_name: zbxproxy_example01 description: Example Zabbix Proxy state: present @@ -186,41 +186,37 @@ register: zbxproxy_active_update_again - name: assert that nothing has been changed - assert: + ansible.builtin.assert: that: not zbxproxy_active_update_again is changed -# proxy_address available on zabbix 4.0 and above -- block: - - name: test - update Zabbix proxy server to be active and use proxy_address - zabbix_proxy: - proxy_name: zbxproxy_example01 - description: Example Zabbix Proxy - state: present - status: active - proxy_address: 10.1.1.0/24,zabbix.example.com - register: zbxproxy_active_proxyaddress - - - name: assert that proxy was updated - assert: - that: zbxproxy_active_proxyaddress is changed - - - name: test - update Zabbix proxy server to be active use proxy_address (again) - zabbix_proxy: - proxy_name: zbxproxy_example01 - description: Example Zabbix Proxy - state: present - status: active - proxy_address: 10.1.1.0/24,zabbix.example.com - register: zbxproxy_active_proxyaddress_again - - - name: assert that nothing has been changed - assert: - that: not zbxproxy_active_proxyaddress_again is changed - - when: zabbix_version != "3.0" +- name: test - update Zabbix proxy server to be active and use proxy_address + community.zabbix.zabbix_proxy: + proxy_name: zbxproxy_example01 + description: Example Zabbix Proxy + state: present + status: active + proxy_address: 10.1.1.0/24,zabbix.example.com + register: zbxproxy_active_proxyaddress + +- name: assert that proxy was updated + ansible.builtin.assert: + that: zbxproxy_active_proxyaddress is changed + +- name: test - update Zabbix proxy server to be active use proxy_address (again) + community.zabbix.zabbix_proxy: + proxy_name: zbxproxy_example01 + description: Example Zabbix Proxy + state: present + status: active + proxy_address: 10.1.1.0/24,zabbix.example.com + register: zbxproxy_active_proxyaddress_again + +- name: assert that nothing has been changed + ansible.builtin.assert: + that: not zbxproxy_active_proxyaddress_again is changed - name: test - update Zabbix proxy server to use encryption - zabbix_proxy: + community.zabbix.zabbix_proxy: proxy_name: zbxproxy_example01 description: Example Zabbix Proxy state: present @@ -232,11 +228,11 @@ register: zbxproxy_encryption - name: assert that encryption has been enabled - assert: + ansible.builtin.assert: that: zbxproxy_encryption is changed - name: test - update Zabbix proxy server to use encryption (again) - zabbix_proxy: + community.zabbix.zabbix_proxy: proxy_name: zbxproxy_example01 description: Example Zabbix Proxy state: present @@ -248,19 +244,11 @@ register: zbxproxy_encryption_again - name: assert that nothing has been changed - assert: - that: not zbxproxy_encryption_again is changed - when: zabbix_version < "6.0" - -# With Zabbix >= 6.0 tls_psk and tls_psk_identity cannot be read -# thus there is no way to check idempotency -- name: assert that nothing has been changed - assert: + ansible.builtin.assert: that: zbxproxy_encryption_again is changed - when: zabbix_version >= "6.0" - name: test - update Zabbix proxy server encryption settings - zabbix_proxy: + community.zabbix.zabbix_proxy: proxy_name: zbxproxy_example01 description: Example Zabbix Proxy state: present @@ -272,11 +260,11 @@ register: zbxproxy_encryption_update - name: assert that encryption has been updated - assert: + ansible.builtin.assert: that: zbxproxy_encryption_update is changed - name: test - update Zabbix proxy server back to being passive - zabbix_proxy: + community.zabbix.zabbix_proxy: proxy_name: zbxproxy_example01 description: Example Zabbix Proxy state: present @@ -289,25 +277,25 @@ register: zbxproxy_passive_update - name: assert that proxy was updated - assert: + ansible.builtin.assert: that: zbxproxy_passive_update is changed - name: test - delete Zabbix proxy server - zabbix_proxy: + community.zabbix.zabbix_proxy: proxy_name: zbxproxy_example01 state: absent register: zbxproxy_delete - name: assert that proxy has been deleted - assert: + ansible.builtin.assert: that: zbxproxy_delete is changed - name: test - delete Zabbix proxy server (again) - zabbix_proxy: + community.zabbix.zabbix_proxy: proxy_name: zbxproxy_example01 state: absent register: zbxproxy_delete_again - name: assert that nothing has been changed - assert: + ansible.builtin.assert: that: not zbxproxy_delete_again is changed diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_proxy_info/tasks/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_proxy_info/tasks/main.yml index a5feb2731..ddd101850 100644 --- a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_proxy_info/tasks/main.yml +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_proxy_info/tasks/main.yml @@ -1,6 +1,6 @@ --- - name: test - Create new Zabbix proxy - zabbix_proxy: + community.zabbix.zabbix_proxy: state: present proxy_name: ExampleProxy description: ExampleProxy @@ -12,12 +12,12 @@ dns: ExampleProxy.local register: create_proxy_result -- assert: +- ansible.builtin.assert: that: - create_proxy_result.changed is sameas true - name: test - Create new Zabbix host monitored by the proxy - zabbix_host: + community.zabbix.zabbix_host: state: present host_name: ExampleHost host_groups: @@ -33,33 +33,33 @@ port: "10050" register: create_host_result -- assert: +- ansible.builtin.assert: that: - create_host_result.changed is sameas true - name: test - Get zabbix proxy information - zabbix_proxy_info: + community.zabbix.zabbix_proxy_info: proxy_name: ExampleProxy proxy_hosts: true register: get_proxy_info_result -- assert: +- ansible.builtin.assert: that: - - get_proxy_info_result["zabbix_proxy"].host == "ExampleProxy" - - get_proxy_info_result["zabbix_proxy"].hosts | length > 0 - - get_proxy_info_result["zabbix_proxy"].hosts[0].host == "ExampleHost" - - get_proxy_info_result["zabbix_proxy"].interface | length > 0 - - get_proxy_info_result["zabbix_proxy"].interface.ip == "10.1.1.2" - - get_proxy_info_result["zabbix_proxy"].interface.useip == "1" - - get_proxy_info_result["zabbix_proxy"].interface.port == "10051" - - get_proxy_info_result["zabbix_proxy"].interface.dns == "ExampleProxy.local" + - get_proxy_info_result["zabbix_proxy"].host == "ExampleProxy" + - get_proxy_info_result["zabbix_proxy"].hosts | length > 0 + - get_proxy_info_result["zabbix_proxy"].hosts[0].host == "ExampleHost" + - get_proxy_info_result["zabbix_proxy"].interface | length > 0 + - get_proxy_info_result["zabbix_proxy"].interface.ip == "10.1.1.2" + - get_proxy_info_result["zabbix_proxy"].interface.useip == "1" + - get_proxy_info_result["zabbix_proxy"].interface.port == "10051" + - get_proxy_info_result["zabbix_proxy"].interface.dns == "ExampleProxy.local" - name: test - cleanup test Zabbix host - zabbix_host: + community.zabbix.zabbix_host: state: absent host_name: ExampleHost - name: test - cleanup test Zabbix proxy - zabbix_proxy: + community.zabbix.zabbix_proxy: state: absent proxy_name: ExampleProxy diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_regexp/meta/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_regexp/meta/main.yml new file mode 100644 index 000000000..acdb704c8 --- /dev/null +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_regexp/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - setup_zabbix diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_regexp/tasks/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_regexp/tasks/main.yml new file mode 100644 index 000000000..8e2afc02d --- /dev/null +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_regexp/tasks/main.yml @@ -0,0 +1,113 @@ +--- +- name: test - do not run tests with < Zabbix 4.0 + meta: end_play + when: zabbix_version is version('4.0', '<') + +- when: zabbix_version is version('6.0', '<') + name: Unsupport Zabbix version (<6.0) + block: + - name: test - fail to update regexp setting + community.zabbix.zabbix_regexp: + name: File systems for discovery + test_string: ext3 + expressions: + - expression: "^(btrfs|ext2|ext3|ext4|reiser|xfs|ffs|ufs|jfs|jfs2|vxfs|hfs|apfs|refs|ntfs|fat32|zfs)$" + - expression_type: result_is_true + ignore_errors: true + register: zbxauth_update + + - ansible.builtin.assert: + that: zbxauth_update.failed is sameas True + +- when: zabbix_version is version('6.0', '>=') + name: support Zabbix version (>=6.0) + block: + - name: test - try to update regexp (present) + community.zabbix.zabbix_regexp: + name: File systems for discovery + test_string: ext3 + expressions: + - expression: "^(btrfs|ext2|ext3|ext4|reiser|xfs|ffs|ufs|jfs|jfs2|vxfs|hfs|apfs|refs|ntfs|fat32|zfs)$" + expression_type: result_is_true + register: zbxregexp_update + + - name: assert that regexp was NOT updated + ansible.builtin.assert: + that: + - zbxregexp_update.changed is sameas False + + - name: test - try to delete regexp + community.zabbix.zabbix_regexp: + name: File systems for discovery + state: absent + register: zbxregexp_update + + - name: assert that regexp was deleted + ansible.builtin.assert: + that: + - zbxregexp_update.changed is sameas True + - zbxregexp_update.msg == "Successfully deleted regular expression setting." + + - name: test - try to create regexp + community.zabbix.zabbix_regexp: + name: File systems for discovery + test_string: ext3 + expressions: + - expression: "^(btrfs|ext2|ext3|ext4|reiser|xfs|ffs|ufs|jfs|jfs2|vxfs|hfs|apfs|refs|ntfs|fat32|zfs)$" + expression_type: result_is_true + register: zbxregexp_update + + - name: assert that regexp was created + ansible.builtin.assert: + that: + - zbxregexp_update.changed is sameas True + - zbxregexp_update.msg == "Successfully created regular expression setting." + + - name: test - try to update regexp + community.zabbix.zabbix_regexp: + name: File systems for discovery + test_string: ext3 + expressions: + - expression: "create" + expression_type: character_string_included + - expression: "update/delete" + expression_type: any_character_string_included + case_sensitive: true + exp_delimiter: "/" + - expression: "failed" + expression_type: character_string_not_included + - expression: "^(btrfs|ext2|ext3|ext4|reiser|xfs|ffs|ufs|jfs|jfs2|vxfs|hfs|apfs|refs|ntfs|fat32|zfs)$" + expression_type: result_is_true + - expression: "regexp" + expression_type: result_is_false + register: zbxregexp_update + + - name: assert that regexp was updated + ansible.builtin.assert: + that: + - zbxregexp_update.changed is sameas True + - zbxregexp_update.msg == "Successfully updated regular expression setting." + + - name: test - try to update regexp (will not update) + community.zabbix.zabbix_regexp: + name: File systems for discovery + test_string: ext3 + expressions: + - expression: "update/delete" + expression_type: any_character_string_included + case_sensitive: true + exp_delimiter: "/" + - expression: "create" + expression_type: character_string_included + - expression: "failed" + expression_type: character_string_not_included + - expression: "^(btrfs|ext2|ext3|ext4|reiser|xfs|ffs|ufs|jfs|jfs2|vxfs|hfs|apfs|refs|ntfs|fat32|zfs)$" + expression_type: result_is_true + - expression: "regexp" + expression_type: result_is_false + register: zbxregexp_update + + - name: assert that regexp was updated + ansible.builtin.assert: + that: + - zbxregexp_update.changed is sameas False diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_screen/tasks/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_screen/tasks/main.yml deleted file mode 100644 index 82d1e5f0e..000000000 --- a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_screen/tasks/main.yml +++ /dev/null @@ -1,149 +0,0 @@ ---- - -- name: ensure zabbix server is being monitored - community.zabbix.zabbix_host: - host_name: Zabbix server - status: enabled - -- name: "Screen got removed with 5.4" - block: - - name: test - Check if screen fails on Zabbix >= 5.4 - community.zabbix.zabbix_screen: - screens: - - screen_name: TestScreenFail54 - host_group: Zabbix servers - state: present - graph_names: - - 'Zabbix cache usage, % used' - - 'Zabbix internal process busy %' - graph_width: 200 - graph_height: 100 - graphs_in_row: 5 - register: result - ignore_errors: true - when: zabbix_version is version('5.4', '>=') - - - name: expect to fail - assert: - that: - - "result is failed" - when: zabbix_version is version('5.4', '>=') - - - name: End play if Zabbix >= 5.4 - meta: end_play - when: zabbix_version is version('5.4', '>=') - -- name: test - delete the screen again - community.zabbix.zabbix_screen: - screens: - - screen_name: TestScreen1 - state: absent - -# ################################################# -# Test screen creation -# ################################################# - -- name: test - Create a new screen - community.zabbix.zabbix_screen: - screens: - - screen_name: TestScreen1 - host_group: Zabbix servers - state: present - graph_names: - - 'Zabbix cache usage, % used' - - 'Zabbix internal process busy %' - graph_width: 200 - graph_height: 100 - graphs_in_row: 5 - register: result - -- assert: - that: - - result.changed - -- name: test - Create a new screen again - community.zabbix.zabbix_screen: - screens: - - screen_name: TestScreen1 - host_group: Zabbix servers - state: present - graph_names: - - 'Zabbix cache usage, % used' - - 'Zabbix internal process busy %' - graph_width: 200 - graph_height: 100 - graphs_in_row: 5 - register: result - -- assert: - that: - - not result.changed - -# ################################################# -# Test screen editing -# ################################################# - -- name: test - Adding new graph - community.zabbix.zabbix_screen: - screens: - - screen_name: TestScreen1 - host_group: Zabbix servers - state: present - graph_names: - - 'Zabbix cache usage, % used' - - 'Zabbix internal process busy %' - - 'Zabbix internal queues' - - 'Zabbix server performance' - - 'Zabbix data gathering process busy %' - graph_width: 200 - graph_height: 100 - graphs_in_row: 5 - register: result - -- assert: - that: - - result.changed - -- name: test - Removing graph - community.zabbix.zabbix_screen: - screens: - - screen_name: TestScreen1 - host_group: Zabbix servers - state: present - graph_names: - - 'Zabbix cache usage, % used' - - 'Zabbix internal queues' - graph_width: 200 - graph_height: 100 - graphs_in_row: 5 - register: result - -- assert: - that: - - result.changed - -# ################################################# -# Test screen deletion -# ################################################# - -- name: test - delete the screen - community.zabbix.zabbix_screen: - screens: - - screen_name: TestScreen1 - state: absent - register: result - -- assert: - that: - - result.changed - -- name: test - delete the screen again - community.zabbix.zabbix_screen: - screens: - - screen_name: TestScreen1 - state: absent - register: result - -- assert: - that: - - not result.changed diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_script/tasks/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_script/tasks/main.yml index fe5c40519..4c5ea8a4c 100644 --- a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_script/tasks/main.yml +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_script/tasks/main.yml @@ -1,347 +1,343 @@ --- -- name: test - do not run tests for Zabbix < 6.0 - meta: end_play - when: zabbix_version is version('6.0', '<') - - name: test - Test action operation script module_defaults: community.zabbix.zabbix_script: name: Test action operation script scope: action_operation script_type: webhook - command: 'return 0' + command: "return 0" description: "Test action operation script" state: present block: - - name: test - Create new action operation script to execute webhook check mode - zabbix_script: - check_mode: true - register: create_action_check_mode_result - - - assert: - that: - - create_action_check_mode_result.changed is sameas true - - - name: test - Create new action operation script to execute webhook - zabbix_script: - register: create_action_result - - - assert: - that: - - create_action_result.changed is sameas true - - - name: test - Create new action operation script to execute webhook again - zabbix_script: - register: create_action_again_result - - - assert: - that: - - create_action_again_result.changed is sameas false - - - name: test - Update action operation script to execute webhook with host group - zabbix_script: - host_group: 'Discovered hosts' - register: update_action_host_group_result - - - assert: - that: - - update_action_host_group_result.changed is sameas true - - - name: test - Update action operation script to execute webhook with host group again - zabbix_script: - host_group: 'Discovered hosts' - register: update_action_host_group_again_result - - - assert: - that: - - update_action_host_group_again_result.changed is sameas false - - - name: test - Update action operation script to execute webhook with parameters - zabbix_script: - host_group: 'Discovered hosts' - parameters: - - name: param_name1 - register: update_action_param_result - - - assert: - that: - - update_action_param_result.changed is sameas true - - - name: test - Update action operation script to execute webhook with parameters again - zabbix_script: - host_group: 'Discovered hosts' - parameters: - - name: param_name1 - register: update_action_param_again_result - - - assert: - that: - - update_action_param_again_result.changed is sameas false - - - name: test - Update action operation script to execute webhook with parameters and value - zabbix_script: - host_group: 'Discovered hosts' - parameters: - - name: param_name1 - - name: param_name2 - value: value2 - register: update_action_param_value_result - - - assert: - that: - - update_action_param_value_result.changed is sameas true - - - name: test - Update action operation script to execute webhook with parameters and value again - zabbix_script: - host_group: 'Discovered hosts' - parameters: - - name: param_name1 - - name: param_name2 - value: value2 - register: update_action_param_value_again_result - - - assert: - that: - - update_action_param_value_again_result.changed is sameas false - - - name: test - Update action operation script remove host group - zabbix_script: - parameters: - - name: param_name1 - - name: param_name2 - value: value2 - register: update_action_no_host_group_result - - - assert: - that: - - update_action_no_host_group_result.changed is sameas true - - - name: test - Update action operation script remove host group again - zabbix_script: - parameters: - - name: param_name1 - - name: param_name2 - value: value2 - register: update_action_no_host_group_again_result - - - assert: - that: - - update_action_no_host_group_again_result.changed is sameas false - - - name: test - Update action operation script to type Script - zabbix_script: - script_type: script - execute_on: zabbix_agent - command: echo 1 - register: update_action_script_result - - - assert: - that: - - update_action_script_result.changed is sameas true - - - name: test - Update action operation script to type Script again - zabbix_script: - script_type: script - execute_on: zabbix_agent - command: echo 1 - register: update_action_script_again_result - - - assert: - that: - - update_action_script_again_result.changed is sameas false - - - name: test - Update action operation script to execute on server - zabbix_script: - script_type: script - execute_on: zabbix_server - command: echo 1 - register: update_action_script_server_result - - - assert: - that: - - update_action_script_server_result.changed is sameas true - - - name: test - Update action operation script to execute on server again - zabbix_script: - script_type: script - execute_on: zabbix_server - command: echo 1 - register: update_action_script_server_again_result - - - assert: - that: - - update_action_script_server_again_result.changed is sameas false - - - name: test - Update action operation script to execute on server or proxy - zabbix_script: - script_type: script - execute_on: zabbix_server_proxy - command: echo 1 - register: update_action_script_server_proxy_result - - - assert: - that: - - update_action_script_server_proxy_result.changed is sameas true - - - name: test - Update action operation script to execute on server or proxy again - zabbix_script: - script_type: script - execute_on: zabbix_server_proxy - command: echo 1 - register: update_action_script_server_proxy_again_result - - - assert: - that: - - update_action_script_server_proxy_again_result.changed is sameas false - - - name: test - Update action operation script to type SSH - zabbix_script: - script_type: ssh - authtype: password - username: bla - password: blabla - command: echo 2 - register: update_action_script_ssh_result - - - assert: - that: - - update_action_script_ssh_result.changed is sameas true - - - name: test - Update action operation script to type SSH again - zabbix_script: - script_type: ssh - authtype: password - username: bla - password: blabla - command: echo 2 - register: update_action_script_ssh_again_result - - - assert: - that: - - update_action_script_ssh_again_result.changed is sameas false - - - name: test - Update action operation script type SSH key auth - zabbix_script: - script_type: ssh - authtype: public_key - username: bla - publickey: blabla - privatekey: blablabla - command: echo 3 - register: update_action_script_ssh_authkey_result - - - assert: - that: - - update_action_script_ssh_authkey_result.changed is sameas true - - - name: test - Update action operation script type SSH key auth again - zabbix_script: - script_type: ssh - authtype: public_key - username: bla - publickey: blabla - privatekey: blablabla - command: echo 3 - register: update_action_script_ssh_authkey_again_result - - - assert: - that: - - update_action_script_ssh_authkey_again_result.changed is sameas false - - - name: test - Update action operation script type SSH add port - zabbix_script: - script_type: ssh - authtype: public_key - username: bla - publickey: blabla - privatekey: blablabla - command: echo 3 - port: 222 - register: update_action_script_ssh_port_result - - - assert: - that: - - update_action_script_ssh_port_result.changed is sameas true - - - name: test - Update action operation script type SSH add port again - zabbix_script: - script_type: ssh - authtype: public_key - username: bla - publickey: blabla - privatekey: blablabla - command: echo 3 - port: 222 - register: update_action_script_ssh_port_again_result - - - assert: - that: - - update_action_script_ssh_port_again_result.changed is sameas false - - - name: test - Update action operation script to type Telnet - zabbix_script: - script_type: telnet - username: bla1 - password: blabla1 - command: echo 4 - port: 223 - register: update_action_script_telnet_result - - - assert: - that: - - update_action_script_telnet_result.changed is sameas true - - - name: test - Update action operation script to type Telnet again - zabbix_script: - script_type: telnet - username: bla1 - password: blabla1 - command: echo 4 - port: 223 - register: update_action_script_telnet_again_result - - - assert: - that: - - update_action_script_telnet_again_result.changed is sameas false - - - name: test - Update action operation script to type IPMI - zabbix_script: - script_type: ipmi - command: echo 5 - register: update_action_script_ipmi_result - - - assert: - that: - - update_action_script_ipmi_result.changed is sameas true - - - name: test - Update action operation script to type IPMI again - zabbix_script: - script_type: ipmi - command: echo 5 - register: update_action_script_ipmi_again_result - - - assert: - that: - - update_action_script_ipmi_again_result.changed is sameas false - - - name: test - Delete action operation script - zabbix_script: - state: absent - register: delete_action_result - - - assert: - that: - - delete_action_result.changed is sameas true - - - name: test - Delete action operation script again - zabbix_script: - state: absent - register: delete_action_again_result - - - assert: - that: - - delete_action_again_result.changed is sameas false + - name: test - Create new action operation script to execute webhook check mode + zabbix_script: + check_mode: true + register: create_action_check_mode_result + + - assert: + that: + - create_action_check_mode_result.changed is sameas true + + - name: test - Create new action operation script to execute webhook + zabbix_script: + register: create_action_result + + - assert: + that: + - create_action_result.changed is sameas true + + - name: test - Create new action operation script to execute webhook again + zabbix_script: + register: create_action_again_result + + - assert: + that: + - create_action_again_result.changed is sameas false + + - name: test - Update action operation script to execute webhook with host group + zabbix_script: + host_group: "Discovered hosts" + register: update_action_host_group_result + + - assert: + that: + - update_action_host_group_result.changed is sameas true + + - name: test - Update action operation script to execute webhook with host group again + zabbix_script: + host_group: "Discovered hosts" + register: update_action_host_group_again_result + + - assert: + that: + - update_action_host_group_again_result.changed is sameas false + + - name: test - Update action operation script to execute webhook with parameters + zabbix_script: + host_group: "Discovered hosts" + parameters: + - name: param_name1 + register: update_action_param_result + + - assert: + that: + - update_action_param_result.changed is sameas true + + - name: test - Update action operation script to execute webhook with parameters again + zabbix_script: + host_group: "Discovered hosts" + parameters: + - name: param_name1 + register: update_action_param_again_result + + - assert: + that: + - update_action_param_again_result.changed is sameas false + + - name: test - Update action operation script to execute webhook with parameters and value + zabbix_script: + host_group: "Discovered hosts" + parameters: + - name: param_name1 + - name: param_name2 + value: value2 + register: update_action_param_value_result + + - assert: + that: + - update_action_param_value_result.changed is sameas true + + - name: test - Update action operation script to execute webhook with parameters and value again + zabbix_script: + host_group: "Discovered hosts" + parameters: + - name: param_name1 + - name: param_name2 + value: value2 + register: update_action_param_value_again_result + + - assert: + that: + - update_action_param_value_again_result.changed is sameas false + + - name: test - Update action operation script remove host group + zabbix_script: + parameters: + - name: param_name1 + - name: param_name2 + value: value2 + register: update_action_no_host_group_result + + - assert: + that: + - update_action_no_host_group_result.changed is sameas true + + - name: test - Update action operation script remove host group again + zabbix_script: + parameters: + - name: param_name1 + - name: param_name2 + value: value2 + register: update_action_no_host_group_again_result + + - assert: + that: + - update_action_no_host_group_again_result.changed is sameas false + + - name: test - Update action operation script to type Script + zabbix_script: + script_type: script + execute_on: zabbix_agent + command: echo 1 + register: update_action_script_result + + - assert: + that: + - update_action_script_result.changed is sameas true + + - name: test - Update action operation script to type Script again + zabbix_script: + script_type: script + execute_on: zabbix_agent + command: echo 1 + register: update_action_script_again_result + + - assert: + that: + - update_action_script_again_result.changed is sameas false + + - name: test - Update action operation script to execute on server + zabbix_script: + script_type: script + execute_on: zabbix_server + command: echo 1 + register: update_action_script_server_result + + - assert: + that: + - update_action_script_server_result.changed is sameas true + + - name: test - Update action operation script to execute on server again + zabbix_script: + script_type: script + execute_on: zabbix_server + command: echo 1 + register: update_action_script_server_again_result + + - assert: + that: + - update_action_script_server_again_result.changed is sameas false + + - name: test - Update action operation script to execute on server or proxy + zabbix_script: + script_type: script + execute_on: zabbix_server_proxy + command: echo 1 + register: update_action_script_server_proxy_result + + - assert: + that: + - update_action_script_server_proxy_result.changed is sameas true + + - name: test - Update action operation script to execute on server or proxy again + zabbix_script: + script_type: script + execute_on: zabbix_server_proxy + command: echo 1 + register: update_action_script_server_proxy_again_result + + - assert: + that: + - update_action_script_server_proxy_again_result.changed is sameas false + + - name: test - Update action operation script to type SSH + zabbix_script: + script_type: ssh + authtype: password + username: bla + password: blabla + command: echo 2 + register: update_action_script_ssh_result + + - assert: + that: + - update_action_script_ssh_result.changed is sameas true + + - name: test - Update action operation script to type SSH again + zabbix_script: + script_type: ssh + authtype: password + username: bla + password: blabla + command: echo 2 + register: update_action_script_ssh_again_result + + - assert: + that: + - update_action_script_ssh_again_result.changed is sameas false + + - name: test - Update action operation script type SSH key auth + zabbix_script: + script_type: ssh + authtype: public_key + username: bla + publickey: blabla + privatekey: blablabla + command: echo 3 + register: update_action_script_ssh_authkey_result + + - assert: + that: + - update_action_script_ssh_authkey_result.changed is sameas true + + - name: test - Update action operation script type SSH key auth again + zabbix_script: + script_type: ssh + authtype: public_key + username: bla + publickey: blabla + privatekey: blablabla + command: echo 3 + register: update_action_script_ssh_authkey_again_result + + - assert: + that: + - update_action_script_ssh_authkey_again_result.changed is sameas false + + - name: test - Update action operation script type SSH add port + zabbix_script: + script_type: ssh + authtype: public_key + username: bla + publickey: blabla + privatekey: blablabla + command: echo 3 + port: 222 + register: update_action_script_ssh_port_result + + - assert: + that: + - update_action_script_ssh_port_result.changed is sameas true + + - name: test - Update action operation script type SSH add port again + zabbix_script: + script_type: ssh + authtype: public_key + username: bla + publickey: blabla + privatekey: blablabla + command: echo 3 + port: 222 + register: update_action_script_ssh_port_again_result + + - assert: + that: + - update_action_script_ssh_port_again_result.changed is sameas false + + - name: test - Update action operation script to type Telnet + zabbix_script: + script_type: telnet + username: bla1 + password: blabla1 + command: echo 4 + port: 223 + register: update_action_script_telnet_result + + - assert: + that: + - update_action_script_telnet_result.changed is sameas true + + - name: test - Update action operation script to type Telnet again + zabbix_script: + script_type: telnet + username: bla1 + password: blabla1 + command: echo 4 + port: 223 + register: update_action_script_telnet_again_result + + - assert: + that: + - update_action_script_telnet_again_result.changed is sameas false + + - name: test - Update action operation script to type IPMI + zabbix_script: + script_type: ipmi + command: echo 5 + register: update_action_script_ipmi_result + + - assert: + that: + - update_action_script_ipmi_result.changed is sameas true + + - name: test - Update action operation script to type IPMI again + zabbix_script: + script_type: ipmi + command: echo 5 + register: update_action_script_ipmi_again_result + + - assert: + that: + - update_action_script_ipmi_again_result.changed is sameas false + + - name: test - Delete action operation script + zabbix_script: + state: absent + register: delete_action_result + + - assert: + that: + - delete_action_result.changed is sameas true + + - name: test - Delete action operation script again + zabbix_script: + state: absent + register: delete_action_again_result + + - assert: + that: + - delete_action_again_result.changed is sameas false - name: test - Test manual host action script module_defaults: @@ -349,125 +345,125 @@ name: Test manual host action script scope: manual_host_action script_type: webhook - command: 'return 0' + command: "return 0" description: "Test manual host action script" state: present block: - - name: test - Create new manual host action script to execute webhook check mode - zabbix_script: - parameters: - - name: param_name1 - - name: param_name2 - value: value2 - check_mode: true - register: create_action_check_mode_result - - - assert: - that: - - create_action_check_mode_result.changed is sameas true - - - name: test - Create new manual host action script to execute webhook - zabbix_script: - parameters: - - name: param_name1 - - name: param_name2 - value: value2 - register: create_action_result - - - assert: - that: - - create_action_result.changed is sameas true - - - name: test - Create new manual host action script to execute webhook again - zabbix_script: - parameters: - - name: param_name1 - - name: param_name2 - value: value2 - register: create_action_again_result - - - assert: - that: - - create_action_again_result.changed is sameas false - - - name: test - Update manual host action script with menu path - zabbix_script: - menu_path: menu/submenu - register: update_action_result - - - assert: - that: - - update_action_result.changed is sameas true - - - name: test - Update manual host action script with menu path again - zabbix_script: - menu_path: menu/submenu - register: update_action_again_result - - - assert: - that: - - update_action_again_result.changed is sameas false - - - name: test - Update manual host action script with user group - zabbix_script: - menu_path: menu/submenu - user_group: Guests - register: update_action_usrgrp_result - - - assert: - that: - - update_action_usrgrp_result.changed is sameas true - - - name: test - Update manual host action script with user group again - zabbix_script: - menu_path: menu/submenu - user_group: Guests - register: update_action_usrgrp_again_result - - - assert: - that: - - update_action_usrgrp_again_result.changed is sameas false - - - name: test - Update manual host action script with Write permissions - zabbix_script: - host_access: write - register: update_action_host_perms_result - - - assert: - that: - - update_action_host_perms_result.changed is sameas true - - - name: test - Update manual host action script with Write permissions again - zabbix_script: - host_access: write - register: update_action_host_perms_again_result - - - assert: - that: - - update_action_host_perms_again_result.changed is sameas false - - - name: test - Update manual host action script with confirmation - zabbix_script: - confirmation: 'Are you sure?' - register: update_action_host_confirm_result - - - assert: - that: - - update_action_host_confirm_result.changed is sameas true - - - name: test - Update manual host action script with confirmation again - zabbix_script: - confirmation: 'Are you sure?' - register: update_action_host_confirm_again_result - - - assert: - that: - - update_action_host_confirm_again_result.changed is sameas false - - - name: test - Delete manual host action script - zabbix_script: - state: absent + - name: test - Create new manual host action script to execute webhook check mode + zabbix_script: + parameters: + - name: param_name1 + - name: param_name2 + value: value2 + check_mode: true + register: create_action_check_mode_result + + - assert: + that: + - create_action_check_mode_result.changed is sameas true + + - name: test - Create new manual host action script to execute webhook + zabbix_script: + parameters: + - name: param_name1 + - name: param_name2 + value: value2 + register: create_action_result + + - assert: + that: + - create_action_result.changed is sameas true + + - name: test - Create new manual host action script to execute webhook again + zabbix_script: + parameters: + - name: param_name1 + - name: param_name2 + value: value2 + register: create_action_again_result + + - assert: + that: + - create_action_again_result.changed is sameas false + + - name: test - Update manual host action script with menu path + zabbix_script: + menu_path: menu/submenu + register: update_action_result + + - assert: + that: + - update_action_result.changed is sameas true + + - name: test - Update manual host action script with menu path again + zabbix_script: + menu_path: menu/submenu + register: update_action_again_result + + - assert: + that: + - update_action_again_result.changed is sameas false + + - name: test - Update manual host action script with user group + zabbix_script: + menu_path: menu/submenu + user_group: Guests + register: update_action_usrgrp_result + + - assert: + that: + - update_action_usrgrp_result.changed is sameas true + + - name: test - Update manual host action script with user group again + zabbix_script: + menu_path: menu/submenu + user_group: Guests + register: update_action_usrgrp_again_result + + - assert: + that: + - update_action_usrgrp_again_result.changed is sameas false + + - name: test - Update manual host action script with Write permissions + zabbix_script: + host_access: write + register: update_action_host_perms_result + + - assert: + that: + - update_action_host_perms_result.changed is sameas true + + - name: test - Update manual host action script with Write permissions again + zabbix_script: + host_access: write + register: update_action_host_perms_again_result + + - assert: + that: + - update_action_host_perms_again_result.changed is sameas false + + - name: test - Update manual host action script with confirmation + zabbix_script: + confirmation: "Are you sure?" + register: update_action_host_confirm_result + + - assert: + that: + - update_action_host_confirm_result.changed is sameas true + + - name: test - Update manual host action script with confirmation again + zabbix_script: + confirmation: "Are you sure?" + register: update_action_host_confirm_again_result + + - assert: + that: + - update_action_host_confirm_again_result.changed is sameas false + + - name: test - Delete manual host action script + zabbix_script: + state: absent - name: test - Test manual event action script module_defaults: @@ -475,49 +471,49 @@ name: Test manual event action script scope: manual_event_action script_type: webhook - command: 'return 0' + command: "return 0" description: "Test manual event action script" state: present block: - - name: test - Create new manual event action script to execute webhook check mode - zabbix_script: - parameters: - - name: param_name1 - - name: param_name2 - value: value2 - check_mode: true - register: create_action_check_mode_result - - - assert: - that: - - create_action_check_mode_result.changed is sameas true - - - name: test - Create new manual event action script to execute webhook - zabbix_script: - parameters: - - name: param_name1 - - name: param_name2 - value: value2 - register: create_action_result - - - assert: - that: - - create_action_result.changed is sameas true - - - name: test - Create new manual event action script to execute webhook again - zabbix_script: - parameters: - - name: param_name1 - - name: param_name2 - value: value2 - diff: true - register: create_action_again_result - - - assert: - that: - - create_action_again_result.changed is sameas false - - - name: test - Delete manual host action script - zabbix_script: - state: absent + - name: test - Create new manual event action script to execute webhook check mode + zabbix_script: + parameters: + - name: param_name1 + - name: param_name2 + value: value2 + check_mode: true + register: create_action_check_mode_result + + - assert: + that: + - create_action_check_mode_result.changed is sameas true + + - name: test - Create new manual event action script to execute webhook + zabbix_script: + parameters: + - name: param_name1 + - name: param_name2 + value: value2 + register: create_action_result + + - assert: + that: + - create_action_result.changed is sameas true + + - name: test - Create new manual event action script to execute webhook again + zabbix_script: + parameters: + - name: param_name1 + - name: param_name2 + value: value2 + diff: true + register: create_action_again_result + + - assert: + that: + - create_action_again_result.changed is sameas false + + - name: test - Delete manual host action script + zabbix_script: + state: absent diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_service/tasks/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_service/tasks/main.yml index f4fc761b1..03501a43b 100644 --- a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_service/tasks/main.yml +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_service/tasks/main.yml @@ -1,305 +1,5 @@ --- -- when: zabbix_version is version('6.0', '<') - module_defaults: - community.zabbix.zabbix_service: - name: ExampleServiceForServiceModule - sla: 99.99 - sortorder: 0 - state: present - - block: - - name: "test - Create a new service with check_mode" - zabbix_service: - check_mode: true - register: create_service_check_mode_result - - - assert: - that: - - create_service_check_mode_result.changed is sameas true - - - name: "test - Create a new service" - zabbix_service: - register: create_service_result - - - assert: - that: - - create_service_result.changed is sameas true - - - name: "test - Create a new service (idempotency check)" - zabbix_service: - register: create_service_idempotency_check_result - - - assert: - that: - - create_service_idempotency_check_result.changed is sameas false - - - name: "test - Update a sla with check_mode" - zabbix_service: - sla: 99.999 - check_mode: true - register: update_sla_check_mode_result - - - assert: - that: - - update_sla_check_mode_result.changed is sameas true - - - name: "test - Update a sla" - zabbix_service: - sla: 99.999 - register: update_sla_result - - - assert: - that: - - update_sla_result.changed is sameas true - - - name: "test - Update a sla (idempotency check)" - zabbix_service: - sla: 99.999 - register: update_sla_idempotency_check_result - - - assert: - that: - - update_sla_idempotency_check_result.changed is sameas false - - - name: "test - Update a calculate_sla with check_mode" - zabbix_service: - sla: 99.999 - calculate_sla: true - check_mode: true - register: update_calculate_sla_check_mode_result - - - assert: - that: - - update_calculate_sla_check_mode_result.changed is sameas true - - - name: "test - Update a calculate_sla" - zabbix_service: - sla: 99.999 - calculate_sla: true - register: update_calculate_sla_result - - - assert: - that: - - update_calculate_sla_result.changed is sameas true - - - name: "test - Update a calculate_sla (idempotency check)" - zabbix_service: - sla: 99.999 - calculate_sla: true - register: update_calculate_sla_idempotency_check_result - - - assert: - 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: - sla: 99.999 - calculate_sla: true - trigger_host: "Zabbix server" - trigger_name: "{{ service_example_trigger }}" - check_mode: true - register: update_trigger_name_check_mode_result - - - assert: - that: - - update_trigger_name_check_mode_result.changed is sameas true - - - name: "test - Update trigger_host and trigger_name" - zabbix_service: - sla: 99.999 - calculate_sla: true - trigger_host: "Zabbix server" - trigger_name: "{{ service_example_trigger }}" - register: update_trigger_name_result - - - assert: - that: - - update_trigger_name_result.changed is sameas true - - - name: "test - Update trigger_host and trigger_name (idempotency check)" - zabbix_service: - sla: 99.999 - calculate_sla: true - trigger_host: "Zabbix server" - trigger_name: "{{ service_example_trigger }}" - register: update_trigger_name_idempotency_check_result - - - assert: - that: - - update_trigger_name_idempotency_check_result.changed is sameas false - - - name: "test - Update a algorithm of service with check_mode" - zabbix_service: - sla: 99.999 - calculate_sla: true - trigger_host: "Zabbix server" - trigger_name: "{{ service_example_trigger }}" - algorithm: all_children - check_mode: true - register: update_algorithm_check_mode_result - - - assert: - that: - - update_algorithm_check_mode_result.changed is sameas true - - - name: "test - Update a algorithm of service" - zabbix_service: - sla: 99.999 - calculate_sla: true - trigger_host: "Zabbix server" - trigger_name: "{{ service_example_trigger }}" - algorithm: all_children - register: update_algorithm_result - - - assert: - that: - - update_algorithm_result.changed is sameas true - - - name: "test - Update a algorithm of service (idempotency check)" - zabbix_service: - sla: 99.999 - calculate_sla: true - trigger_host: "Zabbix server" - trigger_name: "{{ service_example_trigger }}" - algorithm: all_children - register: update_algorithm_idempotency_check_result - - - assert: - that: - - update_algorithm_idempotency_check_result.changed is sameas false - - - name: "test - Create a new root service for parent test" - zabbix_service: - name: ExampleServiceForServiceModuleRoot - sla: 99.99 - register: create_child_service_result - - - assert: - that: - - create_child_service_result.changed is sameas true - - - name: "test - Update a parent of child service with check_mode" - zabbix_service: - name: ExampleServiceForServiceModule - sla: 99.999 - calculate_sla: true - trigger_host: "Zabbix server" - trigger_name: "{{ service_example_trigger }}" - algorithm: all_children - parent: ExampleServiceForServiceModuleRoot - check_mode: true - register: create_parent_child_service_check_mode_result - - - assert: - that: - - create_parent_child_service_check_mode_result.changed is sameas true - - - name: "test - Update a parent of child service" - zabbix_service: - name: ExampleServiceForServiceModule - sla: 99.999 - calculate_sla: true - trigger_host: "Zabbix server" - trigger_name: "{{ service_example_trigger }}" - algorithm: all_children - parent: ExampleServiceForServiceModuleRoot - register: create_parent_child_service_result - - - assert: - that: - - create_parent_child_service_result.changed is sameas true - - - name: "test - Update a parent of child service (idempotency check)" - zabbix_service: - name: ExampleServiceForServiceModule - sla: 99.999 - calculate_sla: true - trigger_host: "Zabbix server" - trigger_name: "{{ service_example_trigger }}" - algorithm: all_children - parent: ExampleServiceForServiceModuleRoot - register: create_parent_child_service_idempotency_check_result - - - assert: - that: - - create_parent_child_service_idempotency_check_result.changed is sameas false - - - name: "test - Remove ExampleServiceForServiceModule service with check_mode" - zabbix_service: - name: ExampleServiceForServiceModule - sla: 99.999 - state: absent - check_mode: true - register: remove_service_with_check_mode_result - - - assert: - that: - - remove_service_with_check_mode_result.changed is sameas true - - - name: "test - Remove ExampleServiceForServiceModule service" - zabbix_service: - name: ExampleServiceForServiceModule - sla: 99.999 - state: absent - register: remove_service_result - - - assert: - that: - - remove_service_result.changed is sameas true - - - name: "test - Remove ExampleServiceForServiceModule service (idempotency check)" - zabbix_service: - name: ExampleServiceForServiceModule - sla: 99.999 - state: absent - register: remove_service_idempotency_check_result - - - assert: - that: - - remove_service_idempotency_check_result.changed is sameas false - - - name: "test - Remove ExampleServiceForServiceModuleRoot service with check_mode" - zabbix_service: - name: ExampleServiceForServiceModuleRoot - sla: 99.999 - state: absent - check_mode: true - register: remove_root_service_with_check_mode_result - - - assert: - that: - - remove_root_service_with_check_mode_result.changed is sameas true - - - name: "test - Remove ExampleServiceForServiceModuleRoot service" - zabbix_service: - name: ExampleServiceForServiceModuleRoot - sla: 99.999 - state: absent - register: remove_root_service_result - - - assert: - that: - - remove_root_service_result.changed is sameas true - - - name: "test - Remove ExampleServiceForServiceModuleRoot service (idempotency check)" - zabbix_service: - name: ExampleServiceForServiceModuleRoot - sla: 99.999 - state: absent - register: remove_root_service_idempotency_check_result - - - assert: - that: - - remove_root_service_idempotency_check_result.changed is sameas false - -- name: test - service for Zabbix >= 6.0 - when: zabbix_version is version('6.0', '>=') +- name: test - service module_defaults: community.zabbix.zabbix_service: description: "Example Service for Service Module" @@ -310,59 +10,59 @@ block: - name: "test - Create a new service with check_mode" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule check_mode: true register: create_service_check_mode_result - - assert: + - ansible.builtin.assert: that: - create_service_check_mode_result.changed is sameas true - name: "test - Create a new service" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule register: create_service_result - - assert: + - ansible.builtin.assert: that: - create_service_result.changed is sameas true - name: "test - Create a new service (idempotency check)" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule register: create_service_idempotency_check_result - - assert: + - ansible.builtin.assert: that: - create_service_idempotency_check_result.changed is sameas false - name: "test - Update service add service tags" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule tags: - tag: TagName1 value: TagValue1 register: update_service_stags_result - - assert: + - ansible.builtin.assert: that: - update_service_stags_result.changed is sameas true - name: "test - Update service with service tags (idempotency check)" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule tags: - tag: TagName1 value: TagValue1 register: update_service_stags_idempotency_check_result - - assert: + - ansible.builtin.assert: that: - update_service_stags_idempotency_check_result.changed is sameas false - name: "test - Update service add more service tags" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule tags: - tag: TagName1 @@ -371,12 +71,12 @@ value: TagValue2 register: update_service_more_stags_result - - assert: + - ansible.builtin.assert: that: - update_service_more_stags_result.changed is sameas true - name: "test - Update service add more service tags (idempotency check)" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule tags: - tag: TagName1 @@ -385,41 +85,41 @@ value: TagValue2 register: update_service_more_stags_idempotency_check_result - - assert: + - ansible.builtin.assert: that: - update_service_more_stags_idempotency_check_result.changed is sameas false - name: "test - Update service remove service tags" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule tags: - tag: TagName2 value: TagValue2 register: update_service_less_stags_result - - assert: + - ansible.builtin.assert: that: - update_service_less_stags_result.changed is sameas true - name: "test - Update service remove service tags (idempotency check)" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule tags: - tag: TagName2 value: TagValue2 register: update_service_less_stags_idempotency_check_result - - assert: + - ansible.builtin.assert: that: - update_service_less_stags_idempotency_check_result.changed is sameas false - name: "test - Delete service" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule state: absent - name: "test - Create service with one problem tag" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule problem_tags: - tag: TagName1 @@ -427,12 +127,12 @@ value: TagValue1 register: create_service_with_ptag_result - - assert: + - ansible.builtin.assert: that: - create_service_with_ptag_result.changed is sameas true - name: "test - Create service with one problem tag (idempotency check)" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule problem_tags: - tag: TagName1 @@ -441,7 +141,7 @@ register: create_service_with_ptag_idempotency_check_result - name: "test - Update service with problem tag without operator" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule problem_tags: - tag: TagName1 @@ -451,12 +151,12 @@ value: TagValue2 register: update_service_with_ptag_woop_result - - assert: + - ansible.builtin.assert: that: - update_service_with_ptag_woop_result.changed is sameas true - name: "test - Update service with problem tag without operator (idempotency check)" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule problem_tags: - tag: TagName1 @@ -466,12 +166,12 @@ value: TagValue2 register: update_service_with_ptag_woop_idempotency_check_result - - assert: + - ansible.builtin.assert: that: - update_service_with_ptag_woop_idempotency_check_result.changed is sameas false - name: "test - Update service with problem tag with like operator" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule problem_tags: - tag: TagName1 @@ -484,12 +184,12 @@ value: TagValue3 register: update_service_with_ptag_wlikeop_result - - assert: + - ansible.builtin.assert: that: - update_service_with_ptag_wlikeop_result.changed is sameas true - name: "test - Update service with problem tag with like operator (idempotency check)" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule problem_tags: - tag: TagName1 @@ -502,12 +202,12 @@ value: TagValue3 register: update_service_with_ptag_wlikeop_idempotency_check_result - - assert: + - ansible.builtin.assert: that: - update_service_with_ptag_wlikeop_idempotency_check_result.changed is sameas false - name: "test - Update service with problem tag without operator and without value" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule problem_tags: - tag: TagName1 @@ -521,12 +221,12 @@ - tag: TagName4 register: update_service_with_ptag_woov_result - - assert: + - ansible.builtin.assert: that: - update_service_with_ptag_woov_result.changed is sameas true - name: "test - Update service with problem tag without operator and without value (idempotency check)" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule problem_tags: - tag: TagName1 @@ -540,12 +240,12 @@ - tag: TagName4 register: update_service_with_ptag_woov_idempotency_check_result - - assert: + - ansible.builtin.assert: that: - update_service_with_ptag_woov_idempotency_check_result.changed is sameas false - name: "test - Update service remove problem tags" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule problem_tags: - tag: TagName1 @@ -556,12 +256,12 @@ value: TagValue3 register: update_service_remove_tags_result - - assert: + - ansible.builtin.assert: that: - update_service_remove_tags_result.changed is sameas true - name: "test - Update service remove problem tags (idempotency check)" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule problem_tags: - tag: TagName1 @@ -572,237 +272,237 @@ value: TagValue3 register: update_service_remove_tags_idempotency_check_result - - assert: + - ansible.builtin.assert: that: - update_service_remove_tags_idempotency_check_result.changed is sameas false - name: "test - Update service remove all problem tags" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule register: update_service_remove_all_tags_result - - assert: + - ansible.builtin.assert: that: - update_service_remove_all_tags_result.changed is sameas true - name: "test - Update service remove all problem tags (idempotency check)" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule register: update_service_remove_all_tags_idempotency_check_result - - assert: + - ansible.builtin.assert: that: - update_service_remove_all_tags_idempotency_check_result.changed is sameas false - name: "test - Create a new child service" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleChildServiceForServiceModule sortorder: 10 parents: - ExampleServiceForServiceModule register: create_child_service_result - - assert: + - ansible.builtin.assert: that: - create_child_service_result.changed is sameas true - name: "test - Create a new child service (idempotency check)" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleChildServiceForServiceModule sortorder: 10 parents: - ExampleServiceForServiceModule register: create_child_service_idempotency_check_result - - assert: + - ansible.builtin.assert: that: - create_child_service_idempotency_check_result.changed is sameas false - name: "test - Update child service to remove parent" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleChildServiceForServiceModule parents: [] register: update_child_service_delete_parent_result - - assert: + - ansible.builtin.assert: that: - update_child_service_delete_parent_result.changed is sameas true - name: "test - Create a new parent service" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleParentServiceForServiceModule - name: "test - Delete child service" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleChildServiceForServiceModule state: absent - name: "test - Create a new child service with two parents" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleChildServiceForServiceModule parents: - ExampleServiceForServiceModule - ExampleParentServiceForServiceModule register: create_child_service_two_parents_result - - assert: + - ansible.builtin.assert: that: - create_child_service_two_parents_result.changed is sameas true - name: "test - Create a new child service with two parents (idempotency check)" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleChildServiceForServiceModule parents: - ExampleServiceForServiceModule - ExampleParentServiceForServiceModule register: create_child_service_two_parents_idempotency_check_result - - assert: + - ansible.builtin.assert: that: - create_child_service_two_parents_idempotency_check_result.changed is sameas false - name: "test - Remove one parent from new child service" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleChildServiceForServiceModule parents: - ExampleParentServiceForServiceModule register: update_child_service_remove_parent_result - - assert: + - ansible.builtin.assert: that: - update_child_service_remove_parent_result.changed is sameas true - name: "test - Remove one parent from new child service (idempotency check)" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleChildServiceForServiceModule parents: - ExampleParentServiceForServiceModule register: update_child_service_remove_parent_idempotency_check_result - - assert: + - ansible.builtin.assert: that: - update_child_service_remove_parent_idempotency_check_result.changed is sameas false - name: "test - Delete parent service 2" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleParentServiceForServiceModule state: absent - name: "test - Create parent service with child service" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleParentServiceForServiceModule children: - ExampleChildServiceForServiceModule register: create_parent_service_with_child_result - - assert: + - ansible.builtin.assert: that: - create_parent_service_with_child_result.changed is sameas true - name: "test - Create parent service with child service (idempotency check)" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleParentServiceForServiceModule children: - ExampleChildServiceForServiceModule register: create_parent_service_with_child_result_idempotency_check_result - - assert: + - ansible.builtin.assert: that: - create_parent_service_with_child_result_idempotency_check_result.changed is sameas false - name: "test - Create second chile service" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleChildServiceForServiceModule2 - name: "test - Update parent service with the second child service" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleParentServiceForServiceModule children: - ExampleChildServiceForServiceModule - ExampleChildServiceForServiceModule2 register: update_parent_service_with_second_child_result - - assert: + - ansible.builtin.assert: that: - update_parent_service_with_second_child_result.changed is sameas true - name: "test - Update parent service with the second child service (idempotency check)" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleParentServiceForServiceModule children: - ExampleChildServiceForServiceModule - ExampleChildServiceForServiceModule2 register: update_parent_service_with_second_child_result_idempotency_check_result - - assert: + - ansible.builtin.assert: that: - update_parent_service_with_second_child_result_idempotency_check_result.changed is sameas false - name: "test - Delete parent service" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleParentServiceForServiceModule state: absent - name: "test - Create parent service with two child services" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleParentServiceForServiceModule children: - ExampleChildServiceForServiceModule - ExampleChildServiceForServiceModule2 register: create_parent_service_with_two_children_result - - assert: + - ansible.builtin.assert: that: - create_parent_service_with_two_children_result.changed is sameas true - name: "test - Create parent service with child services (idempotency check)" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleParentServiceForServiceModule children: - ExampleChildServiceForServiceModule - ExampleChildServiceForServiceModule2 register: create_parent_service_with_two_children_idempotency_check_result - - assert: + - ansible.builtin.assert: that: - create_parent_service_with_two_children_idempotency_check_result.changed is sameas false - name: "test - Delete parent service" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleParentServiceForServiceModule state: absent - name: "test - Delete child service" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleChildServiceForServiceModule state: absent - name: "test - Delete child servicei 2" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleChildServiceForServiceModule2 state: absent - name: "test - Delete new service" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule state: absent register: delete_service_result - - assert: + - ansible.builtin.assert: that: - delete_service_result.changed is sameas true - name: "test - Delete new service (idempotency check)" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule state: absent register: delete_service_idempotency_check_result - - assert: + - ansible.builtin.assert: that: - delete_service_idempotency_check_result.changed is sameas false - name: "test - Create a new service with status rule" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule status_rules: - type: at_least_n_child_services_have_status_or_above @@ -811,12 +511,12 @@ new_status: not_classified register: create_service_sr_result - - assert: + - ansible.builtin.assert: that: - create_service_sr_result.changed is sameas true - name: "test - Create a new service with status rule (idempotency check)" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule status_rules: - type: at_least_n_child_services_have_status_or_above @@ -825,12 +525,12 @@ new_status: not_classified register: create_service_sr_idempotency_check_result - - assert: + - ansible.builtin.assert: that: - create_service_sr_idempotency_check_result.changed is sameas false - name: "test - Update service with the second status rule" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule status_rules: - type: at_least_n_child_services_have_status_or_above @@ -843,12 +543,12 @@ new_status: warning register: update_service_add_sr_result - - assert: + - ansible.builtin.assert: that: - update_service_add_sr_result.changed is sameas true - name: "test - Update service with the second status rule (idempotency check)" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule status_rules: - type: at_least_n_child_services_have_status_or_above @@ -861,12 +561,12 @@ new_status: warning register: update_service_add_sr_idempotency_check_result - - assert: + - ansible.builtin.assert: that: - update_service_add_sr_idempotency_check_result.changed is sameas false - name: "test - Update service remove status rule" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule status_rules: - type: at_least_npct_child_services_have_status_or_above @@ -875,12 +575,12 @@ new_status: warning register: update_service_remove_sr_result - - assert: + - ansible.builtin.assert: that: - update_service_remove_sr_result.changed is sameas true - name: "test - Update service remove status rule (idempotency check)" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule status_rules: - type: at_least_npct_child_services_have_status_or_above @@ -889,12 +589,12 @@ new_status: warning register: update_service_remove_sr_idempotency_check_result - - assert: + - ansible.builtin.assert: that: - update_service_remove_sr_idempotency_check_result.changed is sameas false - name: "test - Delete new service" - zabbix_service: + community.zabbix.zabbix_service: name: ExampleServiceForServiceModule state: absent register: delete_service_result diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_settings/meta/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_settings/meta/main.yml new file mode 100644 index 000000000..acdb704c8 --- /dev/null +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_settings/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - setup_zabbix diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_settings/tasks/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_settings/tasks/main.yml new file mode 100644 index 000000000..7be88158e --- /dev/null +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_settings/tasks/main.yml @@ -0,0 +1,332 @@ +--- +- name: test - Update zabbix settings (same as default) + community.zabbix.zabbix_settings: + alert_usrgrp: "Zabbix administrators" + auditlog_enabled: true + blink_period: "2m" + connect_timeout: "3s" + custom_color: false + default_inventory_mode: disabled + default_lang: en_US + default_theme: blue-theme + default_timezone: system + discovery_group: "Discovered hosts" + geomaps_attribution: "" + geomaps_max_zoom: false + geomaps_tile_provider: "OpenStreetMap.Mapnik" + geomaps_tile_url: "" + history_period: "24h" + iframe_sandboxing_enabled: true + iframe_sandboxing_exceptions: "" + item_test_timeout: "60s" + login_attempts: 5 + login_block: "30s" + max_in_table: 50 + max_overview_table_size: 50 + max_period: "2y" + media_type_test_timeout: "65s" + ok_ack_color: "009900" + ok_ack_style: true + ok_period: "5m" + ok_unack_color: "009900" + ok_unack_style: true + period_default: "1h" + problem_ack_color: "CC0000" + problem_ack_style: true + problem_unack_color: "CC0000" + problem_unack_style: true + report_test_timeout: "60s" + script_timeout: "60s" + search_limit: 1000 + server_check_interval: true + severity_color_0: "97AAB3" + severity_color_1: "7499FF" + severity_color_2: "FFC859" + severity_color_3: "FFA059" + severity_color_4: "E97659" + severity_color_5: "E45959" + severity_name_0: "Not classified" + severity_name_1: "Information" + severity_name_2: "Warning" + severity_name_3: "Average" + severity_name_4: "High" + severity_name_5: "Disaster" + show_technical_errors: false + snmptrap_logging: true + socket_timeout: "3s" + uri_valid_schemes: + - http + - https + - ftp + - file + - mailto + - tel + - ssh + frontend_url: "" + validate_uri_schemes: true + work_period: "1-5,09:00-18:00" + x_frame_options: "SAMEORIGIN" + register: zbx_settings + +- name: assert that settings was NOT updated + ansible.builtin.assert: + that: + - zbx_settings.changed is sameas False + +- when: zabbix_version is version('6.2', '>=') + name: support Zabbix version (>=6.2) + block: + - name: test - Zabbix settings (same as default) + community.zabbix.zabbix_settings: + vault_provider: HashiCorp_Vault + register: zbx_settings + + - name: assert that settings was NOT updated + ansible.builtin.assert: + that: + - zbx_settings.changed is sameas False + + - name: test - Update zabbix settings + community.zabbix.zabbix_settings: + vault_provider: CyberArk_Vault + register: zbx_settings + + - name: assert that settings was updated + ansible.builtin.assert: + that: + - zbx_settings.changed is sameas True + +- name: test - Update zabbix settings + community.zabbix.zabbix_settings: + alert_usrgrp: "0" + auditlog_enabled: false + blink_period: "10m" + connect_timeout: "30s" + custom_color: false + default_inventory_mode: automatic + default_lang: en_GB + default_theme: hc-dark + default_timezone: Asia/Tokyo + discovery_group: "Hypervisors" + geomaps_attribution: "hogehoge" + geomaps_max_zoom: true + geomaps_tile_provider: "another" + geomaps_tile_url: "" + history_period: "1w" + iframe_sandboxing_enabled: false + iframe_sandboxing_exceptions: "hogehoge" + item_test_timeout: "5m" + login_attempts: 30 + login_block: "5m" + max_in_table: 1000 + max_overview_table_size: 1000 + max_period: "1y" + media_type_test_timeout: "1m" + ok_ack_color: "0099AA" + ok_ack_style: false + ok_period: "10m" + ok_unack_color: "0099BB" + ok_unack_style: false + period_default: "2h" + problem_ack_color: "CC0000" + problem_ack_style: false + problem_unack_color: "CC0000" + problem_unack_style: false + report_test_timeout: "2m" + script_timeout: "2m" + search_limit: 10000 + server_check_interval: false + severity_color_0: "97AAAA" + severity_color_1: "7499BB" + severity_color_2: "FFC8CC" + severity_color_3: "FFA0DD" + severity_color_4: "E976EE" + severity_color_5: "E459FF" + severity_name_0: "Not classified(test)" + severity_name_1: "Information(test)" + severity_name_2: "Warning(test)" + severity_name_3: "Average(test)" + severity_name_4: "High(test)" + severity_name_5: "Disaster(test)" + show_technical_errors: true + snmptrap_logging: false + socket_timeout: "30s" + uri_valid_schemes: + - https + - ftp + - file + - mailto + - tel + - ssh + frontend_url: "https://www.zabbix.com/" + validate_uri_schemes: false + work_period: "1-5,09:00-18:00;1-5,22:00-23:00" + x_frame_options: "SAMEORIGIN(TEST)" + register: zbx_settings + +- name: assert that settings was updated + ansible.builtin.assert: + that: + - zbx_settings.changed is sameas True + +- name: test - Update zabbix settings (same setting) + community.zabbix.zabbix_settings: + alert_usrgrp: "0" + auditlog_enabled: false + blink_period: "10m" + connect_timeout: "30s" + custom_color: false + default_inventory_mode: automatic + default_lang: en_GB + default_theme: hc-dark + default_timezone: Asia/Tokyo + discovery_group: "Hypervisors" + geomaps_attribution: "hogehoge" + geomaps_max_zoom: true + geomaps_tile_provider: "another" + geomaps_tile_url: "" + history_period: "1w" + iframe_sandboxing_enabled: false + iframe_sandboxing_exceptions: "hogehoge" + item_test_timeout: "5m" + login_attempts: 30 + login_block: "5m" + max_in_table: 1000 + max_overview_table_size: 1000 + max_period: "1y" + media_type_test_timeout: "1m" + ok_ack_color: "0099AA" + ok_ack_style: false + ok_period: "10m" + ok_unack_color: "0099BB" + ok_unack_style: false + period_default: "2h" + problem_ack_color: "CC0000" + problem_ack_style: false + problem_unack_color: "CC0000" + problem_unack_style: false + report_test_timeout: "2m" + script_timeout: "2m" + search_limit: 10000 + server_check_interval: false + severity_color_0: "97AAAA" + severity_color_1: "7499BB" + severity_color_2: "FFC8CC" + severity_color_3: "FFA0DD" + severity_color_4: "E976EE" + severity_color_5: "E459FF" + severity_name_0: "Not classified(test)" + severity_name_1: "Information(test)" + severity_name_2: "Warning(test)" + severity_name_3: "Average(test)" + severity_name_4: "High(test)" + severity_name_5: "Disaster(test)" + show_technical_errors: true + snmptrap_logging: false + socket_timeout: "30s" + uri_valid_schemes: + - https + - ftp + - file + - mailto + - tel + - ssh + frontend_url: "https://www.zabbix.com/" + validate_uri_schemes: false + work_period: "1-5,09:00-18:00;1-5,22:00-23:00" + x_frame_options: "SAMEORIGIN(TEST)" + register: zbx_settings + +- name: assert that settings was NOT updated + ansible.builtin.assert: + that: + - zbx_settings.changed is sameas False + +- name: test - Update zabbix alert_usrgrp setting + community.zabbix.zabbix_settings: + alert_usrgrp: "No access to the frontend" + register: zbx_settings + +- name: assert that setting was updated + ansible.builtin.assert: + that: + - zbx_settings.changed is sameas True + +- name: test - Update zabbix alert_usrgrp setting (same parameter) + community.zabbix.zabbix_settings: + alert_usrgrp: "No access to the frontend" + register: zbx_settings + +- name: assert that settings was NOT updated + ansible.builtin.assert: + that: + - zbx_settings.changed is sameas False + +- name: test - Update zabbix settings (same as default) + community.zabbix.zabbix_settings: + alert_usrgrp: "Zabbix administrators" + auditlog_enabled: true + blink_period: "2m" + connect_timeout: "3s" + custom_color: false + default_inventory_mode: disabled + default_lang: en_US + default_theme: blue-theme + default_timezone: system + discovery_group: "Discovered hosts" + geomaps_attribution: "" + geomaps_max_zoom: false + geomaps_tile_provider: "OpenStreetMap.Mapnik" + geomaps_tile_url: "" + history_period: "24h" + iframe_sandboxing_enabled: true + iframe_sandboxing_exceptions: "" + item_test_timeout: "60s" + login_attempts: 5 + login_block: "30s" + max_in_table: 50 + max_overview_table_size: 50 + max_period: "2y" + media_type_test_timeout: "65s" + ok_ack_color: "009900" + ok_ack_style: true + ok_period: "5m" + ok_unack_color: "009900" + ok_unack_style: true + period_default: "1h" + problem_ack_color: "CC0000" + problem_ack_style: true + problem_unack_color: "CC0000" + problem_unack_style: true + report_test_timeout: "60s" + script_timeout: "60s" + search_limit: 1000 + server_check_interval: true + severity_color_0: "97AAB3" + severity_color_1: "7499FF" + severity_color_2: "FFC859" + severity_color_3: "FFA059" + severity_color_4: "E97659" + severity_color_5: "E45959" + severity_name_0: "Not classified" + severity_name_1: "Information" + severity_name_2: "Warning" + severity_name_3: "Average" + severity_name_4: "High" + severity_name_5: "Disaster" + show_technical_errors: false + snmptrap_logging: true + socket_timeout: "3s" + uri_valid_schemes: + - http + - https + - ftp + - file + - mailto + - tel + - ssh + frontend_url: "" + validate_uri_schemes: true + work_period: "1-5,09:00-18:00" + x_frame_options: "SAMEORIGIN" + register: zbx_settings diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template2_50_lower.xml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template2_50_lower.xml deleted file mode 100644 index 93a32f0c5..000000000 --- a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template2_50_lower.xml +++ /dev/null @@ -1,53 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<zabbix_export> - <date>2020-05-29T15:22:11Z</date> - <templates> - <template> - <template>ExampleHost</template> - <name>ExampleHost</name> - <description></description> - <groups> - <group> - <name>Templates</name> - </group> - <group> - <name>Templates/Applications</name> - </group> - </groups> - <macros> - <macro> - <macro>{$EXAMPLE_MACRO1}</macro> - <value>1000</value> - </macro> - <macro> - <macro>{$EXAMPLE_MACRO2}</macro> - <value>text</value> - </macro> - <macro> - <macro>{$EXAMPLE_MACRO3}</macro> - <value>text2</value> - </macro> - </macros> - <templates> - <template> - <name>Template App FTP Service</name> - </template> - <template> - <name>Template App Zabbix Proxy</name> - </template> - <template> - <name>Template App HTTP Service</name> - </template> - </templates> - </template> - </templates> - <version>3.0</version> - <groups> - <group> - <name>Templates</name> - </group> - <group> - <name>Templates/Applications</name> - </group> - </groups> -</zabbix_export> diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/tasks/import_54_higher.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/tasks/import_54_higher.yml deleted file mode 100644 index 8ce7a51e1..000000000 --- a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/tasks/import_54_higher.yml +++ /dev/null @@ -1,126 +0,0 @@ ---- - -# -# For Zabbix lower than 5.4 we test against the ExampleHost which was created in the -# main.yml tests. Due to changes in the Zabbix API (mainly because UUIDs) this is -# not possible for 5.4 onwards - so there we first delete the example hosts. -# - -- name: Delete Zabbix template. - zabbix_template: - template_name: ExampleHost - state: absent - register: delete_zabbix_template_result - -- assert: - that: - - delete_zabbix_template_result.changed is sameas true - -- name: Delete Zabbix template (idempotency check). - zabbix_template: - template_name: ExampleHost - state: absent - register: delete_zabbix_template_result - -- assert: - that: - - delete_zabbix_template_result.changed is sameas false - -# -# JSON Tests -# - -- block: - - name: Import Zabbix template from JSON file (idempotency check) - >= Zabbix 5.4. - zabbix_template: - template_json: "{{ lookup('file', 'template3_54_higher.json') }}" - state: present - register: import_template_json - - - name: Assert Zabbix template from JSON file (idempotency check) - >= Zabbix 5.4. - assert: - that: - - import_template_json.changed is sameas true - - - name: Import Zabbix template from JSON file with matching values (idempotency check) - >= Zabbix 5.4. - zabbix_template: - template_json: "{{ lookup('file', 'template3_54_higher.json') }}" - state: present - register: import_template_json - - - name: Assert Zabbix template from JSON file with matching values (idempotency check) - >= Zabbix 5.4. - assert: - that: - - import_template_json.changed is sameas false - -- name: Gather Zabbix template infomation. - zabbix_template_info: - template_name: ExampleHost - format: json - register: gather_template_result - -- block: - - assert: - that: - - gather_template_result.template_json[template_export_key][template_groups_key].0.name == 'Templates' - - gather_template_result.template_json[template_export_key][template_groups_key].1.name == 'Templates/Applications' - - gather_template_result.template_json[template_export_key].templates.0.templates.0.name == 'FTP Service' - - gather_template_result.template_json[template_export_key].templates.0.templates.1.name == 'Zabbix proxy health' - - gather_template_result.template_json[template_export_key].templates.0.macros.0.macro == '{$EXAMPLE_MACRO1}' - - gather_template_result.template_json[template_export_key].templates.0.macros.0.value == '1000' - - gather_template_result.template_json[template_export_key].templates.0.macros.1.macro == '{$EXAMPLE_MACRO2}' - - gather_template_result.template_json[template_export_key].templates.0.macros.1.value == 'text' - -- block: - - name: Import Zabbix template from JSON file with updated values. - zabbix_template: - template_json: "{{ lookup('file', 'template3-changed_54_higher.json') }}" - state: present - register: import_template_json - - - assert: - that: - - import_template_json.changed is sameas true - -- name: Gather Zabbix template infomation. - zabbix_template_info: - template_name: ExampleHost - format: json - register: gather_template_result - -- assert: - that: - - gather_template_result.template_json[template_export_key].templates.0.macros.0.macro == '{$EXAMPLE_MACRO1}' - - gather_template_result.template_json[template_export_key].templates.0.macros.0.value == '1000' - - gather_template_result.template_json[template_export_key].templates.0.macros.1.macro == '{$EXAMPLE_MACRO2}' - - gather_template_result.template_json[template_export_key].templates.0.macros.1.value == 'text' - - gather_template_result.template_json[template_export_key].templates.0.macros.2.macro == '{$EXAMPLE_MACRO3}' - - gather_template_result.template_json[template_export_key].templates.0.macros.2.value == 'text2' - -# -# xml -# - -- block: - - name: Import Zabbix template from XML file with updated values. - zabbix_template: - template_xml: "{{ lookup('file', 'template3_54_higher.xml') }}" - state: present - register: import_template_xml - - - assert: - that: - - import_template_xml.changed is sameas true - -- name: Gather Zabbix template infomation. - zabbix_template_info: - template_name: ExampleHost - format: json - register: gather_template_result - -# zabbix returns values sorted alphabetically so HTTP Service template comes before Zabbix Proxy template -- block: - - assert: - that: - - gather_template_result.template_json[template_export_key].templates.0.templates.0.name == 'FTP Service' - - gather_template_result.template_json[template_export_key].templates.0.templates.1.name == 'Zabbix proxy health' diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/tasks/import_54_lower.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/tasks/import_54_lower.yml deleted file mode 100644 index 48d180210..000000000 --- a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/tasks/import_54_lower.yml +++ /dev/null @@ -1,120 +0,0 @@ ---- - -# -# For Zabbix lower than 5.4 we test against the ExampleHost which was created in the -# main.yml tests. Due to changes in the Zabbix API (mainly because UUIDs) this is -# not possible for 5.4 onwards - so there we first delete the Example host. -# - -# -# JSON Tests -# - -- name: Gather Zabbix template infomation. - zabbix_template_info: - template_name: ExampleHost - format: json - register: gather_template_result - -- block: - - assert: - that: - - gather_template_result.template_json[template_export_key].groups.0.name == 'Templates' - - gather_template_result.template_json[template_export_key].groups.1.name == 'Templates/Applications' - - gather_template_result.template_json[template_export_key].templates.0.templates.0.name == 'Template App FTP Service' - - gather_template_result.template_json[template_export_key].templates.0.templates.1.name == 'Template App Zabbix Proxy' - - gather_template_result.template_json[template_export_key].templates.0.macros.0.macro == '{$EXAMPLE_MACRO1}' - - gather_template_result.template_json[template_export_key].templates.0.macros.0.value == '1000' - - gather_template_result.template_json[template_export_key].templates.0.macros.1.macro == '{$EXAMPLE_MACRO2}' - - gather_template_result.template_json[template_export_key].templates.0.macros.1.value == 'text' - -- block: - - name: Import Zabbix template from JSON file with matching values (idempotency check) - < Zabbix 5.4. - zabbix_template: - template_json: "{{ lookup('file', 'template1_50_lower.json') }}" - state: present - register: import_template_json - - - name: Assert Zabbix template from JSON file with matching values (idempotency check) - < Zabbix 5.4. - assert: - that: - - import_template_json.changed is sameas false - -- block: - - name: Import Zabbix template from JSON file with updated values. - zabbix_template: - template_json: "{{ lookup('file', 'template1-changed_50_lower.json') }}" - state: present - register: import_template_json - - - assert: - that: - - import_template_json.changed is sameas true - -- name: Gather Zabbix template infomation. - zabbix_template_info: - template_name: ExampleHost - format: json - register: gather_template_result - -- assert: - that: - - gather_template_result.template_json[template_export_key].templates.0.macros.0.macro == '{$EXAMPLE_MACRO1}' - - gather_template_result.template_json[template_export_key].templates.0.macros.0.value == '1000' - - gather_template_result.template_json[template_export_key].templates.0.macros.1.macro == '{$EXAMPLE_MACRO2}' - - gather_template_result.template_json[template_export_key].templates.0.macros.1.value == 'text' - - gather_template_result.template_json[template_export_key].templates.0.macros.2.macro == '{$EXAMPLE_MACRO3}' - - gather_template_result.template_json[template_export_key].templates.0.macros.2.value == 'text2' - -- name: Dump Zabbix template to JSON format. - zabbix_template: - template_name: ExampleHost - dump_format: json - state: dump - register: template_dump_result - -- assert: - that: - - template_dump_result.deprecations is defined - - template_dump_result.deprecations.0.version == '3.0.0' - -# -# XML Tests -# - -- block: - - name: Import Zabbix template from XML file with updated values. - zabbix_template: - template_xml: "{{ lookup('file', 'template2_50_lower.xml') }}" - state: present - register: import_template_xml - - - assert: - that: - - import_template_xml.changed is sameas true - -- name: Gather Zabbix template infomation. - zabbix_template_info: - template_name: ExampleHost - format: json - register: gather_template_result - -# zabbix returns values sorted alphabetically so HTTP Service template comes before Zabbix Proxy template -- block: - - assert: - that: - - gather_template_result.template_json[template_export_key].templates.0.templates.0.name == 'Template App FTP Service' - - gather_template_result.template_json[template_export_key].templates.0.templates.1.name == 'Template App HTTP Service' - - gather_template_result.template_json[template_export_key].templates.0.templates.2.name == 'Template App Zabbix Proxy' - -- name: Dump Zabbix template to XML format. - zabbix_template: - template_name: ExampleHost - dump_format: xml - state: dump - register: template_dump_result - -- assert: - that: - - template_dump_result.deprecations is defined - - template_dump_result.deprecations.0.version == '3.0.0' diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/tasks/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/tasks/main.yml index 66505f9a7..69aabe6b0 100644 --- a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/tasks/main.yml +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/tasks/main.yml @@ -1,197 +1,186 @@ --- - name: Create FTP Service Template - zabbix_template: + community.zabbix.zabbix_template: template_name: FTP Service template_groups: - - 'Templates' + - "Templates" state: present - name: Create a new Zabbix template (check mode). - zabbix_template: + community.zabbix.zabbix_template: template_name: ExampleHost template_groups: - - 'Templates' - - 'Templates/Applications' + - "Templates" + - "Templates/Applications" state: present register: create_zabbix_template_result check_mode: true -- assert: +- ansible.builtin.assert: that: - create_zabbix_template_result.changed is sameas true - name: Create a new Zabbix template. - zabbix_template: + community.zabbix.zabbix_template: template_name: ExampleHost template_groups: - - 'Templates' - - 'Templates/Applications' + - "Templates" + - "Templates/Applications" state: present register: create_zabbix_template_result -- assert: +- ansible.builtin.assert: that: - create_zabbix_template_result.changed is sameas true - name: Create a new Zabbix template (idempotency check). - zabbix_template: + community.zabbix.zabbix_template: template_name: ExampleHost template_groups: - - 'Templates' - - 'Templates/Applications' + - "Templates" + - "Templates/Applications" state: present register: create_zabbix_template_result -- assert: +- ansible.builtin.assert: that: - create_zabbix_template_result.changed is sameas false - name: Create a new Zabbix template with linked templates. - zabbix_template: + community.zabbix.zabbix_template: template_name: ExampleHostWithLinked template_groups: - - 'Templates' - - 'Templates/Applications' + - "Templates" + - "Templates/Applications" link_templates: - - "{{ 'Zabbix proxy health' if zabbix_version | float >= 5.4 else 'Template App Zabbix Proxy' }}" - - "{{ 'FTP Service' if zabbix_version | float >= 5.4 else 'Template App FTP Service' }}" + - "Zabbix proxy health" + - "FTP Service" state: present register: create_zabbix_template_linked_result -- assert: +- ansible.builtin.assert: that: - create_zabbix_template_linked_result.changed is sameas true - name: Gather Zabbix template infomation. - zabbix_template_info: + community.zabbix.zabbix_template_info: template_name: ExampleHost format: json register: gather_template_result - name: "test - Set key to template_export_key variable(This deals with the key being masked)" - set_fact: + ansible.builtin.set_fact: template_export_key: "{{ item }}" loop: "{{ gather_template_result.template_json.keys() | list }}" when: - item | regex_search('_export') -- assert: +- ansible.builtin.assert: that: - gather_template_result.template_json[template_export_key][template_groups_key].0.name == 'Templates' - gather_template_result.template_json[template_export_key][template_groups_key].1.name == 'Templates/Applications' - name: Add link_templates to Zabbix template. - zabbix_template: + community.zabbix.zabbix_template: template_name: ExampleHost template_groups: - - 'Templates' - - 'Templates/Applications' + - "Templates" + - "Templates/Applications" link_templates: - - "{{ 'Zabbix proxy health' if zabbix_version | float >= 5.4 else 'Template App Zabbix Proxy' }}" - - "{{ 'FTP Service' if zabbix_version | float >= 5.4 else 'Template App FTP Service' }}" + - "Zabbix proxy health" + - "FTP Service" state: present register: update_zabbix_template_result -- assert: +- ansible.builtin.assert: that: - update_zabbix_template_result.changed is sameas true - name: Add link_templates to Zabbix template (idempotency check). - zabbix_template: + community.zabbix.zabbix_template: template_name: ExampleHost template_groups: - - 'Templates' - - 'Templates/Applications' + - "Templates" + - "Templates/Applications" link_templates: - - "{{ 'Zabbix proxy health' if zabbix_version | float >= 5.4 else 'Template App Zabbix Proxy' }}" - - "{{ 'FTP Service' if zabbix_version | float >= 5.4 else 'Template App FTP Service' }}" + - "Zabbix proxy health" + - "FTP Service" state: present register: update_zabbix_template_result -- assert: +- ansible.builtin.assert: that: - update_zabbix_template_result.changed is sameas false - name: Gather Zabbix template infomation. - zabbix_template_info: + community.zabbix.zabbix_template_info: template_name: ExampleHost format: json register: gather_template_result -- when: zabbix_version is version('5.4', '<') - block: - - assert: - that: - - gather_template_result.template_json[template_export_key].groups.0.name == 'Templates' - - gather_template_result.template_json[template_export_key].groups.1.name == 'Templates/Applications' - - gather_template_result.template_json[template_export_key].templates.0.templates.0.name == 'Template App FTP Service' - - gather_template_result.template_json[template_export_key].templates.0.templates.1.name == 'Template App Zabbix Proxy' - -- when: zabbix_version is version('5.4', '>=') - block: - - assert: - that: - - gather_template_result.template_json[template_export_key][template_groups_key].0.name == 'Templates' - - gather_template_result.template_json[template_export_key][template_groups_key].1.name == 'Templates/Applications' - - gather_template_result.template_json[template_export_key].templates.0.templates.0.name == 'FTP Service' - - gather_template_result.template_json[template_export_key].templates.0.templates.1.name == 'Zabbix proxy health' +- ansible.builtin.assert: + that: + - gather_template_result.template_json[template_export_key][template_groups_key].0.name == 'Templates' + - gather_template_result.template_json[template_export_key][template_groups_key].1.name == 'Templates/Applications' + - gather_template_result.template_json[template_export_key].templates.0.templates.0.name == 'FTP Service' + - gather_template_result.template_json[template_export_key].templates.0.templates.1.name == 'Zabbix proxy health' - name: Add macros to Zabbix template. - zabbix_template: + community.zabbix.zabbix_template: template_name: ExampleHost template_groups: - - 'Templates' - - 'Templates/Applications' + - "Templates" + - "Templates/Applications" link_templates: - - "{{ 'Zabbix proxy health' if zabbix_version | float >= 5.4 else 'Template App Zabbix Proxy' }}" - - "{{ 'FTP Service' if zabbix_version | float >= 5.4 else 'Template App FTP Service' }}" + - "Zabbix proxy health" + - "FTP Service" macros: - - macro: '{$EXAMPLE_MACRO1}' + - macro: "{$EXAMPLE_MACRO1}" value: 1000 - - macro: '{$EXAMPLE_MACRO2}' - value: 'text' + - macro: "{$EXAMPLE_MACRO2}" + value: "text" state: present register: update_zabbix_template_result -- assert: +- ansible.builtin.assert: that: - update_zabbix_template_result.changed is sameas true - name: Add macros to Zabbix template (idempotency check). - zabbix_template: + community.zabbix.zabbix_template: template_name: ExampleHost template_groups: - - 'Templates' - - 'Templates/Applications' + - "Templates" + - "Templates/Applications" link_templates: - - "{{ 'Zabbix proxy health' if zabbix_version | float >= 5.4 else 'Template App Zabbix Proxy' }}" - - "{{ 'FTP Service' if zabbix_version | float >= 5.4 else 'Template App FTP Service' }}" + - "Zabbix proxy health" + - "FTP Service" macros: - - macro: '{$EXAMPLE_MACRO1}' + - macro: "{$EXAMPLE_MACRO1}" value: 1000 - - macro: '{$EXAMPLE_MACRO2}' - value: 'text' + - macro: "{$EXAMPLE_MACRO2}" + value: "text" state: present register: update_zabbix_template_result -- assert: +- ansible.builtin.assert: that: - update_zabbix_template_result.changed is sameas false - name: Add tags to Zabbix template. - zabbix_template: + community.zabbix.zabbix_template: template_name: ExampleHost template_groups: - - 'Templates' - - 'Templates/Applications' + - "Templates" + - "Templates/Applications" link_templates: - - "{{ 'Zabbix proxy health' if zabbix_version | float >= 5.4 else 'Template App Zabbix Proxy' }}" - - "{{ 'FTP Service' if zabbix_version | float >= 5.4 else 'Template App FTP Service' }}" + - "Zabbix proxy health" + - "FTP Service" macros: - - macro: '{$EXAMPLE_MACRO1}' + - macro: "{$EXAMPLE_MACRO1}" value: 1000 - - macro: '{$EXAMPLE_MACRO2}' - value: 'text' + - macro: "{$EXAMPLE_MACRO2}" + value: "text" tags: - tag: tag1 value: 1000 @@ -199,26 +188,24 @@ value: text state: present register: update_zabbix_template_result - when: zabbix_version is version('4.2', '>=') -- assert: +- ansible.builtin.assert: that: update_zabbix_template_result is changed - when: zabbix_version is version('4.2', '>=') - name: Add tags to Zabbix template (idempotency check). - zabbix_template: + community.zabbix.zabbix_template: template_name: ExampleHost template_groups: - - 'Templates' - - 'Templates/Applications' + - "Templates" + - "Templates/Applications" link_templates: - - "{{ 'Zabbix proxy health' if zabbix_version | float >= 5.4 else 'Template App Zabbix Proxy' }}" - - "{{ 'FTP Service' if zabbix_version | float >= 5.4 else 'Template App FTP Service' }}" + - "Zabbix proxy health" + - "FTP Service" macros: - - macro: '{$EXAMPLE_MACRO1}' + - macro: "{$EXAMPLE_MACRO1}" value: 1000 - - macro: '{$EXAMPLE_MACRO2}' - value: 'text' + - macro: "{$EXAMPLE_MACRO2}" + value: "text" tags: - tag: tag1 value: 1000 @@ -226,66 +213,159 @@ value: text state: present register: update_zabbix_template_result - when: zabbix_version is version('4.2', '>=') -- assert: +- ansible.builtin.assert: that: update_zabbix_template_result is not changed - when: zabbix_version is version('4.2', '>=') - name: Remove tags from Zabbix template. - zabbix_template: + community.zabbix.zabbix_template: template_name: ExampleHost template_groups: - - 'Templates' - - 'Templates/Applications' + - "Templates" + - "Templates/Applications" link_templates: - - "{{ 'Zabbix proxy health' if zabbix_version | float >= 5.4 else 'Template App Zabbix Proxy' }}" - - "{{ 'FTP Service' if zabbix_version | float >= 5.4 else 'Template App FTP Service' }}" + - "Zabbix proxy health" + - "FTP Service" macros: - - macro: '{$EXAMPLE_MACRO1}' + - macro: "{$EXAMPLE_MACRO1}" value: 1000 - - macro: '{$EXAMPLE_MACRO2}' - value: 'text' + - macro: "{$EXAMPLE_MACRO2}" + value: "text" tags: [] state: present register: update_zabbix_template_result - when: zabbix_version is version('4.2', '>=') -- assert: +- ansible.builtin.assert: that: update_zabbix_template_result is changed - when: zabbix_version is version('4.2', '>=') -# #### -# Import template tests -# #### +- name: Delete Zabbix template. + community.zabbix.zabbix_template: + template_name: ExampleHost + state: absent + register: delete_zabbix_template_result + +- ansible.builtin.assert: + that: + - delete_zabbix_template_result.changed is sameas true + +# +# JSON Tests +# + +- name: Import Zabbix template from JSON file (idempotency check). + community.zabbix.zabbix_template: + template_json: "{{ lookup('file', 'template3_54_higher.json') }}" + state: present + register: import_template_json -- include_tasks: import_54_lower.yml - when: zabbix_version is version('5.4', '<') +- name: Assert Zabbix template from JSON file (idempotency check). + ansible.builtin.assert: + that: + - import_template_json.changed is sameas true + +- name: Import Zabbix template from JSON file with matching values (idempotency check). + community.zabbix.zabbix_template: + template_json: "{{ lookup('file', 'template3_54_higher.json') }}" + state: present + register: import_template_json -- include_tasks: import_54_higher.yml - when: zabbix_version is version('5.4', '>=') +- name: Assert Zabbix template from JSON file with matching values (idempotency check). + ansible.builtin.assert: + that: + - import_template_json.changed is sameas false + +- name: Gather Zabbix template infomation. + community.zabbix.zabbix_template_info: + template_name: ExampleHost + format: json + register: gather_template_result + +- block: + - ansible.builtin.assert: + that: + - gather_template_result.template_json[template_export_key][template_groups_key].0.name == 'Templates' + - gather_template_result.template_json[template_export_key][template_groups_key].1.name == 'Templates/Applications' + - gather_template_result.template_json[template_export_key].templates.0.templates.0.name == 'FTP Service' + - gather_template_result.template_json[template_export_key].templates.0.templates.1.name == 'Zabbix proxy health' + - gather_template_result.template_json[template_export_key].templates.0.macros.0.macro == '{$EXAMPLE_MACRO1}' + - gather_template_result.template_json[template_export_key].templates.0.macros.0.value == '1000' + - gather_template_result.template_json[template_export_key].templates.0.macros.1.macro == '{$EXAMPLE_MACRO2}' + - gather_template_result.template_json[template_export_key].templates.0.macros.1.value == 'text' + +- name: Import Zabbix template from JSON file with updated values. + community.zabbix.zabbix_template: + template_json: "{{ lookup('file', 'template3-changed_54_higher.json') }}" + state: present + register: import_template_json + +- ansible.builtin.assert: + that: + - import_template_json.changed is sameas true + +- name: Gather Zabbix template infomation. + community.zabbix.zabbix_template_info: + template_name: ExampleHost + format: json + register: gather_template_result + +- ansible.builtin.assert: + that: + - gather_template_result.template_json[template_export_key].templates.0.macros.0.macro == '{$EXAMPLE_MACRO1}' + - gather_template_result.template_json[template_export_key].templates.0.macros.0.value == '1000' + - gather_template_result.template_json[template_export_key].templates.0.macros.1.macro == '{$EXAMPLE_MACRO2}' + - gather_template_result.template_json[template_export_key].templates.0.macros.1.value == 'text' + - gather_template_result.template_json[template_export_key].templates.0.macros.2.macro == '{$EXAMPLE_MACRO3}' + - gather_template_result.template_json[template_export_key].templates.0.macros.2.value == 'text2' + +# +# xml +# + +- block: + - name: Import Zabbix template from XML file with updated values. + community.zabbix.zabbix_template: + template_xml: "{{ lookup('file', 'template3_54_higher.xml') }}" + state: present + register: import_template_xml + + - ansible.builtin.assert: + that: + - import_template_xml.changed is sameas true + +- name: Gather Zabbix template infomation. + community.zabbix.zabbix_template_info: + template_name: ExampleHost + format: json + register: gather_template_result + +# zabbix returns values sorted alphabetically so HTTP Service template comes before Zabbix Proxy template +- block: + - ansible.builtin.assert: + that: + - gather_template_result.template_json[template_export_key].templates.0.templates.0.name == 'FTP Service' + - gather_template_result.template_json[template_export_key].templates.0.templates.1.name == 'Zabbix proxy health' # # Cleanup again # - name: Delete Zabbix template. - zabbix_template: + community.zabbix.zabbix_template: template_name: ExampleHost state: absent register: delete_zabbix_template_result -- assert: +- ansible.builtin.assert: that: - delete_zabbix_template_result.changed is sameas true - name: Delete Zabbix template (idempotency check). - zabbix_template: + community.zabbix.zabbix_template: template_name: ExampleHost state: absent register: delete_zabbix_template_result -- assert: +- ansible.builtin.assert: that: - delete_zabbix_template_result.changed is sameas false @@ -293,38 +373,36 @@ # Unicode stuff # -- when: zabbix_version is version('5.0', '>=') - block: - # The test if decode Unicode correctly and to be imported the template. - # https://github.com/ansible-collections/community.zabbix/issues/314 - - name: Import Zabbix template from JSON file with unicode. - zabbix_template: - template_json: "{{ lookup('file', 'template1_50_higher_decode_unicode.json') }}" - state: present - register: import_template_json +# The test if decode Unicode correctly and to be imported the template. +# https://github.com/ansible-collections/community.zabbix/issues/314 +- name: Import Zabbix template from JSON file with unicode. + community.zabbix.zabbix_template: + template_json: "{{ lookup('file', 'template1_50_higher_decode_unicode.json') }}" + state: present + register: import_template_json - - name: Gather Zabbix template infomation. - zabbix_template_info: - template_name: ExampleTemplate314 - format: json - register: gather_template_result +- name: Gather Zabbix template infomation. + community.zabbix.zabbix_template_info: + template_name: ExampleTemplate314 + format: json + register: gather_template_result - - assert: - that: - - import_template_json.changed is sameas true - - gather_template_result.template_json.zabbix_export.templates.0.description == "\u30c6\u30b9\u30c8\u30b3\u30e1\u30f3\u30c8" +- ansible.builtin.assert: + that: + - import_template_json.changed is sameas true + - gather_template_result.template_json.zabbix_export.templates.0.description == "\u30c6\u30b9\u30c8\u30b3\u30e1\u30f3\u30c8" - - name: Delete Zabbix template. - zabbix_template: - template_name: ExampleTemplate314 - state: absent - register: delete_zabbix_template_result +- name: Delete Zabbix template. + community.zabbix.zabbix_template: + template_name: ExampleTemplate314 + state: absent + register: delete_zabbix_template_result - - assert: - that: - - delete_zabbix_template_result.changed is sameas true +- ansible.builtin.assert: + that: + - delete_zabbix_template_result.changed is sameas true - name: Clean up ExampleHostWithLinked template - zabbix_template: + community.zabbix.zabbix_template: template_name: ExampleHostWithLinked state: absent diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template_info/tasks/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template_info/tasks/main.yml index 3146c04b3..ae790f1f9 100644 --- a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template_info/tasks/main.yml +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template_info/tasks/main.yml @@ -1,48 +1,48 @@ --- - name: "test - Prepare integration tests for zabbix_template_info module" - zabbix_template: + community.zabbix.zabbix_template: template_name: ExampleTemplateForTempleteInfoModule template_groups: - Templates state: present register: prepare_result -- assert: +- ansible.builtin.assert: that: - prepare_result.changed is sameas true - name: "test - Fetch template info as a JSON format from Zabbix Server" - zabbix_template_info: + community.zabbix.zabbix_template_info: template_name: ExampleTemplateForTempleteInfoModule format: json register: fetch_template_json_format_result - name: "test - Set key to template_export_key variable(This deals with the key being masked)" - set_fact: + ansible.builtin.set_fact: template_export_key: "{{ item }}" loop: "{{ fetch_template_json_format_result.template_json.keys() | list }}" when: - item | regex_search('_export') -- assert: +- ansible.builtin.assert: that: - fetch_template_json_format_result.template_json[template_export_key].date is defined when: zabbix_version is version('6.2', '<=') -- assert: +- ansible.builtin.assert: that: - fetch_template_json_format_result.template_json[template_export_key][template_groups_key].0.name == "Templates" - fetch_template_json_format_result.template_json[template_export_key].templates.0.name == "ExampleTemplateForTempleteInfoModule" - fetch_template_json_format_result.template_json[template_export_key].templates.0.template == "ExampleTemplateForTempleteInfoModule" - name: "test - Fetch template info as a JSON format with omit_date parameter from Zabbix Server" - zabbix_template_info: + community.zabbix.zabbix_template_info: template_name: ExampleTemplateForTempleteInfoModule format: json omit_date: true register: fetch_template_json_format_omit_date_result -- assert: +- ansible.builtin.assert: that: - fetch_template_json_format_omit_date_result.template_json[template_export_key].date is not defined - fetch_template_json_format_omit_date_result.template_json[template_export_key][template_groups_key].0.name == "Templates" @@ -50,66 +50,62 @@ - fetch_template_json_format_omit_date_result.template_json[template_export_key].templates.0.template == "ExampleTemplateForTempleteInfoModule" - name: "test - Fetch template info as a XML format from Zabbix Server" - zabbix_template_info: + community.zabbix.zabbix_template_info: template_name: ExampleTemplateForTempleteInfoModule format: xml register: fetch_template_xml_format_result -- assert: +- ansible.builtin.assert: that: - fetch_template_xml_format_result.template_xml | regex_search('<date>.*</date>') is defined - fetch_template_xml_format_result.template_xml | regex_search('</date><groups><group><name>Templates</name></group></groups><templates>') is defined - fetch_template_xml_format_result.template_xml | regex_search('<templates><template><template>ExampleTemplateForTempleteInfoModule</template><name>ExampleTemplateForTempleteInfoModule</name><groups><group><name>Templates</name></group></groups></template></templates>') is defined - name: "test - Fetch template info as a XML format with omit_date parameter from Zabbix Server" - zabbix_template_info: + community.zabbix.zabbix_template_info: template_name: ExampleTemplateForTempleteInfoModule format: xml omit_date: true register: fetch_template_xml_format_omit_date_result -- assert: +- ansible.builtin.assert: that: - fetch_template_xml_format_omit_date_result.template_xml | regex_search('<date>.*</date>') is none - fetch_template_xml_format_omit_date_result.template_xml | regex_search('</date><groups><group><name>Templates</name></group></groups><templates>') is defined - fetch_template_xml_format_omit_date_result.template_xml | regex_search('<templates><template><template>ExampleTemplateForTempleteInfoModule</template><name>ExampleTemplateForTempleteInfoModule</name><groups><group><name>Templates</name></group></groups></template></templates>') is defined - name: "test - Fetch template info as a YAML format from Zabbix Server" - zabbix_template_info: + community.zabbix.zabbix_template_info: template_name: ExampleTemplateForTempleteInfoModule format: yaml register: fetch_template_yaml_format_result - when: zabbix_version is version('5.2', '>=') -- assert: +- ansible.builtin.assert: that: - fetch_template_yaml_format_result.template_yaml | regex_search('date: .+') is defined - fetch_template_yaml_format_result.template_yaml | regex_search('name: Templates') is defined - fetch_template_yaml_format_result.template_yaml | regex_search('template: ExampleTemplateForTempleteInfoModule') is defined - when: zabbix_version is version('5.2', '>=') - name: "test - Fetch template info as a YAML format with omit_date parameter from Zabbix Server" - zabbix_template_info: + community.zabbix.zabbix_template_info: template_name: ExampleTemplateForTempleteInfoModule format: yaml omit_date: true register: fetch_template_yaml_format_omit_date_result - when: zabbix_version is version('5.2', '>=') -- assert: +- ansible.builtin.assert: that: - fetch_template_yaml_format_result.template_yaml | regex_search('date: .+') is not defined - fetch_template_yaml_format_result.template_yaml | regex_search('name: Templates') is defined - fetch_template_yaml_format_result.template_yaml | regex_search('template: ExampleTemplateForTempleteInfoModule') is defined - when: zabbix_version is version('5.2', '>=') - name: "test - Fetch template info with none format from Zabbix Server" - zabbix_template_info: + community.zabbix.zabbix_template_info: template_name: ExampleTemplateForTempleteInfoModule format: none register: fetch_template_none_format_result -- assert: +- ansible.builtin.assert: that: - fetch_template_none_format_result.template_id is defined - fetch_template_none_format_result.template_json is not defined diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_templategroup/meta/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_templategroup/meta/main.yml new file mode 100644 index 000000000..acdb704c8 --- /dev/null +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_templategroup/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - setup_zabbix diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_templategroup/tasks/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_templategroup/tasks/main.yml new file mode 100644 index 000000000..c04c20497 --- /dev/null +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_templategroup/tasks/main.yml @@ -0,0 +1,59 @@ +--- +- name: test - do not run tests for Zabbix < 6.2 + meta: end_play + when: zabbix_version is version('6.2', '<') + +- name: test - create new Zabbix template group + community.zabbix.zabbix_templategroup: + template_groups: + - zbxtempgrp_example_group01 + state: present + register: zbxtempgrp_new + +- name: assert that group was created + ansible.builtin.assert: + that: zbxtempgrp_new is changed + +- name: test - create same Zabbix template group once again + community.zabbix.zabbix_templategroup: + template_groups: + - zbxtempgrp_example_group01 + state: present + register: zbxtempgrp_existing + +- name: assert that nothing has been changed + ansible.builtin.assert: + that: not zbxtempgrp_existing is changed + +- name: test - attempt to create new Zabbix template group matching name of default Zabbix template group + community.zabbix.zabbix_templategroup: + template_groups: + - Templates + state: present + register: zbxtempgrp_default_existing + +- name: assert that nothing has been changed + ansible.builtin.assert: + that: not zbxtempgrp_default_existing is changed + +- name: test - attempt to delete previously created zabbix template group + community.zabbix.zabbix_templategroup: + template_groups: + - zbxtempgrp_example_group01 + state: absent + register: zbxtempgrp_existing_delete + +- name: assert that group was deleted + ansible.builtin.assert: + that: zbxtempgrp_existing_delete is changed + +- name: test - attempt to delete non-existing zabbix template group + community.zabbix.zabbix_templategroup: + template_groups: + - zbxtempgrp_example_group01 + state: absent + register: zbxtempgrp_missing_delete + +- name: assert that nothing has been changed + ansible.builtin.assert: + that: not zbxtempgrp_missing_delete is changed diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_token/meta/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_token/meta/main.yml new file mode 100644 index 000000000..acdb704c8 --- /dev/null +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_token/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - setup_zabbix diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_token/tasks/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_token/tasks/main.yml new file mode 100644 index 000000000..59b87b0f4 --- /dev/null +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_token/tasks/main.yml @@ -0,0 +1,99 @@ +--- +- name: Create token + community.zabbix.zabbix_token: + name: test token + description: Admin test token + username: Admin + status: true + expires_at: 1700000000 + state: present + register: zbx_token + +- name: assert that token was created + ansible.builtin.assert: + that: + - zbx_token is changed + +- name: Update token + community.zabbix.zabbix_token: + name: test token + description: Admin test token (Updated) + username: Admin + status: false + expires_at: 0 + register: zbx_token + +- name: assert that token was updated + ansible.builtin.assert: + that: + - zbx_token is changed + +- name: Update token (not changes) + community.zabbix.zabbix_token: + name: test token + description: Admin test token (Updated) + username: Admin + status: false + expires_at: 0 + register: zbx_token + +- name: assert that token was NOT updated + ansible.builtin.assert: + that: + - not zbx_token is changed + +- name: Delete token + community.zabbix.zabbix_token: + name: test token + username: Admin + state: absent + register: zbx_token + +- name: assert that token was deleted + ansible.builtin.assert: + that: + - zbx_token is changed + +- name: Delete token (already deleted) + community.zabbix.zabbix_token: + name: test token + username: Admin + state: absent + register: zbx_token + +- name: assert that token was not deleted + ansible.builtin.assert: + that: + - not zbx_token is changed + +- name: Create token with generating token + community.zabbix.zabbix_token: + name: test token + username: Admin + generate_token: true + register: zbx_token + +- name: assert that token was created + ansible.builtin.assert: + that: + - zbx_token is changed + +- name: Re-generate token + community.zabbix.zabbix_token: + name: test token + username: Admin + generate_token: true + register: zbx_new_token + +- name: assert that token was updated + ansible.builtin.assert: + that: + - zbx_token is changed + - zbx_token.token != zbx_new_token.token + +- name: Delete token + community.zabbix.zabbix_token: + name: test token + username: Admin + state: absent + register: zbx_token diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user/tasks/for_zabbix_50_lower.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user/tasks/for_zabbix_50_lower.yml deleted file mode 100644 index b658e970a..000000000 --- a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user/tasks/for_zabbix_50_lower.yml +++ /dev/null @@ -1,1044 +0,0 @@ ---- -# New user create test from here -- name: test - Create a new Zabbix user with check_mode and diff - zabbix_user: - alias: example1 - name: example - surname: test - usrgrps: - - Guests - passwd: password - check_mode: true - diff: true - register: create_zabbix_user_result - -- assert: - that: - - create_zabbix_user_result.changed is sameas true - -- name: test - Create a new Zabbix user - zabbix_user: - alias: example1 - name: example - surname: test - usrgrps: - - Guests - passwd: password - register: create_zabbix_user_result - -- assert: - that: - - create_zabbix_user_result.changed is sameas true - -- name: test - Create a new Zabbix user(again) - zabbix_user: - alias: example1 - name: example - surname: test - usrgrps: - - Guests - passwd: password - register: create_zabbix_user_result - -- assert: - that: - - not create_zabbix_user_result.changed is sameas true - -# Parameter add test from here to existing user -- name: test - Add user group to existing user - zabbix_user: - alias: example1 - name: example - surname: test - usrgrps: - - Guests - - Zabbix administrators - passwd: password - register: add_usergroup_to_existing_user_result - -- assert: - that: - - add_usergroup_to_existing_user_result.changed is sameas true - -- name: test - Add user medias(Email) to existing user - zabbix_user: - alias: example1 - name: example - surname: test - usrgrps: - - Guests - - Zabbix administrators - passwd: password - user_medias: - - mediatype: Email - sendto: example@example.com - period: 1-7,00:00-24:00 - severity: - not_classified: false - information: true - warning: true - average: true - high: true - disaster: true - active: true - register: add_user_medias_to_existing_user_result - -- assert: - that: - - add_user_medias_to_existing_user_result.changed is sameas true - -- name: test - Add multiple user medias(Email and SMS) to existing user - zabbix_user: - alias: example1 - name: example - surname: test - usrgrps: - - Guests - - Zabbix administrators - passwd: password - user_medias: - - mediatype: Email - sendto: example@example.com - period: 1-7,00:00-24:00 - severity: - not_classified: false - information: true - warning: true - average: true - high: true - disaster: true - active: true - - mediatype: SMS - sendto: example@example.com - period: 1-5,01:00-23:00 - severity: - not_classified: false - information: true - warning: true - average: false - high: true - disaster: true - active: true - register: add_user_medias_to_existing_user_result - -- assert: - that: - - add_user_medias_to_existing_user_result.changed is sameas true - -# Existing parameter updates test from here -- name: test - Update password parameter for existing user - zabbix_user: - alias: example1 - name: example - surname: test - usrgrps: - - Guests - - Zabbix administrators - passwd: update_password - override_passwd: true - user_medias: - - mediatype: Email - sendto: example@example.com - period: 1-7,00:00-24:00 - severity: - not_classified: false - information: true - warning: true - average: true - high: true - disaster: true - active: true - - mediatype: SMS - sendto: example@example.com - period: 1-5,01:00-23:00 - severity: - not_classified: false - information: true - warning: true - average: false - high: true - disaster: true - active: true - register: update_password_parameter_existing_user_result - -- assert: - that: - - update_password_parameter_existing_user_result.changed is sameas true - -- name: test - Update autologin parameter for existing user - zabbix_user: - alias: example1 - name: example - surname: test - usrgrps: - - Guests - - Zabbix administrators - passwd: update_password - autologin: true - user_medias: - - mediatype: Email - sendto: example@example.com - period: 1-7,00:00-24:00 - severity: - not_classified: false - information: true - warning: true - average: true - high: true - disaster: true - active: true - - mediatype: SMS - sendto: example@example.com - period: 1-5,01:00-23:00 - severity: - not_classified: false - information: true - warning: true - average: false - high: true - disaster: true - active: true - register: update_autologin_parameter_existing_user_result - -- assert: - that: - - update_autologin_parameter_existing_user_result.changed is sameas true - -- name: test - Update autologout parameter for existing user - zabbix_user: - alias: example1 - name: example - surname: test - usrgrps: - - Guests - - Zabbix administrators - passwd: update_password - autologout: 500 - user_medias: - - mediatype: Email - sendto: example@example.com - period: 1-7,00:00-24:00 - severity: - not_classified: false - information: true - warning: true - average: true - high: true - disaster: true - active: true - - mediatype: SMS - sendto: example@example.com - period: 1-5,01:00-23:00 - severity: - not_classified: false - information: true - warning: true - average: false - high: true - disaster: true - active: true - register: update_autologout_parameter_existing_user_result - -- assert: - that: - - update_autologout_parameter_existing_user_result.changed is sameas true - -- name: test - Update refresh parameter for existing user - zabbix_user: - alias: example1 - name: example - surname: test - usrgrps: - - Guests - - Zabbix administrators - passwd: update_password - autologout: 500 - refresh: 60 - user_medias: - - mediatype: Email - sendto: example@example.com - period: 1-7,00:00-24:00 - severity: - not_classified: false - information: true - warning: true - average: true - high: true - disaster: true - active: true - - mediatype: SMS - sendto: example@example.com - period: 1-5,01:00-23:00 - severity: - not_classified: false - information: true - warning: true - average: false - high: true - disaster: true - active: true - register: update_refresh_parameter_existing_user_result - -- assert: - that: - - update_refresh_parameter_existing_user_result.changed is sameas true - -- name: test - Update rows_per_page parameter for existing user - zabbix_user: - alias: example1 - name: example - surname: test - usrgrps: - - Guests - - Zabbix administrators - passwd: update_password - autologout: 500 - refresh: 60 - rows_per_page: 300 - user_medias: - - mediatype: Email - sendto: example@example.com - period: 1-7,00:00-24:00 - severity: - not_classified: false - information: true - warning: true - average: true - high: true - disaster: true - active: true - - mediatype: SMS - sendto: example@example.com - period: 1-5,01:00-23:00 - severity: - not_classified: false - information: true - warning: true - average: false - high: true - disaster: true - active: true - register: update_rows_per_page_parameter_existing_user_result - -- assert: - that: - - update_rows_per_page_parameter_existing_user_result.changed is sameas true - -- name: test - Update after_login_url parameter for existing user - zabbix_user: - alias: example1 - name: example - surname: test - usrgrps: - - Guests - - Zabbix administrators - passwd: update_password - autologout: 500 - refresh: 60 - rows_per_page: 300 - after_login_url: http://example.com - user_medias: - - mediatype: Email - sendto: example@example.com - period: 1-7,00:00-24:00 - severity: - not_classified: false - information: true - warning: true - average: true - high: true - disaster: true - active: true - - mediatype: SMS - sendto: example@example.com - period: 1-5,01:00-23:00 - severity: - not_classified: false - information: true - warning: true - average: false - high: true - disaster: true - active: true - register: update_after_login_url_parameter_existing_user_result - -- assert: - that: - - update_after_login_url_parameter_existing_user_result.changed is sameas true - -- name: test - Update theme parameter for existing user - zabbix_user: - alias: example1 - name: example - surname: test - usrgrps: - - Guests - - Zabbix administrators - passwd: update_password - autologout: 500 - refresh: 60 - rows_per_page: 300 - after_login_url: http://example.com - theme: "{{ item }}" - user_medias: - - mediatype: Email - sendto: example@example.com - period: 1-7,00:00-24:00 - severity: - not_classified: false - information: true - warning: true - average: true - high: true - disaster: true - active: true - - mediatype: SMS - sendto: example@example.com - period: 1-5,01:00-23:00 - severity: - not_classified: false - information: true - warning: true - average: false - high: true - disaster: true - active: true - loop: - - blue-theme - - dark-theme - register: update_theme_parameter_existing_user_result - -- assert: - that: - - item.changed is sameas true - loop: "{{ update_theme_parameter_existing_user_result.results }}" - -- name: test - Update type parameter for existing user - zabbix_user: - alias: example1 - name: example - surname: test - usrgrps: - - Guests - - Zabbix administrators - passwd: update_password - autologout: 500 - refresh: 60 - rows_per_page: 300 - after_login_url: http://example.com - theme: dark-theme - type: "{{ item }}" - user_medias: - - mediatype: Email - sendto: example@example.com - period: 1-7,00:00-24:00 - severity: - not_classified: false - information: true - warning: true - average: true - high: true - disaster: true - active: true - - mediatype: SMS - sendto: example@example.com - period: 1-5,01:00-23:00 - severity: - not_classified: false - information: true - warning: true - average: false - high: true - disaster: true - active: true - loop: - - Zabbix admin - - Zabbix super admin - register: update_type_parameter_existing_user_result - -- assert: - that: - - item.changed is sameas true - loop: "{{ update_type_parameter_existing_user_result.results }}" - -- name: test - Update lang parameter for existing user - zabbix_user: - alias: example1 - name: example - surname: test - usrgrps: - - Guests - - Zabbix administrators - passwd: update_password - autologout: 500 - refresh: 60 - rows_per_page: 300 - after_login_url: http://example.com - theme: dark-theme - type: Zabbix super admin - lang: en_US - user_medias: - - mediatype: Email - sendto: example@example.com - period: 1-7,00:00-24:00 - severity: - not_classified: false - information: true - warning: true - average: true - high: true - disaster: true - active: true - - mediatype: SMS - sendto: example@example.com - period: 1-5,01:00-23:00 - severity: - not_classified: false - information: true - warning: true - average: false - high: true - disaster: true - active: true - register: update_lang_parameter_existing_user_result - -- assert: - that: - - update_lang_parameter_existing_user_result.changed is sameas true - -- name: test - Update name and surname parameter for existing user - zabbix_user: - alias: example1 - name: example2 - surname: test2 - usrgrps: - - Guests - - Zabbix administrators - passwd: update_password - autologout: 500 - refresh: 60 - rows_per_page: 300 - after_login_url: http://example.com - theme: dark-theme - type: Zabbix super admin - lang: en_US - user_medias: - - mediatype: Email - sendto: example@example.com - period: 1-7,00:00-24:00 - severity: - not_classified: false - information: true - warning: true - average: true - high: true - disaster: true - active: true - - mediatype: SMS - sendto: example@example.com - period: 1-5,01:00-23:00 - severity: - not_classified: false - information: true - warning: true - average: false - high: true - disaster: true - active: true - register: update_name_and_surname_parameter_existing_user_result - -- assert: - that: - - update_name_and_surname_parameter_existing_user_result.changed is sameas true - -- name: test - Update lang parameter for existing user with check_mode and diff - zabbix_user: - alias: example1 - name: example2 - surname: test2 - usrgrps: - - Guests - - Zabbix administrators - passwd: update_password - autologout: 500 - refresh: 60 - rows_per_page: 300 - after_login_url: http://example.com - theme: dark-theme - type: Zabbix super admin - lang: en_GB - user_medias: - - mediatype: Email - sendto: example@example.com - period: 1-7,00:00-24:00 - severity: - not_classified: false - information: true - warning: true - average: true - high: true - disaster: true - active: true - - mediatype: SMS - sendto: example@example.com - period: 1-5,01:00-23:00 - severity: - not_classified: false - information: true - warning: true - average: false - high: true - disaster: true - active: true - check_mode: true - diff: true - register: update_lang_parameter_existing_user_with_check_mode_diff_result - -- assert: - that: - - update_lang_parameter_existing_user_with_check_mode_diff_result.changed is sameas true - -- name: test - Update lang parameter for existing user - zabbix_user: - alias: example1 - name: example2 - surname: test2 - usrgrps: - - Guests - - Zabbix administrators - passwd: update_password - autologout: 500 - refresh: 60 - rows_per_page: 300 - after_login_url: http://example.com - theme: dark-theme - type: Zabbix super admin - lang: en_GB - user_medias: - - mediatype: Email - sendto: example@example.com - period: 1-7,00:00-24:00 - severity: - not_classified: false - information: true - warning: true - average: true - high: true - disaster: true - active: true - - mediatype: SMS - sendto: example@example.com - period: 1-5,01:00-23:00 - severity: - not_classified: false - information: true - warning: true - average: false - high: true - disaster: true - active: true - register: update_lang_parameter_existing_user_result - -- assert: - that: - - update_lang_parameter_existing_user_result.changed is sameas true - -- name: test - Update lang parameter for existing user(again) - zabbix_user: - alias: example1 - name: example2 - surname: test2 - usrgrps: - - Guests - - Zabbix administrators - passwd: update_password - autologout: 500 - refresh: 60 - rows_per_page: 300 - after_login_url: http://example.com - theme: dark-theme - type: Zabbix super admin - lang: en_GB - user_medias: - - mediatype: Email - sendto: example@example.com - period: 1-7,00:00-24:00 - severity: - not_classified: false - information: true - warning: true - average: true - high: true - disaster: true - active: true - - mediatype: SMS - sendto: example@example.com - period: 1-5,01:00-23:00 - severity: - not_classified: false - information: true - warning: true - average: false - high: true - disaster: true - active: true - register: update_lang_parameter_existing_user_result - -- assert: - that: - - not update_lang_parameter_existing_user_result.changed is sameas true - -# Parameter delete test from here from existing user -- name: test - Delete user medias(SMS) for existing user with check_mode and diff - zabbix_user: - alias: example1 - name: example2 - surname: test2 - usrgrps: - - Guests - - Zabbix administrators - passwd: update_password - autologout: 500 - refresh: 60 - rows_per_page: 300 - after_login_url: http://example.com - theme: dark-theme - type: Zabbix super admin - lang: en_GB - user_medias: - - mediatype: Email - sendto: example@example.com - period: 1-7,00:00-24:00 - severity: - not_classified: false - information: true - warning: true - average: true - high: true - disaster: true - active: true - check_mode: true - diff: true - register: delete_user_medias_existing_user_result - -- assert: - that: - - delete_user_medias_existing_user_result.changed is sameas true - -- name: test - Delete user medias(SMS) for existing user - zabbix_user: - alias: example1 - name: example2 - surname: test2 - usrgrps: - - Guests - - Zabbix administrators - passwd: update_password - autologout: 500 - refresh: 60 - rows_per_page: 300 - after_login_url: http://example.com - theme: dark-theme - type: Zabbix super admin - lang: en_GB - user_medias: - - mediatype: Email - sendto: example@example.com - period: 1-7,00:00-24:00 - severity: - not_classified: false - information: true - warning: true - average: true - high: true - disaster: true - active: true - register: delete_user_medias_existing_user_result - -- assert: - that: - - delete_user_medias_existing_user_result.changed is sameas true - -- name: test - Delete user group for existing user - zabbix_user: - alias: example1 - name: example2 - surname: test2 - usrgrps: - - Zabbix administrators - passwd: update_password - autologout: 500 - refresh: 60 - rows_per_page: 300 - after_login_url: http://example.com - theme: dark-theme - type: Zabbix super admin - lang: en_GB - user_medias: - - mediatype: Email - sendto: example@example.com - period: 1-7,00:00-24:00 - severity: - not_classified: false - information: true - warning: true - average: true - high: true - disaster: true - active: true - register: delete_user_group_existing_user_result - -- assert: - that: - - delete_user_group_existing_user_result.changed is sameas true - -- name: test - optional user_medias - zabbix_user: - alias: example1 - name: example2 - surname: test2 - usrgrps: - - Zabbix administrators - passwd: update_password - autologout: 500 - refresh: 60 - rows_per_page: 300 - after_login_url: http://example.com - theme: dark-theme - type: Zabbix super admin - lang: en_GB - register: update_user_optional_user_medias_existing_user_result - -- assert: - that: - - update_user_optional_user_medias_existing_user_result.changed is sameas False - -- name: test - Delete existing user with check_mode and diff - zabbix_user: - alias: example1 - state: absent - check_mode: true - diff: true - register: delete_existing_user_result - -- assert: - that: - - delete_existing_user_result.changed is sameas true - -- name: test - Delete existing user - zabbix_user: - alias: example1 - state: absent - register: delete_existing_user_result - -- assert: - that: - - delete_existing_user_result.changed is sameas true - -- name: test - Delete existing user(again) - zabbix_user: - alias: example1 - state: absent - register: delete_existing_user_result - -- assert: - that: - - not delete_existing_user_result.changed is sameas true - -- when: zabbix_version is version('4.0', '<') - block: - - name: test - Create new password-less user without LDAP group (fail, <4.0) - zabbix_user: - alias: example2alias - name: example2 - surname: testldap - usrgrps: - - Guests - register: create_zabbix_user_ldap_fail - ignore_errors: true - - - assert: - that: - - create_zabbix_user_ldap_fail.failed is sameas True - -- when: zabbix_version is version('4.0', '>=') - block: - - name: test prepare - Create LDAP user group - zabbix_usergroup: - name: testLDAPgrp - gui_access: LDAP - register: zbxuser_create_ldap_group - - - assert: - that: - - zbxuser_create_ldap_group.changed is sameas True - - - name: test - Create new password-less user without LDAP group (fail) - zabbix_user: - alias: example2alias - name: example2 - surname: testldap - usrgrps: - - Guests - register: create_zabbix_user_ldap_fail - ignore_errors: true - - - assert: - that: - - create_zabbix_user_ldap_fail.failed is sameas True - - - name: test - Create new password-less user as member in LDAP group - zabbix_user: - alias: example2alias - name: example2 - surname: testldap - usrgrps: - - testLDAPgrp - register: create_zabbix_user_ldap_result - - - assert: - that: - - create_zabbix_user_ldap_result.changed is sameas True - - - name: test - Create new password-less user as member in LDAP group (again) - zabbix_user: - alias: example2alias - name: example2 - surname: testldap - usrgrps: - - testLDAPgrp - register: create_zabbix_user_ldap_result - - - assert: - that: - - create_zabbix_user_ldap_result.changed is sameas False - - - name: test - Delete existing user - zabbix_user: - alias: example2alias - state: absent - register: delete_existing_user_result - - - assert: - that: - - delete_existing_user_result.changed is sameas true - -# The tests are to check the patch for PR hasn't a problem. -# https://github.com/ansible-collections/community.zabbix/pull/382 -- name: test - Create a zabbix user with minimum parameters - zabbix_user: - alias: example2 - usrgrps: - - Guests - passwd: password - register: create_zabbix_user_with_minimum_params_result - -- assert: - that: - - create_zabbix_user_with_minimum_params_result.changed is sameas true - -- name: test - Create a zabbix user with minimum parameters(again) - zabbix_user: - alias: example2 - usrgrps: - - Guests - passwd: password - register: create_zabbix_user_with_minimum_params_result - -- assert: - that: - - create_zabbix_user_with_minimum_params_result.changed is sameas false - -- name: test - Update the parameters without role_name - zabbix_user: - alias: example2 - name: example2 - surname: test - usrgrps: - - Guests - passwd: password - register: update_params_without_role_name_result - -- assert: - that: - - update_params_without_role_name_result.changed is sameas true - -- name: test - Update the parameters without role_name(again) - zabbix_user: - alias: example2 - name: example2 - surname: test - usrgrps: - - Guests - passwd: password - register: update_params_without_role_name_result - -- assert: - that: - - update_params_without_role_name_result.changed is sameas false - -- name: test - Add user medias(Email) as list to existing user - zabbix_user: - alias: example2 - name: example2 - surname: test - usrgrps: - - Guests - passwd: G$jd_79!jw - user_medias: - - mediatype: Email - sendto: - - example@example.com - - example1@example.com - period: 1-7,00:00-24:00 - severity: - not_classified: false - information: true - warning: true - average: true - high: true - disaster: true - active: true - register: add_user_email_media_as_list_to_existing_user_result - -- assert: - that: - - add_user_email_media_as_list_to_existing_user_result.changed is sameas true - -- name: test - Add user medias(Email) as list to existing user(again) - zabbix_user: - alias: example2 - name: example2 - surname: test - usrgrps: - - Guests - passwd: G$jd_79!jw - user_medias: - - mediatype: Email - sendto: - - example@example.com - - example1@example.com - period: 1-7,00:00-24:00 - severity: - not_classified: false - information: true - warning: true - average: true - high: true - disaster: true - active: true - register: add_user_email_media_as_list_to_existing_user_result - -- assert: - that: - - add_user_email_media_as_list_to_existing_user_result.changed is sameas false - -- name: test - Delete existing user - zabbix_user: - alias: example2 - state: absent - -- name: test prepare - Delete LDAP user group - zabbix_usergroup: - name: testLDAPgrp - state: absent diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user/tasks/for_zabbix_54_higher.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user/tasks/for_zabbix_54_higher.yml deleted file mode 100644 index 9d3d913ce..000000000 --- a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user/tasks/for_zabbix_54_higher.yml +++ /dev/null @@ -1,1100 +0,0 @@ ---- -# New user create test from here -- name: test - Create a new Zabbix user with check_mode and diff - zabbix_user: - alias: example1 - name: example - surname: test - usrgrps: - - Guests - passwd: G$jd_79!jw - check_mode: true - diff: true - register: create_zabbix_user_result - -- assert: - that: - - create_zabbix_user_result.changed is sameas true - -- name: test - Create a new Zabbix user - zabbix_user: - alias: example1 - name: example - surname: test - usrgrps: - - Guests - passwd: G$jd_79!jw - register: create_zabbix_user_result - -- assert: - that: - - create_zabbix_user_result.changed is sameas true - -- name: test - Create a new Zabbix user(again) - zabbix_user: - alias: example1 - name: example - surname: test - usrgrps: - - Guests - passwd: G$jd_79!jw - register: create_zabbix_user_result - -- assert: - that: - - not create_zabbix_user_result.changed is sameas true - -# Parameter add test from here to existing user -- name: test - Add user group to existing user - zabbix_user: - alias: example1 - name: example - surname: test - usrgrps: - - Guests - - Zabbix administrators - passwd: G$jd_79!jw - register: add_usergroup_to_existing_user_result - -- assert: - that: - - add_usergroup_to_existing_user_result.changed is sameas true - -- name: test - Add user medias(Email) to existing user - zabbix_user: - alias: example1 - name: example - surname: test - usrgrps: - - Guests - - Zabbix administrators - passwd: G$jd_79!jw - user_medias: - - mediatype: Email - sendto: example@example.com - period: 1-7,00:00-24:00 - severity: - not_classified: false - information: true - warning: true - average: true - high: true - disaster: true - active: true - register: add_user_medias_to_existing_user_result - -- assert: - that: - - add_user_medias_to_existing_user_result.changed is sameas true - -- name: test - Add multiple user medias(Email and SMS) to existing user - zabbix_user: - alias: example1 - name: example - surname: test - usrgrps: - - Guests - - Zabbix administrators - passwd: G$jd_79!jw - user_medias: - - mediatype: Email - sendto: example@example.com - period: 1-7,00:00-24:00 - severity: - not_classified: false - information: true - warning: true - average: true - high: true - disaster: true - active: true - - mediatype: SMS - sendto: example@example.com - period: 1-5,01:00-23:00 - severity: - not_classified: false - information: true - warning: true - average: false - high: true - disaster: true - active: true - register: add_user_medias_to_existing_user_result - -- assert: - that: - - add_user_medias_to_existing_user_result.changed is sameas true - -# Existing parameter updates test from here -- name: test - Update password parameter for existing user - zabbix_user: - alias: example1 - name: example - surname: test - usrgrps: - - Guests - - Zabbix administrators - passwd: update_password - override_passwd: true - user_medias: - - mediatype: Email - sendto: example@example.com - period: 1-7,00:00-24:00 - severity: - not_classified: false - information: true - warning: true - average: true - high: true - disaster: true - active: true - - mediatype: SMS - sendto: example@example.com - period: 1-5,01:00-23:00 - severity: - not_classified: false - information: true - warning: true - average: false - high: true - disaster: true - active: true - register: update_password_parameter_existing_user_result - -- assert: - that: - - update_password_parameter_existing_user_result.changed is sameas true - -- name: test - Update autologin parameter for existing user - zabbix_user: - alias: example1 - name: example - surname: test - usrgrps: - - Guests - - Zabbix administrators - passwd: update_password - autologin: true - user_medias: - - mediatype: Email - sendto: example@example.com - period: 1-7,00:00-24:00 - severity: - not_classified: false - information: true - warning: true - average: true - high: true - disaster: true - active: true - - mediatype: SMS - sendto: example@example.com - period: 1-5,01:00-23:00 - severity: - not_classified: false - information: true - warning: true - average: false - high: true - disaster: true - active: true - register: update_autologin_parameter_existing_user_result - -- assert: - that: - - update_autologin_parameter_existing_user_result.changed is sameas true - -- name: test - Update autologout parameter for existing user - zabbix_user: - alias: example1 - name: example - surname: test - usrgrps: - - Guests - - Zabbix administrators - passwd: update_password - autologout: 500 - user_medias: - - mediatype: Email - sendto: example@example.com - period: 1-7,00:00-24:00 - severity: - not_classified: false - information: true - warning: true - average: true - high: true - disaster: true - active: true - - mediatype: SMS - sendto: example@example.com - period: 1-5,01:00-23:00 - severity: - not_classified: false - information: true - warning: true - average: false - high: true - disaster: true - active: true - register: update_autologout_parameter_existing_user_result - -- assert: - that: - - update_autologout_parameter_existing_user_result.changed is sameas true - -- name: test - Update refresh parameter for existing user - zabbix_user: - alias: example1 - name: example - surname: test - usrgrps: - - Guests - - Zabbix administrators - passwd: update_password - autologout: 500 - refresh: 60 - user_medias: - - mediatype: Email - sendto: example@example.com - period: 1-7,00:00-24:00 - severity: - not_classified: false - information: true - warning: true - average: true - high: true - disaster: true - active: true - - mediatype: SMS - sendto: example@example.com - period: 1-5,01:00-23:00 - severity: - not_classified: false - information: true - warning: true - average: false - high: true - disaster: true - active: true - register: update_refresh_parameter_existing_user_result - -- assert: - that: - - update_refresh_parameter_existing_user_result.changed is sameas true - -- name: test - Update rows_per_page parameter for existing user - zabbix_user: - alias: example1 - name: example - surname: test - usrgrps: - - Guests - - Zabbix administrators - passwd: update_password - autologout: 500 - refresh: 60 - rows_per_page: 300 - user_medias: - - mediatype: Email - sendto: example@example.com - period: 1-7,00:00-24:00 - severity: - not_classified: false - information: true - warning: true - average: true - high: true - disaster: true - active: true - - mediatype: SMS - sendto: example@example.com - period: 1-5,01:00-23:00 - severity: - not_classified: false - information: true - warning: true - average: false - high: true - disaster: true - active: true - register: update_rows_per_page_parameter_existing_user_result - -- assert: - that: - - update_rows_per_page_parameter_existing_user_result.changed is sameas true - -- name: test - Update after_login_url parameter for existing user - zabbix_user: - alias: example1 - name: example - surname: test - usrgrps: - - Guests - - Zabbix administrators - passwd: update_password - autologout: 500 - refresh: 60 - rows_per_page: 300 - after_login_url: http://example.com - user_medias: - - mediatype: Email - sendto: example@example.com - period: 1-7,00:00-24:00 - severity: - not_classified: false - information: true - warning: true - average: true - high: true - disaster: true - active: true - - mediatype: SMS - sendto: example@example.com - period: 1-5,01:00-23:00 - severity: - not_classified: false - information: true - warning: true - average: false - high: true - disaster: true - active: true - register: update_after_login_url_parameter_existing_user_result - -- assert: - that: - - update_after_login_url_parameter_existing_user_result.changed is sameas true - -- name: test - Update theme parameter for existing user - zabbix_user: - alias: example1 - name: example - surname: test - usrgrps: - - Guests - - Zabbix administrators - passwd: update_password - autologout: 500 - refresh: 60 - rows_per_page: 300 - after_login_url: http://example.com - theme: "{{ item }}" - user_medias: - - mediatype: Email - sendto: example@example.com - period: 1-7,00:00-24:00 - severity: - not_classified: false - information: true - warning: true - average: true - high: true - disaster: true - active: true - - mediatype: SMS - sendto: example@example.com - period: 1-5,01:00-23:00 - severity: - not_classified: false - information: true - warning: true - average: false - high: true - disaster: true - active: true - loop: - - blue-theme - - dark-theme - register: update_theme_parameter_existing_user_result - -- assert: - that: - - item.changed is sameas true - loop: "{{ update_theme_parameter_existing_user_result.results }}" - -- name: test - Update role_name parameter for existing user - zabbix_user: - alias: example1 - name: example - surname: test - usrgrps: - - Guests - - Zabbix administrators - passwd: update_password - autologout: 500 - refresh: 60 - rows_per_page: 300 - after_login_url: http://example.com - theme: dark-theme - role_name: "{{ item }}" - user_medias: - - mediatype: Email - sendto: example@example.com - period: 1-7,00:00-24:00 - severity: - not_classified: false - information: true - warning: true - average: true - high: true - disaster: true - active: true - - mediatype: SMS - sendto: example@example.com - period: 1-5,01:00-23:00 - severity: - not_classified: false - information: true - warning: true - average: false - high: true - disaster: true - active: true - loop: - - Guest role - - Admin role - register: update_type_parameter_existing_user_result - -- assert: - that: - - item.changed is sameas true - loop: "{{ update_type_parameter_existing_user_result.results }}" - -- name: test - Update lang parameter for existing user - zabbix_user: - alias: example1 - name: example - surname: test - usrgrps: - - Guests - - Zabbix administrators - passwd: update_password - autologout: 500 - refresh: 60 - rows_per_page: 300 - after_login_url: http://example.com - theme: dark-theme - role_name: Admin role - lang: en_US - user_medias: - - mediatype: Email - sendto: example@example.com - period: 1-7,00:00-24:00 - severity: - not_classified: false - information: true - warning: true - average: true - high: true - disaster: true - active: true - - mediatype: SMS - sendto: example@example.com - period: 1-5,01:00-23:00 - severity: - not_classified: false - information: true - warning: true - average: false - high: true - disaster: true - active: true - register: update_lang_parameter_existing_user_result - -- assert: - that: - - update_lang_parameter_existing_user_result.changed is sameas true - -- name: test - Update timezone parameter for existing user - zabbix_user: - alias: example1 - name: example - surname: test - usrgrps: - - Guests - - Zabbix administrators - passwd: update_password - autologout: 500 - refresh: 60 - rows_per_page: 300 - after_login_url: http://example.com - theme: dark-theme - role_name: Admin role - timezone: Asia/Tokyo - lang: en_US - user_medias: - - mediatype: Email - sendto: example@example.com - period: 1-7,00:00-24:00 - severity: - not_classified: false - information: true - warning: true - average: true - high: true - disaster: true - active: true - - mediatype: SMS - sendto: example@example.com - period: 1-5,01:00-23:00 - severity: - not_classified: false - information: true - warning: true - average: false - high: true - disaster: true - active: true - register: update_timezone_parameter_existing_user_result - -- assert: - that: - - update_timezone_parameter_existing_user_result.changed is sameas true - -- name: test - Update name and surname parameter for existing user - zabbix_user: - alias: example1 - name: example2 - surname: test2 - usrgrps: - - Guests - - Zabbix administrators - passwd: update_password - autologout: 500 - refresh: 60 - rows_per_page: 300 - after_login_url: http://example.com - theme: dark-theme - role_name: Admin role - timezone: Asia/Tokyo - lang: en_US - user_medias: - - mediatype: Email - sendto: example@example.com - period: 1-7,00:00-24:00 - severity: - not_classified: false - information: true - warning: true - average: true - high: true - disaster: true - active: true - - mediatype: SMS - sendto: example@example.com - period: 1-5,01:00-23:00 - severity: - not_classified: false - information: true - warning: true - average: false - high: true - disaster: true - active: true - register: update_name_and_surname_parameter_existing_user_result - -- assert: - that: - - update_name_and_surname_parameter_existing_user_result.changed is sameas true - -- name: test - Update lang parameter for existing user with check_mode and diff - zabbix_user: - alias: example1 - name: example2 - surname: test2 - usrgrps: - - Guests - - Zabbix administrators - passwd: update_password - autologout: 500 - refresh: 60 - rows_per_page: 300 - after_login_url: http://example.com - theme: dark-theme - role_name: Admin role - timezone: Asia/Tokyo - lang: fr_FR - user_medias: - - mediatype: Email - sendto: example@example.com - period: 1-7,00:00-24:00 - severity: - not_classified: false - information: true - warning: true - average: true - high: true - disaster: true - active: true - - mediatype: SMS - sendto: example@example.com - period: 1-5,01:00-23:00 - severity: - not_classified: false - information: true - warning: true - average: false - high: true - disaster: true - active: true - check_mode: true - diff: true - register: update_lang_parameter_existing_user_with_check_mode_diff_result - -- assert: - that: - - update_lang_parameter_existing_user_with_check_mode_diff_result.changed is sameas true - -- name: test - Update lang parameter for existing user - zabbix_user: - alias: example1 - name: example2 - surname: test2 - usrgrps: - - Guests - - Zabbix administrators - passwd: update_password - autologout: 500 - refresh: 60 - rows_per_page: 300 - after_login_url: http://example.com - theme: dark-theme - role_name: Admin role - timezone: Asia/Tokyo - lang: fr_FR - user_medias: - - mediatype: Email - sendto: example@example.com - period: 1-7,00:00-24:00 - severity: - not_classified: false - information: true - warning: true - average: true - high: true - disaster: true - active: true - - mediatype: SMS - sendto: example@example.com - period: 1-5,01:00-23:00 - severity: - not_classified: false - information: true - warning: true - average: false - high: true - disaster: true - active: true - register: update_lang_parameter_existing_user_result - -- assert: - that: - - update_lang_parameter_existing_user_result.changed is sameas true - -- name: test - Update lang parameter for existing user(again) - zabbix_user: - alias: example1 - name: example2 - surname: test2 - usrgrps: - - Guests - - Zabbix administrators - passwd: update_password - autologout: 500 - refresh: 60 - rows_per_page: 300 - after_login_url: http://example.com - theme: dark-theme - role_name: Admin role - timezone: Asia/Tokyo - lang: fr_FR - user_medias: - - mediatype: Email - sendto: example@example.com - period: 1-7,00:00-24:00 - severity: - not_classified: false - information: true - warning: true - average: true - high: true - disaster: true - active: true - - mediatype: SMS - sendto: example@example.com - period: 1-5,01:00-23:00 - severity: - not_classified: false - information: true - warning: true - average: false - high: true - disaster: true - active: true - register: update_lang_parameter_existing_user_result - -- assert: - that: - - not update_lang_parameter_existing_user_result.changed is sameas true - -# Parameter delete test from here from existing user -- name: test - Delete user medias(SMS) for existing user with check_mode and diff - zabbix_user: - alias: example1 - name: example2 - surname: test2 - usrgrps: - - Guests - - Zabbix administrators - passwd: update_password - autologout: 500 - refresh: 60 - rows_per_page: 300 - after_login_url: http://example.com - theme: dark-theme - role_name: Admin role - timezone: Asia/Tokyo - lang: fr_FR - user_medias: - - mediatype: Email - sendto: example@example.com - period: 1-7,00:00-24:00 - severity: - not_classified: false - information: true - warning: true - average: true - high: true - disaster: true - active: true - check_mode: true - diff: true - register: delete_user_medias_existing_user_result - -- assert: - that: - - delete_user_medias_existing_user_result.changed is sameas true - -- name: test - Delete user medias(SMS) for existing user - zabbix_user: - alias: example1 - name: example2 - surname: test2 - usrgrps: - - Guests - - Zabbix administrators - passwd: update_password - autologout: 500 - refresh: 60 - rows_per_page: 300 - after_login_url: http://example.com - theme: dark-theme - role_name: Admin role - timezone: Asia/Tokyo - lang: fr_FR - user_medias: - - mediatype: Email - sendto: example@example.com - period: 1-7,00:00-24:00 - severity: - not_classified: false - information: true - warning: true - average: true - high: true - disaster: true - active: true - register: delete_user_medias_existing_user_result - -- assert: - that: - - delete_user_medias_existing_user_result.changed is sameas true - -- name: test - Delete user group for existing user - zabbix_user: - alias: example1 - name: example2 - surname: test2 - usrgrps: - - Zabbix administrators - passwd: update_password - autologout: 500 - refresh: 60 - rows_per_page: 300 - after_login_url: http://example.com - theme: dark-theme - role_name: Admin role - timezone: Asia/Tokyo - lang: fr_FR - user_medias: - - mediatype: Email - sendto: example@example.com - period: 1-7,00:00-24:00 - severity: - not_classified: false - information: true - warning: true - average: true - high: true - disaster: true - active: true - register: delete_user_group_existing_user_result - -- assert: - that: - - delete_user_group_existing_user_result.changed is sameas true - -- name: test - optional user_medias - zabbix_user: - alias: example1 - name: example2 - surname: test2 - usrgrps: - - Zabbix administrators - passwd: update_password - autologout: 500 - refresh: 60 - rows_per_page: 300 - after_login_url: http://example.com - theme: dark-theme - role_name: Admin role - timezone: Asia/Tokyo - lang: fr_FR - register: update_user_optional_user_medias_existing_user_result - -- assert: - that: - - update_user_optional_user_medias_existing_user_result.changed is sameas False - -- name: test - Delete existing user with check_mode and diff - zabbix_user: - alias: example1 - state: absent - check_mode: true - diff: true - register: delete_existing_user_result - -- assert: - that: - - delete_existing_user_result.changed is sameas true - -- name: test - Delete existing user - zabbix_user: - alias: example1 - state: absent - register: delete_existing_user_result - -- assert: - that: - - delete_existing_user_result.changed is sameas true - -- name: test - Delete existing user(again) - zabbix_user: - alias: example1 - state: absent - register: delete_existing_user_result - -- assert: - that: - - not delete_existing_user_result.changed is sameas true - -- when: zabbix_version is version('4.0', '<') - block: - - name: test - Create new password-less user without LDAP group (fail, <4.0) - zabbix_user: - alias: example2alias - name: example2 - surname: testldap - usrgrps: - - Guests - register: create_zabbix_user_ldap_fail - ignore_errors: true - - - assert: - that: - - create_zabbix_user_ldap_fail.failed is sameas True - -- when: zabbix_version is version('4.0', '>=') - block: - - name: test prepare - Create LDAP user group - zabbix_usergroup: - name: testLDAPgrp - gui_access: LDAP - register: zbxuser_create_ldap_group - - - assert: - that: - - zbxuser_create_ldap_group.changed is sameas True - - - name: test - Create new password-less user without LDAP group (fail) - zabbix_user: - alias: example2alias - name: example2 - surname: testldap - usrgrps: - - Guests - register: create_zabbix_user_ldap_fail - ignore_errors: true - - - assert: - that: - - create_zabbix_user_ldap_fail.failed is sameas True - - - name: test - Create new password-less user as member in LDAP group - zabbix_user: - alias: example2alias - name: example2 - surname: testldap - usrgrps: - - testLDAPgrp - register: create_zabbix_user_ldap_result - - - assert: - that: - - create_zabbix_user_ldap_result.changed is sameas True - - - name: test - Create new password-less user as member in LDAP group (again) - zabbix_user: - alias: example2alias - name: example2 - surname: testldap - usrgrps: - - testLDAPgrp - register: create_zabbix_user_ldap_result - - - assert: - that: - - create_zabbix_user_ldap_result.changed is sameas False - - - name: test - Delete existing user - zabbix_user: - alias: example2alias - state: absent - register: delete_existing_user_result - - - assert: - that: - - delete_existing_user_result.changed is sameas true - -# The tests are to check the patch for PR hasn't a problem. -# https://github.com/ansible-collections/community.zabbix/pull/382 -- name: test - Create a zabbix user with minimum parameters - zabbix_user: - alias: example2 - usrgrps: - - Guests - passwd: G$jd_79!jw - role_name: "User role" - register: create_zabbix_user_with_minimum_params_result - -- assert: - that: - - create_zabbix_user_with_minimum_params_result.changed is sameas true - -- name: test - Create a zabbix user with minimum parameters(again) - zabbix_user: - alias: example2 - usrgrps: - - Guests - passwd: G$jd_79!jw - role_name: "User role" - register: create_zabbix_user_with_minimum_params_result - -- assert: - that: - - create_zabbix_user_with_minimum_params_result.changed is sameas false - -- name: test - Update the parameters without role_name - zabbix_user: - alias: example2 - name: example2 - surname: test - usrgrps: - - Guests - passwd: G$jd_79!jw - register: update_params_without_role_name_result - -- assert: - that: - - update_params_without_role_name_result.changed is sameas true - -- name: test - Update the parameters without role_name(again) - zabbix_user: - alias: example2 - name: example2 - surname: test - usrgrps: - - Guests - passwd: G$jd_79!jw - register: update_params_without_role_name_result - -- assert: - that: - - update_params_without_role_name_result.changed is sameas false - -- name: test - Add user medias(Email) as list to existing user - zabbix_user: - alias: example2 - name: example2 - surname: test - usrgrps: - - Guests - passwd: G$jd_79!jw - user_medias: - - mediatype: Email - sendto: - - example@example.com - - example1@example.com - period: 1-7,00:00-24:00 - severity: - not_classified: false - information: true - warning: true - average: true - high: true - disaster: true - active: true - register: add_user_email_media_as_list_to_existing_user_result - -- assert: - that: - - add_user_email_media_as_list_to_existing_user_result.changed is sameas true - -- name: test - Add user medias(Email) as list to existing user(again) - zabbix_user: - alias: example2 - name: example2 - surname: test - usrgrps: - - Guests - passwd: G$jd_79!jw - user_medias: - - mediatype: Email - sendto: - - example@example.com - - example1@example.com - period: 1-7,00:00-24:00 - severity: - not_classified: false - information: true - warning: true - average: true - high: true - disaster: true - active: true - register: add_user_email_media_as_list_to_existing_user_result - -- assert: - that: - - add_user_email_media_as_list_to_existing_user_result.changed is sameas false - -- name: test - Delete existing user - zabbix_user: - alias: example2 - state: absent - -- name: test prepare - Delete LDAP user group - zabbix_usergroup: - name: testLDAPgrp - state: absent diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user/tasks/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user/tasks/main.yml index f762591cf..29163436f 100644 --- a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user/tasks/main.yml +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user/tasks/main.yml @@ -1,10 +1,1082 @@ --- -- name: Execute the integration test for Zabbix 5.0 and lower - include_tasks: for_zabbix_50_lower.yml - when: - - zabbix_version | float <= 5.0 - -- name: Execute the integration test for Zabbix 5.4 and higher - include_tasks: for_zabbix_54_higher.yml - when: - - zabbix_version | float >= 5.4 +# New user create test from here +- name: test - Create a new Zabbix user with check_mode and diff + community.zabbix.zabbix_user: + username: example1 + name: example + surname: test + usrgrps: + - Guests + passwd: G$jd_79!jw + check_mode: true + diff: true + register: create_zabbix_user_result + +- ansible.builtin.assert: + that: + - create_zabbix_user_result.changed is sameas true + +- name: test - Create a new Zabbix user + community.zabbix.zabbix_user: + username: example1 + name: example + surname: test + usrgrps: + - Guests + passwd: G$jd_79!jw + register: create_zabbix_user_result + +- ansible.builtin.assert: + that: + - create_zabbix_user_result.changed is sameas true + +- name: test - Create a new Zabbix user(again) + community.zabbix.zabbix_user: + username: example1 + name: example + surname: test + usrgrps: + - Guests + passwd: G$jd_79!jw + register: create_zabbix_user_result + +- ansible.builtin.assert: + that: + - not create_zabbix_user_result.changed is sameas true + +# Parameter add test from here to existing user +- name: test - Add user group to existing user + community.zabbix.zabbix_user: + username: example1 + name: example + surname: test + usrgrps: + - Guests + - Zabbix administrators + passwd: G$jd_79!jw + register: add_usergroup_to_existing_user_result + +- ansible.builtin.assert: + that: + - add_usergroup_to_existing_user_result.changed is sameas true + +- name: test - Add user medias(Email) to existing user + community.zabbix.zabbix_user: + username: example1 + name: example + surname: test + usrgrps: + - Guests + - Zabbix administrators + passwd: G$jd_79!jw + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: false + information: true + warning: true + average: true + high: true + disaster: true + active: true + register: add_user_medias_to_existing_user_result + +- ansible.builtin.assert: + that: + - add_user_medias_to_existing_user_result.changed is sameas true + +- name: test - Add multiple user medias(Email and SMS) to existing user + community.zabbix.zabbix_user: + username: example1 + name: example + surname: test + usrgrps: + - Guests + - Zabbix administrators + passwd: G$jd_79!jw + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: false + information: true + warning: true + average: true + high: true + disaster: true + active: true + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: false + information: true + warning: true + average: false + high: true + disaster: true + active: true + register: add_user_medias_to_existing_user_result + +- ansible.builtin.assert: + that: + - add_user_medias_to_existing_user_result.changed is sameas true + +# Existing parameter updates test from here +- name: test - Update password parameter for existing user + community.zabbix.zabbix_user: + username: example1 + name: example + surname: test + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + override_passwd: true + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: false + information: true + warning: true + average: true + high: true + disaster: true + active: true + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: false + information: true + warning: true + average: false + high: true + disaster: true + active: true + register: update_password_parameter_existing_user_result + +- ansible.builtin.assert: + that: + - update_password_parameter_existing_user_result.changed is sameas true + +- name: test - Update autologin parameter for existing user + community.zabbix.zabbix_user: + username: example1 + name: example + surname: test + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologin: true + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: false + information: true + warning: true + average: true + high: true + disaster: true + active: true + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: false + information: true + warning: true + average: false + high: true + disaster: true + active: true + register: update_autologin_parameter_existing_user_result + +- ansible.builtin.assert: + that: + - update_autologin_parameter_existing_user_result.changed is sameas true + +- name: test - Update autologout parameter for existing user + community.zabbix.zabbix_user: + username: example1 + name: example + surname: test + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologout: 500 + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: false + information: true + warning: true + average: true + high: true + disaster: true + active: true + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: false + information: true + warning: true + average: false + high: true + disaster: true + active: true + register: update_autologout_parameter_existing_user_result + +- ansible.builtin.assert: + that: + - update_autologout_parameter_existing_user_result.changed is sameas true + +- name: test - Update refresh parameter for existing user + community.zabbix.zabbix_user: + username: example1 + name: example + surname: test + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologout: 500 + refresh: 60 + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: false + information: true + warning: true + average: true + high: true + disaster: true + active: true + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: false + information: true + warning: true + average: false + high: true + disaster: true + active: true + register: update_refresh_parameter_existing_user_result + +- ansible.builtin.assert: + that: + - update_refresh_parameter_existing_user_result.changed is sameas true + +- name: test - Update rows_per_page parameter for existing user + community.zabbix.zabbix_user: + username: example1 + name: example + surname: test + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologout: 500 + refresh: 60 + rows_per_page: 300 + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: false + information: true + warning: true + average: true + high: true + disaster: true + active: true + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: false + information: true + warning: true + average: false + high: true + disaster: true + active: true + register: update_rows_per_page_parameter_existing_user_result + +- ansible.builtin.assert: + that: + - update_rows_per_page_parameter_existing_user_result.changed is sameas true + +- name: test - Update after_login_url parameter for existing user + community.zabbix.zabbix_user: + username: example1 + name: example + surname: test + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologout: 500 + refresh: 60 + rows_per_page: 300 + after_login_url: http://example.com + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: false + information: true + warning: true + average: true + high: true + disaster: true + active: true + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: false + information: true + warning: true + average: false + high: true + disaster: true + active: true + register: update_after_login_url_parameter_existing_user_result + +- ansible.builtin.assert: + that: + - update_after_login_url_parameter_existing_user_result.changed is sameas true + +- name: test - Update theme parameter for existing user + community.zabbix.zabbix_user: + username: example1 + name: example + surname: test + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologout: 500 + refresh: 60 + rows_per_page: 300 + after_login_url: http://example.com + theme: "{{ item }}" + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: false + information: true + warning: true + average: true + high: true + disaster: true + active: true + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: false + information: true + warning: true + average: false + high: true + disaster: true + active: true + loop: + - blue-theme + - dark-theme + register: update_theme_parameter_existing_user_result + +- ansible.builtin.assert: + that: + - item.changed is sameas true + loop: "{{ update_theme_parameter_existing_user_result.results }}" + +- name: test - Update role_name parameter for existing user + community.zabbix.zabbix_user: + username: example1 + name: example + surname: test + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologout: 500 + refresh: 60 + rows_per_page: 300 + after_login_url: http://example.com + theme: dark-theme + role_name: "{{ item }}" + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: false + information: true + warning: true + average: true + high: true + disaster: true + active: true + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: false + information: true + warning: true + average: false + high: true + disaster: true + active: true + loop: + - Guest role + - Admin role + register: update_type_parameter_existing_user_result + +- ansible.builtin.assert: + that: + - item.changed is sameas true + loop: "{{ update_type_parameter_existing_user_result.results }}" + +- name: test - Update lang parameter for existing user + community.zabbix.zabbix_user: + username: example1 + name: example + surname: test + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologout: 500 + refresh: 60 + rows_per_page: 300 + after_login_url: http://example.com + theme: dark-theme + role_name: Admin role + lang: en_US + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: false + information: true + warning: true + average: true + high: true + disaster: true + active: true + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: false + information: true + warning: true + average: false + high: true + disaster: true + active: true + register: update_lang_parameter_existing_user_result + +- ansible.builtin.assert: + that: + - update_lang_parameter_existing_user_result.changed is sameas true + +- name: test - Update timezone parameter for existing user + community.zabbix.zabbix_user: + username: example1 + name: example + surname: test + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologout: 500 + refresh: 60 + rows_per_page: 300 + after_login_url: http://example.com + theme: dark-theme + role_name: Admin role + timezone: Asia/Tokyo + lang: en_US + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: false + information: true + warning: true + average: true + high: true + disaster: true + active: true + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: false + information: true + warning: true + average: false + high: true + disaster: true + active: true + register: update_timezone_parameter_existing_user_result + +- ansible.builtin.assert: + that: + - update_timezone_parameter_existing_user_result.changed is sameas true + +- name: test - Update name and surname parameter for existing user + community.zabbix.zabbix_user: + username: example1 + name: example2 + surname: test2 + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologout: 500 + refresh: 60 + rows_per_page: 300 + after_login_url: http://example.com + theme: dark-theme + role_name: Admin role + timezone: Asia/Tokyo + lang: en_US + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: false + information: true + warning: true + average: true + high: true + disaster: true + active: true + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: false + information: true + warning: true + average: false + high: true + disaster: true + active: true + register: update_name_and_surname_parameter_existing_user_result + +- ansible.builtin.assert: + that: + - update_name_and_surname_parameter_existing_user_result.changed is sameas true + +- name: test - Update lang parameter for existing user with check_mode and diff + community.zabbix.zabbix_user: + username: example1 + name: example2 + surname: test2 + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologout: 500 + refresh: 60 + rows_per_page: 300 + after_login_url: http://example.com + theme: dark-theme + role_name: Admin role + timezone: Asia/Tokyo + lang: fr_FR + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: false + information: true + warning: true + average: true + high: true + disaster: true + active: true + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: false + information: true + warning: true + average: false + high: true + disaster: true + active: true + check_mode: true + diff: true + register: update_lang_parameter_existing_user_with_check_mode_diff_result + +- ansible.builtin.assert: + that: + - update_lang_parameter_existing_user_with_check_mode_diff_result.changed is sameas true + +- name: test - Update lang parameter for existing user + community.zabbix.zabbix_user: + username: example1 + name: example2 + surname: test2 + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologout: 500 + refresh: 60 + rows_per_page: 300 + after_login_url: http://example.com + theme: dark-theme + role_name: Admin role + timezone: Asia/Tokyo + lang: fr_FR + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: false + information: true + warning: true + average: true + high: true + disaster: true + active: true + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: false + information: true + warning: true + average: false + high: true + disaster: true + active: true + register: update_lang_parameter_existing_user_result + +- ansible.builtin.assert: + that: + - update_lang_parameter_existing_user_result.changed is sameas true + +- name: test - Update lang parameter for existing user(again) + community.zabbix.zabbix_user: + username: example1 + name: example2 + surname: test2 + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologout: 500 + refresh: 60 + rows_per_page: 300 + after_login_url: http://example.com + theme: dark-theme + role_name: Admin role + timezone: Asia/Tokyo + lang: fr_FR + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: false + information: true + warning: true + average: true + high: true + disaster: true + active: true + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: false + information: true + warning: true + average: false + high: true + disaster: true + active: true + register: update_lang_parameter_existing_user_result + +- ansible.builtin.assert: + that: + - not update_lang_parameter_existing_user_result.changed is sameas true + +# Parameter delete test from here from existing user +- name: test - Delete user medias(SMS) for existing user with check_mode and diff + community.zabbix.zabbix_user: + username: example1 + name: example2 + surname: test2 + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologout: 500 + refresh: 60 + rows_per_page: 300 + after_login_url: http://example.com + theme: dark-theme + role_name: Admin role + timezone: Asia/Tokyo + lang: fr_FR + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: false + information: true + warning: true + average: true + high: true + disaster: true + active: true + check_mode: true + diff: true + register: delete_user_medias_existing_user_result + +- ansible.builtin.assert: + that: + - delete_user_medias_existing_user_result.changed is sameas true + +- name: test - Delete user medias(SMS) for existing user + community.zabbix.zabbix_user: + username: example1 + name: example2 + surname: test2 + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologout: 500 + refresh: 60 + rows_per_page: 300 + after_login_url: http://example.com + theme: dark-theme + role_name: Admin role + timezone: Asia/Tokyo + lang: fr_FR + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: false + information: true + warning: true + average: true + high: true + disaster: true + active: true + register: delete_user_medias_existing_user_result + +- ansible.builtin.assert: + that: + - delete_user_medias_existing_user_result.changed is sameas true + +- name: test - Delete user group for existing user + community.zabbix.zabbix_user: + username: example1 + name: example2 + surname: test2 + usrgrps: + - Zabbix administrators + passwd: update_password + autologout: 500 + refresh: 60 + rows_per_page: 300 + after_login_url: http://example.com + theme: dark-theme + role_name: Admin role + timezone: Asia/Tokyo + lang: fr_FR + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: false + information: true + warning: true + average: true + high: true + disaster: true + active: true + register: delete_user_group_existing_user_result + +- ansible.builtin.assert: + that: + - delete_user_group_existing_user_result.changed is sameas true + +- name: test - optional user_medias + community.zabbix.zabbix_user: + username: example1 + name: example2 + surname: test2 + usrgrps: + - Zabbix administrators + passwd: update_password + autologout: 500 + refresh: 60 + rows_per_page: 300 + after_login_url: http://example.com + theme: dark-theme + role_name: Admin role + timezone: Asia/Tokyo + lang: fr_FR + register: update_user_optional_user_medias_existing_user_result + +- ansible.builtin.assert: + that: + - update_user_optional_user_medias_existing_user_result.changed is sameas False + +- name: test - Delete existing user with check_mode and diff + community.zabbix.zabbix_user: + username: example1 + state: absent + check_mode: true + diff: true + register: delete_existing_user_result + +- ansible.builtin.assert: + that: + - delete_existing_user_result.changed is sameas true + +- name: test - Delete existing user + community.zabbix.zabbix_user: + username: example1 + state: absent + register: delete_existing_user_result + +- ansible.builtin.assert: + that: + - delete_existing_user_result.changed is sameas true + +- name: test - Delete existing user(again) + community.zabbix.zabbix_user: + username: example1 + state: absent + register: delete_existing_user_result + +- ansible.builtin.assert: + that: + - not delete_existing_user_result.changed is sameas true + +- name: test prepare - Create LDAP user group + community.zabbix.zabbix_usergroup: + name: testLDAPgrp + gui_access: LDAP + register: zbxuser_create_ldap_group + +- ansible.builtin.assert: + that: + - zbxuser_create_ldap_group.changed is sameas True + +- name: test - Create new password-less user without LDAP group (fail) + community.zabbix.zabbix_user: + username: example2username + name: example2 + surname: testldap + usrgrps: + - Guests + register: create_zabbix_user_ldap_fail + ignore_errors: true + +- ansible.builtin.assert: + that: + - create_zabbix_user_ldap_fail.failed is sameas True + +- name: test - Create new password-less user as member in LDAP group + community.zabbix.zabbix_user: + username: example2username + name: example2 + surname: testldap + usrgrps: + - testLDAPgrp + register: create_zabbix_user_ldap_result + +- ansible.builtin.assert: + that: + - create_zabbix_user_ldap_result.changed is sameas True + +- name: test - Create new password-less user as member in LDAP group (again) + community.zabbix.zabbix_user: + username: example2username + name: example2 + surname: testldap + usrgrps: + - testLDAPgrp + register: create_zabbix_user_ldap_result + +- ansible.builtin.assert: + that: + - create_zabbix_user_ldap_result.changed is sameas False + +- name: test - Delete existing user + community.zabbix.zabbix_user: + username: example2username + state: absent + register: delete_existing_user_result + +- ansible.builtin.assert: + that: + - delete_existing_user_result.changed is sameas true + +# The tests are to check the patch for PR hasn't a problem. +# https://github.com/ansible-collections/community.zabbix/pull/382 +- name: test - Create a zabbix user with minimum parameters + community.zabbix.zabbix_user: + username: example2 + usrgrps: + - Guests + passwd: G$jd_79!jw + role_name: "User role" + register: create_zabbix_user_with_minimum_params_result + +- ansible.builtin.assert: + that: + - create_zabbix_user_with_minimum_params_result.changed is sameas true + +- name: test - Create a zabbix user with minimum parameters(again) + community.zabbix.zabbix_user: + username: example2 + usrgrps: + - Guests + passwd: G$jd_79!jw + role_name: "User role" + register: create_zabbix_user_with_minimum_params_result + +- ansible.builtin.assert: + that: + - create_zabbix_user_with_minimum_params_result.changed is sameas false + +- name: test - Update the parameters without role_name + community.zabbix.zabbix_user: + username: example2 + name: example2 + surname: test + usrgrps: + - Guests + passwd: G$jd_79!jw + register: update_params_without_role_name_result + +- ansible.builtin.assert: + that: + - update_params_without_role_name_result.changed is sameas true + +- name: test - Update the parameters without role_name(again) + community.zabbix.zabbix_user: + username: example2 + name: example2 + surname: test + usrgrps: + - Guests + passwd: G$jd_79!jw + register: update_params_without_role_name_result + +- ansible.builtin.assert: + that: + - update_params_without_role_name_result.changed is sameas false + +- name: test - Add user medias(Email) as list to existing user + community.zabbix.zabbix_user: + username: example2 + name: example2 + surname: test + usrgrps: + - Guests + passwd: G$jd_79!jw + user_medias: + - mediatype: Email + sendto: + - example@example.com + - example1@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: false + information: true + warning: true + average: true + high: true + disaster: true + active: true + register: add_user_email_media_as_list_to_existing_user_result + +- ansible.builtin.assert: + that: + - add_user_email_media_as_list_to_existing_user_result.changed is sameas true + +- name: test - Add user medias(Email) as list to existing user(again) + community.zabbix.zabbix_user: + username: example2 + name: example2 + surname: test + usrgrps: + - Guests + passwd: G$jd_79!jw + user_medias: + - mediatype: Email + sendto: + - example@example.com + - example1@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: false + information: true + warning: true + average: true + high: true + disaster: true + active: true + register: add_user_email_media_as_list_to_existing_user_result + +- ansible.builtin.assert: + that: + - add_user_email_media_as_list_to_existing_user_result.changed is sameas false + +- name: test - Delete existing user + community.zabbix.zabbix_user: + username: example2 + state: absent + +- name: test prepare - Delete LDAP user group + community.zabbix.zabbix_usergroup: + name: testLDAPgrp + state: absent diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user_directory/tasks/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user_directory/tasks/main.yml index 6c697a2e5..e4cc87d28 100644 --- a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user_directory/tasks/main.yml +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user_directory/tasks/main.yml @@ -3,8 +3,8 @@ - include_tasks: zabbix_user_directory_tests.yml always: - - name: Cleanup - zabbix_user_directory: - name: TestUserDirectory - state: absent - ignore_errors: true + - name: Cleanup + community.zabbix.zabbix_user_directory: + name: TestUserDirectory + state: absent + ignore_errors: true diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user_directory/tasks/zabbix_user_directory_tests.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user_directory/tasks/zabbix_user_directory_tests.yml index db057a5d0..6488b80e5 100644 --- a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user_directory/tasks/zabbix_user_directory_tests.yml +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user_directory/tasks/zabbix_user_directory_tests.yml @@ -10,97 +10,97 @@ name: TestUserDirectory block: - - name: test - create new user directory in check mode - zabbix_user_directory: - host: 'test.com' - port: 389 - base_dn: 'ou=Users,dc=example,dc=org' - search_attribute: 'uid' - check_mode: true - register: directory_check_result - - - assert: - that: directory_check_result.changed is sameas True - - - name: test - attempt to create new user directory with not all mandatory parameters - zabbix_user_directory: - host: 'test.com' - port: 389 - ignore_errors: true - register: directory_expect_fail_result - - - assert: - that: directory_expect_fail_result.failed is sameas True - - - name: test - create new user directory withoud bind_password - zabbix_user_directory: - host: 'test.com' - port: 389 - base_dn: 'ou=Users,dc=example,dc=org' - search_attribute: 'uid' - register: directory_result - - - assert: - that: directory_result.changed is sameas True - - - name: test - create new user directory without bind_password again - zabbix_user_directory: - host: 'test.com' - port: 389 - base_dn: 'ou=Users,dc=example,dc=org' - search_attribute: 'uid' - register: directory_again_result - - - assert: - that: directory_again_result.changed is sameas False - - - name: test - delete user directory - zabbix_user_directory: - state: absent - register: directory_delete_result - - - assert: - that: directory_delete_result.changed is sameas True - - - name: test - create new user directory with bind_password - zabbix_user_directory: - host: 'test.com' - port: 389 - base_dn: 'ou=Users,dc=example,dc=org' - search_attribute: 'uid' - bind_password: 'password' - register: directory_result - - - assert: - that: directory_result.changed is sameas True - - - name: test - create new user directory with bind_password again - zabbix_user_directory: - host: 'test.com' - port: 389 - base_dn: 'ou=Users,dc=example,dc=org' - search_attribute: 'uid' - bind_password: 'password' - register: directory_again_result - - - assert: - that: directory_again_result.changed is sameas True - - - name: test - update only host parameter in user directory - zabbix_user_directory: - host: 'test.ca' - register: directory_update_result - - - assert: - that: directory_update_result.changed is sameas True - - - name: test - update only host parameter in user directory again - zabbix_user_directory: - host: 'test.ca' - register: directory_update_again_result - - - assert: - that: directory_update_again_result.changed is sameas False + - name: test - create new user directory in check mode + community.zabbix.zabbix_user_directory: + host: "test.com" + port: 389 + base_dn: "ou=Users,dc=example,dc=org" + search_attribute: "uid" + check_mode: true + register: directory_check_result + + - ansible.builtin.assert: + that: directory_check_result.changed is sameas True + + - name: test - attempt to create new user directory with not all mandatory parameters + community.zabbix.zabbix_user_directory: + host: "test.com" + port: 389 + ignore_errors: true + register: directory_expect_fail_result + + - ansible.builtin.assert: + that: directory_expect_fail_result.failed is sameas True + + - name: test - create new user directory withoud bind_password + community.zabbix.zabbix_user_directory: + host: "test.com" + port: 389 + base_dn: "ou=Users,dc=example,dc=org" + search_attribute: "uid" + register: directory_result + + - ansible.builtin.assert: + that: directory_result.changed is sameas True + + - name: test - create new user directory without bind_password again + community.zabbix.zabbix_user_directory: + host: "test.com" + port: 389 + base_dn: "ou=Users,dc=example,dc=org" + search_attribute: "uid" + register: directory_again_result + + - ansible.builtin.assert: + that: directory_again_result.changed is sameas False + + - name: test - delete user directory + community.zabbix.zabbix_user_directory: + state: absent + register: directory_delete_result + + - ansible.builtin.assert: + that: directory_delete_result.changed is sameas True + + - name: test - create new user directory with bind_password + community.zabbix.zabbix_user_directory: + host: "test.com" + port: 389 + base_dn: "ou=Users,dc=example,dc=org" + search_attribute: "uid" + bind_password: "password" + register: directory_result + + - ansible.builtin.assert: + that: directory_result.changed is sameas True + + - name: test - create new user directory with bind_password again + community.zabbix.zabbix_user_directory: + host: "test.com" + port: 389 + base_dn: "ou=Users,dc=example,dc=org" + search_attribute: "uid" + bind_password: "password" + register: directory_again_result + + - ansible.builtin.assert: + that: directory_again_result.changed is sameas True + + - name: test - update only host parameter in user directory + community.zabbix.zabbix_user_directory: + host: "test.ca" + register: directory_update_result + + - ansible.builtin.assert: + that: directory_update_result.changed is sameas True + + - name: test - update only host parameter in user directory again + community.zabbix.zabbix_user_directory: + host: "test.ca" + register: directory_update_again_result + + - ansible.builtin.assert: + that: directory_update_again_result.changed is sameas False when: zabbix_version is version('6.4', '<') @@ -111,327 +111,327 @@ name: TestUserDirectory block: - - name: test - create new LDAP user directory in check mode - zabbix_user_directory: - idp_type: ldap - host: 'test.com' - port: 389 - base_dn: 'ou=Users,dc=example,dc=org' - search_attribute: 'uid' - check_mode: true - register: directory_check_result - - - assert: - that: directory_check_result.changed is sameas True - - - name: test - attempt to create new LDAP user directory with not all mandatory parameters - zabbix_user_directory: - idp_type: ldap - host: 'test.com' - port: 389 - ignore_errors: true - register: directory_expect_fail_result - - - assert: - that: directory_expect_fail_result.failed is sameas True - - - name: test - create new LDAP user directory withoud bind_password - zabbix_user_directory: - idp_type: ldap - host: 'test.com' - port: 389 - base_dn: 'ou=Users,dc=example,dc=org' - search_attribute: 'uid' - register: directory_result - - - assert: - that: directory_result.changed is sameas True - - - name: test - create new LDAP user directory without bind_password again - zabbix_user_directory: - idp_type: ldap - host: 'test.com' - port: 389 - base_dn: 'ou=Users,dc=example,dc=org' - search_attribute: 'uid' - register: directory_again_result - - - assert: - that: directory_again_result.changed is sameas False - - - name: test - delete LDAP user directory - zabbix_user_directory: - state: absent - register: directory_delete_result - - - assert: - that: directory_delete_result.changed is sameas True - - - name: test - create new LDAP user directory with bind_password - zabbix_user_directory: - idp_type: ldap - host: 'test.com' - port: 389 - base_dn: 'ou=Users,dc=example,dc=org' - search_attribute: 'uid' - bind_password: 'password' - register: directory_result - - - assert: - that: directory_result.changed is sameas True - - - name: test - create new LDAP user directory with bind_password again - zabbix_user_directory: - idp_type: ldap - host: 'test.com' - port: 389 - base_dn: 'ou=Users,dc=example,dc=org' - search_attribute: 'uid' - bind_password: 'password' - register: directory_again_result - - - assert: - that: directory_again_result.changed is sameas True - - - name: test - update host parameter in LDAP user directory - zabbix_user_directory: - idp_type: ldap - host: 'test.ca' - port: 389 - base_dn: 'ou=Users,dc=example,dc=org' - search_attribute: 'uid' - register: directory_update_result - - - assert: - that: directory_update_result.changed is sameas True - - - name: test - update host parameter in LDAP user directory again - zabbix_user_directory: - idp_type: ldap - host: 'test.ca' - port: 389 - base_dn: 'ou=Users,dc=example,dc=org' - search_attribute: 'uid' - register: directory_update_again_result - - - assert: - that: directory_update_again_result.changed is sameas False - - - name: test - add media type mapping with non-existing media type - zabbix_user_directory: - idp_type: ldap - host: 'test.ca' - port: 389 - base_dn: 'ou=Users,dc=example,dc=org' - search_attribute: 'uid' - provision_status: True - provision_media: - - name: Media1 - mediatype: EmailX - attribute: email - provision_groups: - - name: idpname1 - role: Guest role - user_groups: - - Guests - ignore_errors: True - register: directory_update_media_fail_result - - - assert: - that: directory_update_media_fail_result.failed is sameas True - - - name: test - add mappings - zabbix_user_directory: - idp_type: ldap - host: 'test.ca' - port: 389 - base_dn: 'ou=Users,dc=example,dc=org' - search_attribute: 'uid' - provision_status: True - group_name: cn - group_basedn: ou=Group,dc=example,dc=org - group_member: member - user_ref_attr: uid - group_filter: '(member=uid=%{ref},ou=Users,dc=example,dc=com)' - user_username: first_name - user_lastname: last_name - provision_media: - - name: Media1 - mediatype: Email - attribute: email1 - provision_groups: - - name: idpname1 - role: Guest role - user_groups: - - Guests - register: directory_update_media_result - - - assert: - that: directory_update_media_result.changed is sameas True - - - name: test - add mappings again - zabbix_user_directory: - idp_type: ldap - host: 'test.ca' - port: 389 - base_dn: 'ou=Users,dc=example,dc=org' - search_attribute: 'uid' - provision_status: True - group_name: cn - group_basedn: ou=Group,dc=example,dc=org - group_member: member - user_ref_attr: uid - group_filter: '(member=uid=%{ref},ou=Users,dc=example,dc=com)' - user_username: first_name - user_lastname: last_name - provision_media: - - name: Media1 - mediatype: Email - attribute: email1 - provision_groups: - - name: idpname1 - role: Guest role - user_groups: - - Guests - register: directory_update_media_again_result - - - assert: - that: directory_update_media_again_result.changed is sameas False - - - name: test - delete LDAP user directory - zabbix_user_directory: - state: absent - - - name: test - create new SAML user directory in check mode - zabbix_user_directory: - idp_type: saml - idp_entityid: http://okta.com/xxxxx - sp_entityid: zabbix - sso_url: http://xxxx.okta.com/app/xxxxxx_123dhu8o3 - username_attribute: usrEmail - check_mode: true - register: directory_check_result - - - assert: - that: directory_check_result.changed is sameas True - - - name: test - attempt to create new SAML user directory with not all mandatory parameters - zabbix_user_directory: - idp_type: saml - ignore_errors: true - register: directory_expect_fail_result - - - assert: - that: directory_expect_fail_result.failed is sameas True - - - name: test - create new SAML user directory - zabbix_user_directory: - idp_type: saml - idp_entityid: http://okta.com/xxxxx - sp_entityid: zabbix - sso_url: http://xxxx.okta.com/app/xxxxxx_123dhu8o3 - username_attribute: usrEmail - register: directory_create_result - - - assert: - that: directory_create_result.changed is sameas True - - - name: test - update SAML user directory with all optional parameters - zabbix_user_directory: - idp_type: saml - idp_entityid: http://okta.com/xxxxx - sp_entityid: zabbix - sso_url: http://xxxx.okta.com/app/xxxxxx_123dhu8o3 - username_attribute: usrEmail - slo_url: http://yyyy.okta.com - nameid_format: 'urn:oasis' - scim_status: true - encrypt_nameid: true - encrypt_assertions: true - sign_messages: true - sign_assertions: true - sign_authn_requests: true - sign_logout_requests: true - sign_logout_responses: true - register: directory_create_all_result - - - assert: - that: directory_create_all_result.changed is sameas True - - - name: test - update SAML user directory with all optional parameters again - zabbix_user_directory: - idp_type: saml - idp_entityid: http://okta.com/xxxxx - sp_entityid: zabbix - sso_url: http://xxxx.okta.com/app/xxxxxx_123dhu8o3 - username_attribute: usrEmail - slo_url: http://yyyy.okta.com - nameid_format: 'urn:oasis' - scim_status: true - encrypt_nameid: true - encrypt_assertions: true - sign_messages: true - sign_assertions: true - sign_authn_requests: true - sign_logout_requests: true - sign_logout_responses: true - register: directory_create_all_again_result - - - assert: - that: directory_create_all_again_result.changed is sameas False - - - name: test - delete SAML user directory - zabbix_user_directory: - state: absent - - - name: test - create new SAML user directory with mappings - zabbix_user_directory: - idp_type: saml - idp_entityid: http://okta.com/xxxxx - sp_entityid: zabbix - sso_url: http://xxxx.okta.com/app/xxxxxx_123dhu8o3 - username_attribute: usrEmail - provision_status: True - group_name: cn - user_username: first_name - user_lastname: last_name - provision_media: - - name: Media1 - mediatype: Email - attribute: email1 - provision_groups: - - name: idpname1 - role: Guest role - user_groups: - - Guests - register: directory_create_mappings_result - - - assert: - that: directory_create_mappings_result.changed is sameas True - - - name: test - create new SAML user directory with mappings again - zabbix_user_directory: - idp_type: saml - idp_entityid: http://okta.com/xxxxx - sp_entityid: zabbix - sso_url: http://xxxx.okta.com/app/xxxxxx_123dhu8o3 - username_attribute: usrEmail - provision_status: True - group_name: cn - user_username: first_name - user_lastname: last_name - provision_media: - - name: Media1 - mediatype: Email - attribute: email1 - provision_groups: - - name: idpname1 - role: Guest role - user_groups: - - Guests - register: directory_create_mappings_again_result - - - assert: - that: directory_create_mappings_again_result.changed is sameas False + - name: test - create new LDAP user directory in check mode + community.zabbix.zabbix_user_directory: + idp_type: ldap + host: "test.com" + port: 389 + base_dn: "ou=Users,dc=example,dc=org" + search_attribute: "uid" + check_mode: true + register: directory_check_result + + - ansible.builtin.assert: + that: directory_check_result.changed is sameas True + + - name: test - attempt to create new LDAP user directory with not all mandatory parameters + community.zabbix.zabbix_user_directory: + idp_type: ldap + host: "test.com" + port: 389 + ignore_errors: true + register: directory_expect_fail_result + + - ansible.builtin.assert: + that: directory_expect_fail_result.failed is sameas True + + - name: test - create new LDAP user directory withoud bind_password + community.zabbix.zabbix_user_directory: + idp_type: ldap + host: "test.com" + port: 389 + base_dn: "ou=Users,dc=example,dc=org" + search_attribute: "uid" + register: directory_result + + - ansible.builtin.assert: + that: directory_result.changed is sameas True + + - name: test - create new LDAP user directory without bind_password again + community.zabbix.zabbix_user_directory: + idp_type: ldap + host: "test.com" + port: 389 + base_dn: "ou=Users,dc=example,dc=org" + search_attribute: "uid" + register: directory_again_result + + - ansible.builtin.assert: + that: directory_again_result.changed is sameas False + + - name: test - delete LDAP user directory + community.zabbix.zabbix_user_directory: + state: absent + register: directory_delete_result + + - ansible.builtin.assert: + that: directory_delete_result.changed is sameas True + + - name: test - create new LDAP user directory with bind_password + community.zabbix.zabbix_user_directory: + idp_type: ldap + host: "test.com" + port: 389 + base_dn: "ou=Users,dc=example,dc=org" + search_attribute: "uid" + bind_password: "password" + register: directory_result + + - ansible.builtin.assert: + that: directory_result.changed is sameas True + + - name: test - create new LDAP user directory with bind_password again + community.zabbix.zabbix_user_directory: + idp_type: ldap + host: "test.com" + port: 389 + base_dn: "ou=Users,dc=example,dc=org" + search_attribute: "uid" + bind_password: "password" + register: directory_again_result + + - ansible.builtin.assert: + that: directory_again_result.changed is sameas True + + - name: test - update host parameter in LDAP user directory + community.zabbix.zabbix_user_directory: + idp_type: ldap + host: "test.ca" + port: 389 + base_dn: "ou=Users,dc=example,dc=org" + search_attribute: "uid" + register: directory_update_result + + - ansible.builtin.assert: + that: directory_update_result.changed is sameas True + + - name: test - update host parameter in LDAP user directory again + community.zabbix.zabbix_user_directory: + idp_type: ldap + host: "test.ca" + port: 389 + base_dn: "ou=Users,dc=example,dc=org" + search_attribute: "uid" + register: directory_update_again_result + + - ansible.builtin.assert: + that: directory_update_again_result.changed is sameas False + + - name: test - add media type mapping with non-existing media type + community.zabbix.zabbix_user_directory: + idp_type: ldap + host: "test.ca" + port: 389 + base_dn: "ou=Users,dc=example,dc=org" + search_attribute: "uid" + provision_status: True + provision_media: + - name: Media1 + mediatype: EmailX + attribute: email + provision_groups: + - name: idpname1 + role: Guest role + user_groups: + - Guests + ignore_errors: True + register: directory_update_media_fail_result + + - ansible.builtin.assert: + that: directory_update_media_fail_result.failed is sameas True + + - name: test - add mappings + community.zabbix.zabbix_user_directory: + idp_type: ldap + host: "test.ca" + port: 389 + base_dn: "ou=Users,dc=example,dc=org" + search_attribute: "uid" + provision_status: True + group_name: cn + group_basedn: ou=Group,dc=example,dc=org + group_member: member + user_ref_attr: uid + group_filter: "(member=uid=%{ref},ou=Users,dc=example,dc=com)" + user_username: first_name + user_lastname: last_name + provision_media: + - name: Media1 + mediatype: Email + attribute: email1 + provision_groups: + - name: idpname1 + role: Guest role + user_groups: + - Guests + register: directory_update_media_result + + - ansible.builtin.assert: + that: directory_update_media_result.changed is sameas True + + - name: test - add mappings again + community.zabbix.zabbix_user_directory: + idp_type: ldap + host: "test.ca" + port: 389 + base_dn: "ou=Users,dc=example,dc=org" + search_attribute: "uid" + provision_status: True + group_name: cn + group_basedn: ou=Group,dc=example,dc=org + group_member: member + user_ref_attr: uid + group_filter: "(member=uid=%{ref},ou=Users,dc=example,dc=com)" + user_username: first_name + user_lastname: last_name + provision_media: + - name: Media1 + mediatype: Email + attribute: email1 + provision_groups: + - name: idpname1 + role: Guest role + user_groups: + - Guests + register: directory_update_media_again_result + + - ansible.builtin.assert: + that: directory_update_media_again_result.changed is sameas False + + - name: test - delete LDAP user directory + community.zabbix.zabbix_user_directory: + state: absent + + - name: test - create new SAML user directory in check mode + community.zabbix.zabbix_user_directory: + idp_type: saml + idp_entityid: http://okta.com/xxxxx + sp_entityid: zabbix + sso_url: http://xxxx.okta.com/app/xxxxxx_123dhu8o3 + username_attribute: usrEmail + check_mode: true + register: directory_check_result + + - ansible.builtin.assert: + that: directory_check_result.changed is sameas True + + - name: test - attempt to create new SAML user directory with not all mandatory parameters + community.zabbix.zabbix_user_directory: + idp_type: saml + ignore_errors: true + register: directory_expect_fail_result + + - ansible.builtin.assert: + that: directory_expect_fail_result.failed is sameas True + + - name: test - create new SAML user directory + community.zabbix.zabbix_user_directory: + idp_type: saml + idp_entityid: http://okta.com/xxxxx + sp_entityid: zabbix + sso_url: http://xxxx.okta.com/app/xxxxxx_123dhu8o3 + username_attribute: usrEmail + register: directory_create_result + + - ansible.builtin.assert: + that: directory_create_result.changed is sameas True + + - name: test - update SAML user directory with all optional parameters + community.zabbix.zabbix_user_directory: + idp_type: saml + idp_entityid: http://okta.com/xxxxx + sp_entityid: zabbix + sso_url: http://xxxx.okta.com/app/xxxxxx_123dhu8o3 + username_attribute: usrEmail + slo_url: http://yyyy.okta.com + nameid_format: "urn:oasis" + scim_status: true + encrypt_nameid: true + encrypt_assertions: true + sign_messages: true + sign_assertions: true + sign_authn_requests: true + sign_logout_requests: true + sign_logout_responses: true + register: directory_create_all_result + + - ansible.builtin.assert: + that: directory_create_all_result.changed is sameas True + + - name: test - update SAML user directory with all optional parameters again + community.zabbix.zabbix_user_directory: + idp_type: saml + idp_entityid: http://okta.com/xxxxx + sp_entityid: zabbix + sso_url: http://xxxx.okta.com/app/xxxxxx_123dhu8o3 + username_attribute: usrEmail + slo_url: http://yyyy.okta.com + nameid_format: "urn:oasis" + scim_status: true + encrypt_nameid: true + encrypt_assertions: true + sign_messages: true + sign_assertions: true + sign_authn_requests: true + sign_logout_requests: true + sign_logout_responses: true + register: directory_create_all_again_result + + - ansible.builtin.assert: + that: directory_create_all_again_result.changed is sameas False + + - name: test - delete SAML user directory + community.zabbix.zabbix_user_directory: + state: absent + + - name: test - create new SAML user directory with mappings + community.zabbix.zabbix_user_directory: + idp_type: saml + idp_entityid: http://okta.com/xxxxx + sp_entityid: zabbix + sso_url: http://xxxx.okta.com/app/xxxxxx_123dhu8o3 + username_attribute: usrEmail + provision_status: True + group_name: cn + user_username: first_name + user_lastname: last_name + provision_media: + - name: Media1 + mediatype: Email + attribute: email1 + provision_groups: + - name: idpname1 + role: Guest role + user_groups: + - Guests + register: directory_create_mappings_result + + - ansible.builtin.assert: + that: directory_create_mappings_result.changed is sameas True + + - name: test - create new SAML user directory with mappings again + community.zabbix.zabbix_user_directory: + idp_type: saml + idp_entityid: http://okta.com/xxxxx + sp_entityid: zabbix + sso_url: http://xxxx.okta.com/app/xxxxxx_123dhu8o3 + username_attribute: usrEmail + provision_status: True + group_name: cn + user_username: first_name + user_lastname: last_name + provision_media: + - name: Media1 + mediatype: Email + attribute: email1 + provision_groups: + - name: idpname1 + role: Guest role + user_groups: + - Guests + register: directory_create_mappings_again_result + + - ansible.builtin.assert: + that: directory_create_mappings_again_result.changed is sameas False when: zabbix_version is version('6.4', '>=') diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user_info/tasks/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user_info/tasks/main.yml index 7228e12eb..1f1862586 100644 --- a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user_info/tasks/main.yml +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user_info/tasks/main.yml @@ -1,170 +1,94 @@ --- -# New user create test from here -- when: zabbix_version is version('5.4', '<') - block: - - name: test - Create a new Zabbix user - zabbix_user: - alias: example - name: user name - surname: user surname - usrgrps: - - Guests - - Disabled - passwd: G$jd_79!jw - lang: en_US - theme: blue-theme - autologin: false - autologout: '0' - refresh: '30' - rows_per_page: '200' - after_login_url: '' - user_medias: - - mediatype: Email - sendto: example@example.com - period: 1-7,00:00-24:00 - severity: - not_classified: false - information: true - warning: true - average: true - high: true - disaster: true - active: false - type: Zabbix super admin - state: present - register: create_zabbix_user_result - - - assert: - that: - - create_zabbix_user_result.changed is sameas true - - - name: test - Set definition_of_results variable of Zabbix 5.0 and lower - set_fact: - definition_of_results: - - get_user_info_result[user_info_key].alias == "example" - - get_user_info_result[user_info_key].autologin is defined - - get_user_info_result[user_info_key].autologout is defined - - get_user_info_result[user_info_key].lang is defined - - get_user_info_result[user_info_key].medias.0.active is defined - - get_user_info_result[user_info_key].medias.0.mediaid is defined - - get_user_info_result[user_info_key].medias.0.period is defined - - get_user_info_result[user_info_key].medias.0.sendto is defined - - get_user_info_result[user_info_key].medias.0.severity is defined - - get_user_info_result[user_info_key].medias.0.userid is defined - - get_user_info_result[user_info_key].name is defined - - get_user_info_result[user_info_key].refresh is defined - - get_user_info_result[user_info_key].rows_per_page is defined - - get_user_info_result[user_info_key].surname is defined - - get_user_info_result[user_info_key].theme is defined - - get_user_info_result[user_info_key].type is defined - - get_user_info_result[user_info_key].url is defined - - get_user_info_result[user_info_key].userid is defined - - get_user_info_result[user_info_key].users_status is defined - - get_user_info_result[user_info_key].usrgrps | length == 2 - - get_user_info_result[user_info_key].usrgrps.0.debug_mode is defined - - get_user_info_result[user_info_key].usrgrps.0.gui_access is defined - - get_user_info_result[user_info_key].usrgrps.0.name is defined - - get_user_info_result[user_info_key].usrgrps.0.users_status is defined - - get_user_info_result[user_info_key].usrgrps.0.usrgrpid is defined - - get_user_info_result[user_info_key].usrgrps.1.debug_mode is defined - - get_user_info_result[user_info_key].usrgrps.1.gui_access is defined - - get_user_info_result[user_info_key].usrgrps.1.name is defined - - get_user_info_result[user_info_key].usrgrps.1.users_status is defined - - get_user_info_result[user_info_key].usrgrps.1.usrgrpid is defined - -- when: zabbix_version is version('5.4', '>=') - block: - - name: test - Create a new Zabbix user - zabbix_user: - alias: example - name: user name - surname: user surname - usrgrps: - - Guests - - Disabled - passwd: G$jd_79!jw - lang: en_US - theme: blue-theme - autologin: false - autologout: '0' - refresh: '30' - rows_per_page: '200' - after_login_url: '' - user_medias: - - mediatype: Email - sendto: example@example.com - period: 1-7,00:00-24:00 - severity: - not_classified: false - information: true - warning: true - average: true - high: true - disaster: true - active: false - role_name: Super admin role - timezone: Asia/Tokyo - state: present - register: create_zabbix_user_result +- name: test - Create a new Zabbix user + community.zabbix.zabbix_user: + username: example + name: user name + surname: user surname + usrgrps: + - Guests + - Disabled + passwd: G$jd_79!jw + lang: en_US + theme: blue-theme + autologin: false + autologout: "0" + refresh: "30" + rows_per_page: "200" + after_login_url: "" + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: false + information: true + warning: true + average: true + high: true + disaster: true + active: false + role_name: Super admin role + timezone: Asia/Tokyo + state: present + register: create_zabbix_user_result - - assert: - that: - - create_zabbix_user_result.changed is sameas true +- ansible.builtin.assert: + that: + - create_zabbix_user_result.changed is sameas true - - name: test - Set definition_of_results variable of Zabbix 5.4 and higher - set_fact: - definition_of_results: - - get_user_info_result[user_info_key].alias == "example" - - get_user_info_result[user_info_key].autologin is defined - - get_user_info_result[user_info_key].autologout is defined - - get_user_info_result[user_info_key].lang is defined - - get_user_info_result[user_info_key].medias.0.active is defined - - get_user_info_result[user_info_key].medias.0.mediaid is defined - - get_user_info_result[user_info_key].medias.0.period is defined - - get_user_info_result[user_info_key].medias.0.sendto is defined - - get_user_info_result[user_info_key].medias.0.severity is defined - - get_user_info_result[user_info_key].medias.0.userid is defined - - get_user_info_result[user_info_key].name is defined - - get_user_info_result[user_info_key].refresh is defined - - get_user_info_result[user_info_key].rows_per_page is defined - - get_user_info_result[user_info_key].surname is defined - - get_user_info_result[user_info_key].theme is defined - - get_user_info_result[user_info_key].roleid is defined - - get_user_info_result[user_info_key].url is defined - - get_user_info_result[user_info_key].userid is defined - - get_user_info_result[user_info_key].users_status is defined - - get_user_info_result[user_info_key].timezone is defined - - get_user_info_result[user_info_key].usrgrps | length == 2 - - get_user_info_result[user_info_key].usrgrps.0.debug_mode is defined - - get_user_info_result[user_info_key].usrgrps.0.gui_access is defined - - get_user_info_result[user_info_key].usrgrps.0.name is defined - - get_user_info_result[user_info_key].usrgrps.0.users_status is defined - - get_user_info_result[user_info_key].usrgrps.0.usrgrpid is defined - - get_user_info_result[user_info_key].usrgrps.1.debug_mode is defined - - get_user_info_result[user_info_key].usrgrps.1.gui_access is defined - - get_user_info_result[user_info_key].usrgrps.1.name is defined - - get_user_info_result[user_info_key].usrgrps.1.users_status is defined - - get_user_info_result[user_info_key].usrgrps.1.usrgrpid is defined +- name: test - Set definition_of_results variable + ansible.builtin.set_fact: + definition_of_results: + - get_user_info_result[user_info_key].username == "example" + - get_user_info_result[user_info_key].autologin is defined + - get_user_info_result[user_info_key].autologout is defined + - get_user_info_result[user_info_key].lang is defined + - get_user_info_result[user_info_key].medias.0.active is defined + - get_user_info_result[user_info_key].medias.0.mediaid is defined + - get_user_info_result[user_info_key].medias.0.period is defined + - get_user_info_result[user_info_key].medias.0.sendto is defined + - get_user_info_result[user_info_key].medias.0.severity is defined + - get_user_info_result[user_info_key].medias.0.userid is defined + - get_user_info_result[user_info_key].name is defined + - get_user_info_result[user_info_key].refresh is defined + - get_user_info_result[user_info_key].rows_per_page is defined + - get_user_info_result[user_info_key].surname is defined + - get_user_info_result[user_info_key].theme is defined + - get_user_info_result[user_info_key].roleid is defined + - get_user_info_result[user_info_key].url is defined + - get_user_info_result[user_info_key].userid is defined + - get_user_info_result[user_info_key].users_status is defined + - get_user_info_result[user_info_key].timezone is defined + - get_user_info_result[user_info_key].usrgrps | length == 2 + - get_user_info_result[user_info_key].usrgrps.0.debug_mode is defined + - get_user_info_result[user_info_key].usrgrps.0.gui_access is defined + - get_user_info_result[user_info_key].usrgrps.0.name is defined + - get_user_info_result[user_info_key].usrgrps.0.users_status is defined + - get_user_info_result[user_info_key].usrgrps.0.usrgrpid is defined + - get_user_info_result[user_info_key].usrgrps.1.debug_mode is defined + - get_user_info_result[user_info_key].usrgrps.1.gui_access is defined + - get_user_info_result[user_info_key].usrgrps.1.name is defined + - get_user_info_result[user_info_key].usrgrps.1.users_status is defined + - get_user_info_result[user_info_key].usrgrps.1.usrgrpid is defined - name: "test - Get a zabbix user information" - zabbix_user_info: - alias: example + community.zabbix.zabbix_user_info: + username: example register: get_user_info_result - name: "test - Set key to user_info_key variable(This deals with the key being masked)" - set_fact: + ansible.builtin.set_fact: user_info_key: "{{ item }}" loop: "{{ get_user_info_result.keys() | list }}" when: - item | regex_search('_user') -- assert: +- ansible.builtin.assert: that: definition_of_results - - name: test - Create a new Zabbix user - zabbix_user: - alias: example2 + community.zabbix.zabbix_user: + username: example2 usrgrps: - Guests - Disabled @@ -172,28 +96,22 @@ state: present register: create_zabbix_user_result2 -- assert: +- ansible.builtin.assert: that: - create_zabbix_user_result2.changed is sameas true - name: "test - Get a zabbix user information" - zabbix_user_info: - alias: example2 + community.zabbix.zabbix_user_info: + username: example2 register: get_user_info_result2 - name: "test - Set key to user_info_key variable(This deals with the key being masked)" - set_fact: + ansible.builtin.set_fact: user_info_key: "{{ item }}" loop: "{{ get_user_info_result2.keys() | list }}" when: - item | regex_search('_user') -- assert: - that: - - get_user_info_result2[user_info_key].alias == "example2" - when: zabbix_version is version('5.4', '<') - -- assert: +- ansible.builtin.assert: that: - get_user_info_result2[user_info_key].username == "example2" - when: zabbix_version is version('5.4', '>=') diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user_role/tasks/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user_role/tasks/main.yml index 799bef30b..53e57a043 100644 --- a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user_role/tasks/main.yml +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user_role/tasks/main.yml @@ -1,106 +1,103 @@ --- -# New user role create test from here, only 6.0 and higher -- when: zabbix_version is version('6.0', '>=') - block: - - name: test - Create a new Zabbix role - zabbix_user_role: - state: present - name: Operators - type: User - rules: - ui.default_access: 0 - ui: - - name: "monitoring.hosts" - status: 0 - - name: "monitoring.maps" - status: 1 - register: create_zabbix_user_role_result +- name: test - Create a new Zabbix role + community.zabbix.zabbix_user_role: + state: present + name: Operators + type: User + rules: + ui.default_access: 0 + ui: + - name: "monitoring.hosts" + status: 0 + - name: "monitoring.maps" + status: 1 + register: create_zabbix_user_role_result - - assert: - that: - - create_zabbix_user_role_result.changed is sameas true +- ansible.builtin.assert: + that: + - create_zabbix_user_role_result.changed is sameas true - # Check user role idempotency - - name: test - Update a Zabbix role with same rules - zabbix_user_role: - state: present - name: Operators - type: User - rules: - ui.default_access: 0 - ui: - - name: "monitoring.hosts" - status: 0 - - name: "monitoring.maps" - status: 1 - register: create_zabbix_user_role_result +# Check user role idempotency +- name: test - Update a Zabbix role with same rules + community.zabbix.zabbix_user_role: + state: present + name: Operators + type: User + rules: + ui.default_access: 0 + ui: + - name: "monitoring.hosts" + status: 0 + - name: "monitoring.maps" + status: 1 + register: create_zabbix_user_role_result - - assert: - that: - - create_zabbix_user_role_result.changed is sameas false +- ansible.builtin.assert: + that: + - create_zabbix_user_role_result.changed is sameas false - # Check user role change - - name: test - Update a Zabbix role with new rules - zabbix_user_role: - state: present - name: Operators - type: User - rules: - ui.default_access: 0 - ui: - - name: "monitoring.hosts" - status: 1 - - name: "monitoring.maps" - status: 0 - register: create_zabbix_user_role_result +# Check user role change +- name: test - Update a Zabbix role with new rules + community.zabbix.zabbix_user_role: + state: present + name: Operators + type: User + rules: + ui.default_access: 0 + ui: + - name: "monitoring.hosts" + status: 1 + - name: "monitoring.maps" + status: 0 + register: create_zabbix_user_role_result - - assert: - that: - - create_zabbix_user_role_result.changed is sameas true +- ansible.builtin.assert: + that: + - create_zabbix_user_role_result.changed is sameas true - # Check user role remove - - name: test - Remove Zabbix role - zabbix_user_role: - state: absent - name: Operators - register: create_zabbix_user_role_result +# Check user role remove +- name: test - Remove Zabbix role + community.zabbix.zabbix_user_role: + state: absent + name: Operators + register: create_zabbix_user_role_result - - assert: - that: - - create_zabbix_user_role_result.changed is sameas true +- ansible.builtin.assert: + that: + - create_zabbix_user_role_result.changed is sameas true - - name: test - Create a new Zabbix role type Admin - zabbix_user_role: - state: present - name: Admins - type: Admin - rules: - ui.default_access: 0 - register: create_zabbix_user_role_admin_result +- name: test - Create a new Zabbix role type Admin + community.zabbix.zabbix_user_role: + state: present + name: Admins + type: Admin + rules: + ui.default_access: 0 + register: create_zabbix_user_role_admin_result - - assert: - that: - - create_zabbix_user_role_admin_result.changed is sameas true +- ansible.builtin.assert: + that: + - create_zabbix_user_role_admin_result.changed is sameas true - - name: test - Remove Zabbix role type Admin - zabbix_user_role: - state: absent - name: Admins +- name: test - Remove Zabbix role type Admin + community.zabbix.zabbix_user_role: + state: absent + name: Admins - - name: test - Create a new Zabbix role type Super Admin - zabbix_user_role: - state: present - name: Super Admins - type: Super Admin - rules: - ui.default_access: 0 - register: create_zabbix_user_role_super_admin_result +- name: test - Create a new Zabbix role type Super Admin + community.zabbix.zabbix_user_role: + state: present + name: Super Admins + type: Super Admin + rules: + ui.default_access: 0 + register: create_zabbix_user_role_super_admin_result - - assert: - that: - - create_zabbix_user_role_super_admin_result.changed is sameas true +- ansible.builtin.assert: + that: + - create_zabbix_user_role_super_admin_result.changed is sameas true - - name: test - Remove Zabbix role type Super Admin - zabbix_user_role: - state: absent - name: Super Admins +- name: test - Remove Zabbix role type Super Admin + community.zabbix.zabbix_user_role: + state: absent + name: Super Admins diff --git a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_usergroup/tasks/main.yml b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_usergroup/tasks/main.yml index f7a6aa60e..d1922315b 100644 --- a/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_usergroup/tasks/main.yml +++ b/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_usergroup/tasks/main.yml @@ -1,278 +1,273 @@ --- -- name: test - do not run tests for Zabbix 3.0 - meta: end_play - when: zabbix_version is version('3.0', '=') - - name: test - Zabbix user group module_defaults: community.zabbix.zabbix_usergroup: name: ACME block: - - name: test - create new Zabbix user group - zabbix_usergroup: - state: present - register: usergroup_new - - - name: assert that user group was created - assert: - that: usergroup_new is changed - - - name: test - create new Zabbix user group (again) - zabbix_usergroup: - state: present - register: usergroup_again - - - name: assert that user group was created - assert: - that: not usergroup_again is changed - - - name: test - update Zabbix user group with disabled gui_access - zabbix_usergroup: - gui_access: disable - register: usergroup_updated - - - name: assert that user group was updated - assert: - that: usergroup_updated is changed - - - name: test - update Zabbix user group with disabled gui_access (again) - zabbix_usergroup: - gui_access: disable - register: usergroup_updated_again - - - name: assert that user group was updated - assert: - that: not usergroup_updated_again is changed - - - name: test - reset Zabbix user group to default - zabbix_usergroup: - register: usergroup_reset - - - name: assert that user group was created - assert: - that: usergroup_reset is changed - - - when: zabbix_version is version('6.2', '<') - block: - - name: test - update Zabbix user group with one right - zabbix_usergroup: - rights: - - host_group: Discovered hosts - permission: read-only - register: usergroup_updated_right + - name: test - create new Zabbix user group + community.zabbix.zabbix_usergroup: + state: present + register: usergroup_new - - name: assert that user group was updated - assert: - that: usergroup_updated_right is changed + - name: assert that user group was created + ansible.builtin.assert: + that: usergroup_new is changed - - name: test - update Zabbix user group with multiple rights - zabbix_usergroup: - rights: - - host_group: Discovered hosts - permission: read-only - - host_group: Zabbix servers - permission: read-write - register: usergroup_updated_rights + - name: test - create new Zabbix user group (again) + community.zabbix.zabbix_usergroup: + state: present + register: usergroup_again - - name: assert that user group was updated - assert: - that: usergroup_updated_rights is changed + - name: assert that user group was created + ansible.builtin.assert: + that: not usergroup_again is changed - - name: test - update Zabbix user group with multiple rights (again) - zabbix_usergroup: - rights: - - host_group: Discovered hosts - permission: read-only - - host_group: Zabbix servers - permission: read-write - register: usergroup_updated_rights_again - - - name: assert that user group was not updated - assert: - that: not usergroup_updated_rights_again is changed - - - when: zabbix_version is version('6.2', '>=') - block: - - name: test - update Zabbix user group with one hostgroup right - zabbix_usergroup: - hostgroup_rights: - - host_group: Discovered hosts - permission: read-only - register: usergroup_updated_hostgroup_right + - name: test - update Zabbix user group with disabled gui_access + community.zabbix.zabbix_usergroup: + gui_access: disable + register: usergroup_updated - name: assert that user group was updated - assert: - that: usergroup_updated_hostgroup_right is changed + ansible.builtin.assert: + that: usergroup_updated is changed - - name: test - update Zabbix user group with multiple hostgroup rights - zabbix_usergroup: - hostgroup_rights: - - host_group: Discovered hosts - permission: read-only - - host_group: Zabbix servers - permission: read-write - register: usergroup_updated_hostgroup_rights + - name: test - update Zabbix user group with disabled gui_access (again) + community.zabbix.zabbix_usergroup: + gui_access: disable + register: usergroup_updated_again - name: assert that user group was updated - assert: - that: usergroup_updated_hostgroup_rights is changed - - - name: test - update Zabbix user group with multiple hostgroup rights (again) - zabbix_usergroup: - hostgroup_rights: - - host_group: Discovered hosts - permission: read-only - - host_group: Zabbix servers - permission: read-write - register: usergroup_updated_hostgroup_rights_again - - - name: assert that user group was not updated - assert: - that: not usergroup_updated_hostgroup_rights_again is changed - - - name: test - update Zabbix user group with one template group right - zabbix_usergroup: - hostgroup_rights: + ansible.builtin.assert: + that: not usergroup_updated_again is changed + + - name: test - reset Zabbix user group to default + community.zabbix.zabbix_usergroup: + register: usergroup_reset + + - name: assert that user group was created + ansible.builtin.assert: + that: usergroup_reset is changed + + - when: zabbix_version is version('6.2', '<') + block: + - name: test - update Zabbix user group with one right + community.zabbix.zabbix_usergroup: + rights: + - host_group: Discovered hosts + permission: read-only + register: usergroup_updated_right + + - name: assert that user group was updated + ansible.builtin.assert: + that: usergroup_updated_right is changed + + - name: test - update Zabbix user group with multiple rights + community.zabbix.zabbix_usergroup: + rights: + - host_group: Discovered hosts + permission: read-only + - host_group: Zabbix servers + permission: read-write + register: usergroup_updated_rights + + - name: assert that user group was updated + ansible.builtin.assert: + that: usergroup_updated_rights is changed + + - name: test - update Zabbix user group with multiple rights (again) + community.zabbix.zabbix_usergroup: + rights: + - host_group: Discovered hosts + permission: read-only + - host_group: Zabbix servers + permission: read-write + register: usergroup_updated_rights_again + + - name: assert that user group was not updated + ansible.builtin.assert: + that: not usergroup_updated_rights_again is changed + + - when: zabbix_version is version('6.2', '>=') + block: + - name: test - update Zabbix user group with one hostgroup right + community.zabbix.zabbix_usergroup: + hostgroup_rights: + - host_group: Discovered hosts + permission: read-only + register: usergroup_updated_hostgroup_right + + - name: assert that user group was updated + ansible.builtin.assert: + that: usergroup_updated_hostgroup_right is changed + + - name: test - update Zabbix user group with multiple hostgroup rights + community.zabbix.zabbix_usergroup: + hostgroup_rights: + - host_group: Discovered hosts + permission: read-only + - host_group: Zabbix servers + permission: read-write + register: usergroup_updated_hostgroup_rights + + - name: assert that user group was updated + ansible.builtin.assert: + that: usergroup_updated_hostgroup_rights is changed + + - name: test - update Zabbix user group with multiple hostgroup rights (again) + community.zabbix.zabbix_usergroup: + hostgroup_rights: + - host_group: Discovered hosts + permission: read-only + - host_group: Zabbix servers + permission: read-write + register: usergroup_updated_hostgroup_rights_again + + - name: assert that user group was not updated + ansible.builtin.assert: + that: not usergroup_updated_hostgroup_rights_again is changed + + - name: test - update Zabbix user group with one template group right + community.zabbix.zabbix_usergroup: + hostgroup_rights: + - host_group: Discovered hosts + permission: read-only + - host_group: Zabbix servers + permission: read-write + templategroup_rights: + - template_group: Templates + permission: read-only + register: usergroup_updated_templategroup_right + + - name: assert that user group was updated + ansible.builtin.assert: + that: usergroup_updated_templategroup_right is changed + + - name: test - update Zabbix user group with multiple template group rights + community.zabbix.zabbix_usergroup: + hostgroup_rights: + - host_group: Discovered hosts + permission: read-only + - host_group: Zabbix servers + permission: read-write + templategroup_rights: + - template_group: Templates + permission: read-only + - template_group: Templates/Applications + permission: read-write + register: usergroup_updated_templategroup_rights + + - name: assert that user group was updated + ansible.builtin.assert: + that: usergroup_updated_templategroup_right is changed + + - name: test - update Zabbix user group with multiple template group rights (again) + community.zabbix.zabbix_usergroup: + hostgroup_rights: + - host_group: Discovered hosts + permission: read-only + - host_group: Zabbix servers + permission: read-write + templategroup_rights: + - template_group: Templates + permission: read-only + - template_group: Templates/Applications + permission: read-write + register: usergroup_updated_templategroup_rights_again + + - name: assert that user group was not updated + ansible.builtin.assert: + that: not usergroup_updated_templategroup_rights_again is changed + + - name: test - reset Zabbix user group to default + community.zabbix.zabbix_usergroup: + register: usergroup_reset + + - name: assert that user group was created + ansible.builtin.assert: + that: usergroup_reset is changed + + - name: test - update Zabbix user group with one tag_filter + community.zabbix.zabbix_usergroup: + tag_filters: - host_group: Discovered hosts - permission: read-only - - host_group: Zabbix servers - permission: read-write - templategroup_rights: - - template_group: Templates - permission: read-only - register: usergroup_updated_templategroup_right + tag: Service + value: JIRA + register: usergroup_updated_tag_filter - name: assert that user group was updated - assert: - that: usergroup_updated_templategroup_right is changed + ansible.builtin.assert: + that: usergroup_updated_tag_filter is changed - - name: test - update Zabbix user group with multiple template group rights - zabbix_usergroup: - hostgroup_rights: + - name: test - update Zabbix user group with multiple tag_filters + community.zabbix.zabbix_usergroup: + tag_filters: - host_group: Discovered hosts - permission: read-only - - host_group: Zabbix servers - permission: read-write - templategroup_rights: - - template_group: Templates - permission: read-only - - template_group: Templates/Applications - permission: read-write - register: usergroup_updated_templategroup_rights - - - name: assert that user group was updated - assert: - that: usergroup_updated_templategroup_right is changed - - - name: test - update Zabbix user group with multiple template group rights (again) - zabbix_usergroup: - hostgroup_rights: + tag: Service + value: JIRA - host_group: Discovered hosts - permission: read-only - - host_group: Zabbix servers - permission: read-write - templategroup_rights: - - template_group: Templates - permission: read-only - - template_group: Templates/Applications - permission: read-write - register: usergroup_updated_templategroup_rights_again - - - name: assert that user group was not updated - assert: - that: not usergroup_updated_templategroup_rights_again is changed - - - name: test - reset Zabbix user group to default - zabbix_usergroup: - register: usergroup_reset - - - name: assert that user group was created - assert: - that: usergroup_reset is changed - - - name: test - update Zabbix user group with one tag_filter - zabbix_usergroup: - tag_filters: - - host_group: Discovered hosts - tag: Service - value: JIRA - register: usergroup_updated_tag_filter - - - name: assert that user group was updated - assert: - that: usergroup_updated_tag_filter is changed - - - name: test - update Zabbix user group with multiple tag_filters - zabbix_usergroup: - tag_filters: - - host_group: Discovered hosts - tag: Service - value: JIRA - - host_group: Discovered hosts - tag: Service - value: Zabbix - register: usergroup_updated_tag_filters - - - name: assert that user group was updated - assert: - that: usergroup_updated_tag_filters is changed - - - name: test - reset Zabbix user group to default - zabbix_usergroup: - - - when: zabbix_version is version('6.2', '>=') - block: - - name: test - create new user directory - zabbix_user_directory: - name: LDAP infra 1 - host: 'test.com' - port: 389 - base_dn: 'ou=Users,dc=example,dc=org' - search_attribute: 'uid' - when: zabbix_version is version('6.4', '<') - - - name: test - create new user directory - zabbix_user_directory: - name: LDAP infra 1 - idp_type: ldap - host: 'test.com' - port: 389 - base_dn: 'ou=Users,dc=example,dc=org' - search_attribute: 'uid' - when: zabbix_version is version('6.4', '>=') - - - name: test - update Zabbix user group with user directory - zabbix_usergroup: - userdirectory: LDAP infra 1 - register: usergroup_create_userdir + tag: Service + value: Zabbix + register: usergroup_updated_tag_filters - name: assert that user group was updated - assert: - that: usergroup_create_userdir is changed - - - name: test - update Zabbix user group with user directory (again) - zabbix_usergroup: - userdirectory: LDAP infra 1 - register: usergroup_create_userdir_again - - - name: assert that user group was not updated - assert: - that: not usergroup_create_userdir_again is changed - - - name: test - delete Zabbix user group - zabbix_usergroup: - state: absent - register: usergroup_delete - - - name: assert that Zabbix user group has been deleted - assert: - that: usergroup_delete is changed - - - - name: test - delete user directory - zabbix_user_directory: - name: LDAP infra 1 - host: 'test.com' - state: absent - when: zabbix_version is version('6.2', '>=') + ansible.builtin.assert: + that: usergroup_updated_tag_filters is changed + + - name: test - reset Zabbix user group to default + community.zabbix.zabbix_usergroup: + + - when: zabbix_version is version('6.2', '>=') + block: + - name: test - create new user directory + community.zabbix.zabbix_user_directory: + name: LDAP infra 1 + host: "test.com" + port: 389 + base_dn: "ou=Users,dc=example,dc=org" + search_attribute: "uid" + when: zabbix_version is version('6.4', '<') + + - name: test - create new user directory + community.zabbix.zabbix_user_directory: + name: LDAP infra 1 + idp_type: ldap + host: "test.com" + port: 389 + base_dn: "ou=Users,dc=example,dc=org" + search_attribute: "uid" + when: zabbix_version is version('6.4', '>=') + + - name: test - update Zabbix user group with user directory + community.zabbix.zabbix_usergroup: + userdirectory: LDAP infra 1 + register: usergroup_create_userdir + + - name: assert that user group was updated + ansible.builtin.assert: + that: usergroup_create_userdir is changed + + - name: test - update Zabbix user group with user directory (again) + community.zabbix.zabbix_usergroup: + userdirectory: LDAP infra 1 + register: usergroup_create_userdir_again + + - name: assert that user group was not updated + ansible.builtin.assert: + that: not usergroup_create_userdir_again is changed + + - name: test - delete Zabbix user group + community.zabbix.zabbix_usergroup: + state: absent + register: usergroup_delete + + - name: assert that Zabbix user group has been deleted + ansible.builtin.assert: + that: usergroup_delete is changed + + - name: test - delete user directory + community.zabbix.zabbix_user_directory: + name: LDAP infra 1 + host: "test.com" + state: absent + when: zabbix_version is version('6.2', '>=') |