diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-14 20:03:01 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-14 20:03:01 +0000 |
commit | a453ac31f3428614cceb99027f8efbdb9258a40b (patch) | |
tree | f61f87408f32a8511cbd91799f9cececb53e0374 /collections-debian-merged/ansible_collections/community/zabbix/tests | |
parent | Initial commit. (diff) | |
download | ansible-a453ac31f3428614cceb99027f8efbdb9258a40b.tar.xz ansible-a453ac31f3428614cceb99027f8efbdb9258a40b.zip |
Adding upstream version 2.10.7+merged+base+2.10.8+dfsg.upstream/2.10.7+merged+base+2.10.8+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'collections-debian-merged/ansible_collections/community/zabbix/tests')
54 files changed, 8911 insertions, 0 deletions
diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/setup_zabbix/defaults/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/setup_zabbix/defaults/main.yml new file mode 100644 index 00000000..85e8c620 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/setup_zabbix/defaults/main.yml @@ -0,0 +1,4 @@ +--- +zabbix_server_url: http://127.0.0.1:8080 +zabbix_login_user: Admin +zabbix_login_password: zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/setup_zabbix/tasks/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/setup_zabbix/tasks/main.yml new file mode 100644 index 00000000..b790ea1f --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/setup_zabbix/tasks/main.yml @@ -0,0 +1,40 @@ +--- +- name: check login to zabbix + uri: + url: "{{ zabbix_server_url }}/api_jsonrpc.php" + method: POST + body: + jsonrpc: "2.0" + method: "user.login" + params: + user: "{{ zabbix_login_user }}" + password: "{{ zabbix_login_password }}" + id: "1" + body_format: json + status_code: 200 + retries: 60 + delay: 5 + until: check_login_result is defined and 'json' in check_login_result and 'result' in check_login_result.json + register: check_login_result + +- name: get zabbix version + uri: + url: "{{ zabbix_server_url }}/api_jsonrpc.php" + method: POST + body: + jsonrpc: "2.0" + method: "apiinfo.version" + params: [] + id: "1" + body_format: json + status_code: 200 + register: zabbix_version_result + +- name: set zabbix_version variable + set_fact: + zabbix_version: >- + {{ [0,1] + | map('extract', zabbix_version_result.json.result.split('.')) + | list + | join('.') + }} diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_action/meta/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_action/meta/main.yml new file mode 100644 index 00000000..d3007478 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_action/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_action/tasks/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_action/tasks/main.yml new file mode 100644 index 00000000..df91f321 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_action/tasks/main.yml @@ -0,0 +1,1169 @@ +--- +- 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_server_url }} " + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_name: ExampleTemplateForActionModule + template_groups: + - Templates + state: present + register: zbxaction_prep_template + +- name: test - prepare example mediatype for zabbix_action module + zabbix_mediatype: + server_url: "{{ zabbix_server_url }} " + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleMediaTypeForActionModule + smtp_email: zabbix@example.com + type: email + state: present + register: zbxaction_prep_mediatype + +- name: test - simple actions + module_defaults: + zabbix_action: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + state: present + status: enabled + name: ExampleTriggerAction + event_source: trigger + esc_period: 60 + conditions: + - type: trigger_severity + operator: '>=' + value: Information + operations: + - type: send_message + subject: ExampleSubject + message: ExampleMessage + media_type: ExampleMediaTypeForActionModule + send_to_users: + - Admin + + block: + - name: test - create new action + zabbix_action: + register: zbxaction_new + + - assert: + that: zbxaction_new.changed is sameas True + + - name: test - create new action (again) + zabbix_action: + register: zbxaction_new + + - 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: + esc_period: 2m + register: zbxaction_escperiod_str + + - assert: + that: zbxaction_escperiod_str.changed is sameas True + + - name: test - update action with esc_period as string (again) + zabbix_action: + esc_period: 2m + register: zbxaction_escperiod_str + + - assert: + that: zbxaction_escperiod_str.changed is sameas False + + - name: test - update action with esc_period as macro + zabbix_action: + esc_period: '{$MYMACRO}' + register: zbxaction_escperiod_macro + + - assert: + that: zbxaction_escperiod_macro.changed is sameas True + + - name: test - update action with esc_period as macro (again) + zabbix_action: + esc_period: '{$MYMACRO}' + register: zbxaction_escperiod_macro + + - 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 - reset action to default + zabbix_action: + register: zbxaction_reset + + - assert: + that: zbxaction_reset.changed is sameas True + + - name: test - disable action + zabbix_action: + status: disabled + register: zbxaction_disable + + - assert: + that: zbxaction_disable.changed is sameas True + + - name: test - disable action (again) + zabbix_action: + status: disabled + register: zbxaction_disable + + - assert: + that: zbxaction_disable.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 - delete action (again) + zabbix_action: + state: absent + register: zbxaction_delete + + - assert: + that: zbxaction_delete.changed is sameas False + +- name: test - trigger actions with conditions + module_defaults: + zabbix_action: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + state: present + status: enabled + name: ExampleTriggerActionConditions + event_source: trigger + esc_period: 60 + operations: + - type: send_message + subject: ExampleSubject + 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: application + operator: like + value: AnsibleTest + - 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: application + operator: like + value: AnsibleTest + - 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: application + operator: like + value: AnsibleTest + - 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 True + + - name: test - update action with multiple conditions by removing one condition + zabbix_action: + conditions: + - type: host_group + operator: '=' + value: Linux servers + - type: application + operator: like + value: AnsibleTest + - 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: application + operator: not like + value: AnsibleTest + - 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 and evaltype + zabbix_action: + conditions: + - type: host_group + operator: '<>' + value: Linux servers + - type: application + operator: not like + value: AnsibleTest + - 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: application + operator: not like + value: AnsibleTest + - 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 - trigger actions with operations + module_defaults: + zabbix_action: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + state: present + status: enabled + name: ExampleTriggerActionOperations + event_source: trigger + esc_period: 60 + conditions: + - type: trigger_severity + 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 - 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 - discovery actions + module_defaults: + zabbix_action: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + state: present + status: enabled + name: ExampleDiscoveryActionOperations + event_source: discovery + 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 + + - assert: + that: zbxaction_discovery_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 - auto registration actions + module_defaults: + zabbix_action: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + state: present + status: enabled + name: ExampleAutoRegActionOperations + event_source: auto_registration + 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 - internal actions + module_defaults: + zabbix_action: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + state: present + status: enabled + name: ExampleInternalActionOperations + event_source: internal + esc_period: 60 + operations: + - type: send_message + send_to_users: + - Admin + subject: test_subject + message: test_message + media_type: ExampleMediaTypeForActionModule + + block: + - name: test - create new internal action + zabbix_action: + conditions: + - type: application + operator: like + value: zabbix + - 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: application + operator: like + value: zabbix + - 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: application + operator: like + value: zabbix + - 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: application + operator: like + value: zabbix + - 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 + when: + - zabbix_version is version('3.4', '>=') + module_defaults: + zabbix_action: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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 + 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 - cleanup example template for zabbix_action module + zabbix_template: + server_url: "{{ zabbix_server_url }} " + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_name: ExampleTemplateForActionModule + state: absent + register: zbxaction_prep_template + +- name: test - cleanup example mediatype for zabbix_action module + zabbix_mediatype: + server_url: "{{ zabbix_server_url }} " + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleMediaTypeForActionModule + type: email + state: absent + register: zbxaction_prep_mediatype diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_discovery_rule/meta/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_discovery_rule/meta/main.yml new file mode 100644 index 00000000..d3007478 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_discovery_rule/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_discovery_rule/tasks/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_discovery_rule/tasks/main.yml new file mode 100644 index 00000000..5f31d48d --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_discovery_rule/tasks/main.yml @@ -0,0 +1,295 @@ +--- +- 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: + zabbix_discovery_rule: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ACME + state: present + 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: yes + 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: no + 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: no + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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 - delete Zabbix discovery rule + zabbix_discovery_rule: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ACME + state: absent + register: drule_delete + +- name: assert that proxy has been deleted + assert: + that: drule_delete is changed + +- name: test - delete Zabbix discovery rule (again) + zabbix_discovery_rule: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ACME + state: absent + register: drule_delete_again + +- name: assert that nothing has been changed + assert: + that: not drule_delete_again is changed + +# Cleanup +- name: delete active Zabbix proxy server + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: ACME_proxy + state: absent + register: zbxproxy_delete + +- name: assert that proxy has been deleted + assert: + that: zbxproxy_delete is changed diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group/meta/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group/meta/main.yml new file mode 100644 index 00000000..d3007478 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group/tasks/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group/tasks/main.yml new file mode 100644 index 00000000..f4021709 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group/tasks/main.yml @@ -0,0 +1,112 @@ +--- +- name: test - create new Zabbix group + zabbix_group: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_groups: + - zbxgrp_example_group01 + state: present + register: zbxgrp_new + +- name: assert that group was created + assert: + that: zbxgrp_new is changed + +- name: test - create simple zabbix host to assign to group + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: zbxgrp_example_host01 + host_groups: + - zbxgrp_example_group01 + interfaces: + - type: agent + main: 1 + dns: zbxgrp_example_host01 + state: present + register: zbxgrp_host_assignement + +- name: assert that host was assigned successfully + assert: + that: zbxgrp_host_assignement is changed + +- name: test - create same Zabbix group once again + zabbix_group: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_groups: + - zbxgrp_example_group01 + state: present + register: zbxgrp_existing + +- name: assert that nothing has been changed + assert: + that: not zbxgrp_existing is changed + +- name: test - attempt to create new Zabbix group matching name of default Zabbix group + zabbix_group: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_groups: + - Linux servers + state: present + register: zbxgrp_default_existing + +- name: assert that nothing has been changed + assert: + that: not zbxgrp_default_existing is changed + +- name: test - attempt to delete host group while its only group host has assigned + zabbix_group: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_groups: + - zbxgrp_example_group01 + state: absent + register: zbxgrp_existing_delete_failed + ignore_errors: True + +- name: assert that group deletion failed + assert: + that: zbxgrp_existing_delete_failed is failed + +- name: delete helper zabbix host + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: zbxgrp_example_host01 + state: absent + +- name: test - attempt to delete previously created zabbix group + zabbix_group: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_groups: + - zbxgrp_example_group01 + state: absent + register: zbxgrp_existing_delete + +- name: assert that group was deleted + assert: + that: zbxgrp_existing_delete is changed + +- name: test - attempt to delete non-existing zabbix group + zabbix_group: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_groups: + - zbxgrp_example_group01 + state: absent + register: zbxgrp_missing_delete + +- name: assert that nothing has been changed + assert: + that: not zbxgrp_missing_delete is changed diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group_info/meta/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group_info/meta/main.yml new file mode 100644 index 00000000..d3007478 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group_info/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group_info/tasks/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group_info/tasks/main.yml new file mode 100644 index 00000000..599b626e --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_group_info/tasks/main.yml @@ -0,0 +1,62 @@ +--- +- name: test - create new Zabbix group + zabbix_group: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_groups: + - zbxgrp_example_group01 + - zbxgrp_example_group02 + state: present + register: zbxgrp_new + +- name: assert that group was created + assert: + that: zbxgrp_new is changed + +- name: test - get one hostgroup info + zabbix_group_info: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + hostgroup_name: + - zbxgrp_example_group01 + register: get_hostgorup_info_result + +- name: assert that one group was get + assert: + that: + - get_hostgorup_info_result.host_groups | length == 1 + - get_hostgorup_info_result.host_groups.0.name == 'zbxgrp_example_group01' + +- name: test - get two hostgroup info + zabbix_group_info: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + hostgroup_name: + - zbxgrp_example_group01 + - zbxgrp_example_group02 + register: get_hostgorup_info_result + +- name: assert that two group was get + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_groups: + - zbxgrp_example_group01 + - zbxgrp_example_group02 + state: absent + register: delete_zbxgrp + +- name: assert that group was deleted + assert: + that: delete_zbxgrp is changed diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/meta/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/meta/main.yml new file mode 100644 index 00000000..d3007478 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/main.yml new file mode 100644 index 00000000..f7aeefab --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/main.yml @@ -0,0 +1,12 @@ +--- +# setup stuff not testing zabbix_host +- include: zabbix_host_setup.yml + +# zabbix_host module tests +- include: zabbix_host_tests.yml + +# documentation example tests +- include: zabbix_host_doc.yml + +# tear down stuff set up earlier +- include: zabbix_host_teardown.yml diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_doc.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_doc.yml new file mode 100644 index 00000000..1710f750 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_doc.yml @@ -0,0 +1,83 @@ +--- +# These two tests are close to documentation example + +- name: Create a new host or update an existing host's info + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost1 + visible_name: ExampleName + description: My ExampleHost Description + host_groups: + - 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' }}" + status: enabled + state: present + inventory_mode: manual + inventory_zabbix: + tag: test-tag + alias: test-alias + notes: "Special Informations: test-info" + location: test-location + site_rack: test-rack + os: test-os + hardware: test-hw + ipmi_authtype: 2 + ipmi_privilege: 4 + ipmi_username: username + ipmi_password: password + interfaces: + - type: 1 + main: 1 + useip: 1 + ip: 10.1.1.1 + dns: "" + port: "10050" + - type: 4 + main: 1 + useip: 1 + ip: 10.1.1.1 + dns: "" + port: "12345" + macros: + - macro: '{$EXAMPLEMACRO}' + value: ExampleMacroValue + - macro: EXAMPLEMACRO2 + value: ExampleMacroValue2 + description: Example desc that work only with Zabbix 4.4 and higher + tags: + - tag: ExampleHostsTag + - tag: ExampleHostsTag2 + value: ExampleTagValue + register: zabbix_host1 + +- name: Update an existing host's tls settings + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost2 + visible_name: ExampleName2 + interfaces: + - type: 1 + main: 1 + useip: 1 + ip: 10.1.1.2 + dns: "" + port: "10050" + host_groups: + - Linux servers + tls_psk_identity: test + tls_connect: 2 + tls_psk: 123456789abcdef123456789abcdef12 + register: zabbix_host2 + +- name: expect both to succeed + assert: + that: + - "zabbix_host1 is changed" + - "zabbix_host2 is changed" diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_setup.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_setup.yml new file mode 100644 index 00000000..498a725f --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_setup.yml @@ -0,0 +1,20 @@ +--- +# set up a zabbix proxy to test zabbix_host with + +- name: Create a new proxy + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: ExampleProxy + description: ExampleProxy + status: active + state: present + interface: + type: 0 + main: 1 + useip: 1 + ip: 10.5.6.7 + dns: "" + port: 10050 + register: zabbix_proxy diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_teardown.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_teardown.yml new file mode 100644 index 00000000..1d76c516 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_teardown.yml @@ -0,0 +1,10 @@ +--- +# remove zabbix_proxy (hopefully) created earlier + +- name: remove proxy + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: ExampleProxy + state: absent diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_tests.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_tests.yml new file mode 100644 index 00000000..bf701471 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host/tasks/zabbix_host_tests.yml @@ -0,0 +1,1488 @@ +--- +- name: "test: create host with many options set" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + visible_name: ExampleName + description: My ExampleHost Description + host_groups: + - 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' }}" + status: enabled + state: present + inventory_mode: manual + inventory_zabbix: + tag: test-tag + alias: test-alias + notes: "Special Informations: test-info" + location: test-location + site_rack: test-rack + os: test-os + hardware: test-hw + interfaces: + - type: 1 + main: 1 + useip: 1 + ip: 10.1.1.1 + dns: "" + port: "10050" + - type: 1 + main: 0 + useip: 1 + ip: 10.1.1.1 + dns: "" + port: "{$MACRO}" + - type: 4 + main: 1 + useip: 1 + ip: 10.1.1.1 + dns: "" + port: "12345" + proxy: ExampleProxy + tls_psk_identity: test + tls_connect: 2 + tls_psk: 123456789abcdef123456789abcdef12 + macros: + - macro: MACRO1 + value: test1 + - macro: '{$MACRO2}' + value: test2 + tags: + - tag: Tag1 + - tag: Tag2 + value: test2 + register: zabbix_host1 + +- name: expect to succeed and that things changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: try to create the same host with the same settings" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + visible_name: ExampleName + description: My ExampleHost Description + host_groups: + - 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' }}" + status: enabled + state: present + inventory_mode: manual + inventory_zabbix: + tag: test-tag + alias: test-alias + notes: "Special Informations: test-info" + location: test-location + site_rack: test-rack + os: test-os + hardware: test-hw + interfaces: + - type: 1 + main: 1 + useip: 1 + ip: 10.1.1.1 + dns: "" + port: "10050" + - type: 1 + main: 0 + useip: 1 + ip: 10.1.1.1 + dns: "" + port: "{$MACRO}" + - type: 4 + main: 1 + useip: 1 + ip: 10.1.1.1 + dns: "" + port: "12345" + proxy: ExampleProxy + tls_psk_identity: test + tls_connect: 2 + tls_psk: 123456789abcdef123456789abcdef12 + macros: + - macro: MACRO1 + value: test1 + - macro: '{$MACRO2}' + value: test2 + tags: + - tag: Tag1 + - tag: Tag2 + value: test2 + register: zabbix_host1 + +- name: updating with same values should be idempotent + assert: + that: + - "not zabbix_host1 is changed" + +- name: "test: try to create the same host with the same settings and force false" + zabbix_host: + force: false + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + visible_name: ExampleName + description: My ExampleHost Description + host_groups: + - 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' }}" + status: enabled + state: present + inventory_mode: manual + inventory_zabbix: + tag: test-tag + alias: test-alias + notes: "Special Informations: test-info" + location: test-location + site_rack: test-rack + os: test-os + hardware: test-hw + interfaces: + - type: 1 + main: 1 + useip: 1 + ip: 10.1.1.1 + dns: "" + port: "10050" + - type: 1 + main: 0 + useip: 1 + ip: 10.1.1.1 + dns: "" + port: "{$MACRO}" + - type: 4 + main: 1 + useip: 1 + ip: 10.1.1.1 + dns: "" + port: "12345" + proxy: ExampleProxy + tls_psk_identity: test + tls_connect: 2 + tls_psk: 123456789abcdef123456789abcdef12 + register: zabbix_host1 + +- name: updating with same values and force false should be idempotent + 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: + force: false + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + visible_name: ExampleName + description: My ExampleHost Description + host_groups: + - 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' }}" + status: enabled + state: present + inventory_mode: manual + inventory_zabbix: + tag: test-tag + alias: test-alias + notes: "Special Informations: test-info" + location: test-location + site_rack: test-rack + os: test-os + hardware: test-hw-modified + interfaces: + - type: 1 + main: 1 + useip: 1 + ip: 10.1.1.1 + dns: "" + port: "10050" + - type: 1 + main: 0 + useip: 1 + ip: 10.1.1.1 + dns: "" + port: "{$MACRO}" + - type: 4 + main: 1 + useip: 1 + ip: 10.1.1.1 + dns: "" + port: "12345" + proxy: ExampleProxy + tls_psk_identity: test + tls_connect: 2 + tls_psk: 123456789abcdef123456789abcdef12 + register: zabbix_host1 + +- name: changing the value of an already defined inventory should work and mark task as changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: change visible_name" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + visible_name: "ExampleName Changed" + register: zabbix_host1 + +- name: expect to succeed and that things changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: change visible_name (again)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + visible_name: "ExampleName Changed" + register: zabbix_host1 + +- name: updating with same values should be idempotent + assert: + that: + - "not zabbix_host1 is changed" + +- name: "test: change description" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + description: "My ExampleHost Description Changed" + register: zabbix_host1 + +- name: expect to succeed and that things changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: change description (again)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + description: "My ExampleHost Description Changed" + register: zabbix_host1 + +- name: updating with same values should be idempotent + assert: + that: + - "not zabbix_host1 is changed" + +- name: "test: change host groups (adding one group)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + host_groups: + - Linux servers + - Zabbix servers + - Virtual machines + register: zabbix_host1 + +- name: expect to succeed and that things changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: change host groups (remove one group)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + host_groups: + - Linux servers + - Zabbix servers + register: zabbix_host1 + +- name: expect to succeed and that things changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: change host groups (add one group using force=no)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + host_groups: + - Virtual machines + force: no + register: zabbix_host1 + +- name: expect to succeed and that things changed + assert: + that: + - "zabbix_host1 is changed" + + +- name: "test: change host groups (check whether we are at three groups)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + host_groups: + - Linux servers + - Zabbix servers + - Virtual machines + register: zabbix_host1 + +- name: expect to succeed and that things have not changed + assert: + that: + - "not zabbix_host1 is changed" + +- name: "test: change host groups (attempt to remove all host groups)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + host_groups: + - + register: zabbix_host1 + ignore_errors: yes + +- name: expect to fail + assert: + that: + - "zabbix_host1 is failed" + +- name: "test: change host linked templates (same as before)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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' }}" + register: zabbix_host1 + +- name: expect to succeed and that things have not changed + assert: + that: + - "not zabbix_host1 is changed" + +- name: "test: change host linked templates (add one template)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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' }}" + register: zabbix_host1 + +- name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: change host linked templates (add one template, using force=no)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + link_templates: + - "{{ 'LDAP Service' if zabbix_version | float >= 5.2 else 'Template App LDAP Service' }}" + force: no + register: zabbix_host1 + +- name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: change host linked templates (make sure we are at 4 templates)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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' }}" + register: zabbix_host1 + +- name: expect to succeed and that things have not changed + assert: + that: + - "not zabbix_host1 is changed" + +- name: "test: change host linked templates (remove all templates)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + link_templates: + - + register: zabbix_host1 + +- name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: change host linked templates (check we have no templates left)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + link_templates: + - + register: zabbix_host1 + +- name: expect to succeed and that things have not changed + assert: + that: + - "not zabbix_host1 is changed" + +- name: "test: change host status" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + status: disabled + register: zabbix_host1 + +- name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: change host status (again)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + status: disabled + register: zabbix_host1 + +- name: expect to succeed and that things have not changed + assert: + that: + - "not zabbix_host1 is changed" + +- name: "test: change host inventory mode" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + inventory_mode: automatic + register: zabbix_host1 + +- name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: change host inventory mode" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + inventory_mode: automatic + register: zabbix_host1 + +- name: expect to succeed and that things have not changed + assert: + that: + - "not zabbix_host1 is changed" + +- name: "test: change host inventory data (one field)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + inventory_zabbix: + tag: test-tag-two + alias: test-alias + notes: "Special Informations: test-info" + location: test-location + site_rack: test-rack + os: test-os + hardware: test-hw + register: zabbix_host1 + +- name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: change host inventory data (again)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + inventory_zabbix: + tag: test-tag-two + alias: test-alias + notes: "Special Informations: test-info" + location: test-location + site_rack: test-rack + os: test-os + hardware: test-hw + register: zabbix_host1 + +- name: expect to succeed and that things have not changed + assert: + that: + - "not zabbix_host1 is changed" + +- name: "test: remove host proxy" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + proxy: '' + register: zabbix_host1 + +- name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: add host proxy" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + proxy: ExampleProxy + register: zabbix_host1 + +- name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: add host proxy (again)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + proxy: ExampleProxy + register: zabbix_host1 + +- name: expect to succeed and that things have not changed + assert: + that: + - "not zabbix_host1 is changed" + +- name: "test: change tls settings" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + tls_psk_identity: test2 + tls_connect: 4 + tls_accept: 7 + tls_psk: 123456789abcdef123456789abcdef13 + tls_issuer: AcmeCorp + tls_subject: AcmeCorpServer + register: zabbix_host1 + +- name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: change tls settings (again)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + tls_psk_identity: test2 + tls_connect: 4 + tls_accept: 7 + tls_psk: 123456789abcdef123456789abcdef13 + tls_issuer: AcmeCorp + tls_subject: AcmeCorpServer + register: zabbix_host1 + +- name: expect to succeed and that things have not changed + assert: + that: + - "not zabbix_host1 is changed" + +- name: "test: change interface settings (remove one)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + interfaces: + - type: 1 + main: 1 + useip: 1 + ip: 10.1.1.1 + dns: "" + port: "10050" + register: zabbix_host1 + +- name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: change interface settings (again)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + interfaces: + - type: 1 + main: 1 + useip: 1 + ip: 10.1.1.1 + dns: "" + port: "10050" + register: zabbix_host1 + +- name: expect to succeed and that things have not changed + assert: + that: + - "not zabbix_host1 is changed" + +- name: "test: change interface settings (add one interface using force=no)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + interfaces: + - type: 4 + main: 1 + useip: 1 + ip: 10.1.1.1 + dns: "" + port: "12345" + force: no + register: zabbix_host1 + +- name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: change interface settings (verify that we are at two interfaces)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + interfaces: + - type: 1 + main: 1 + useip: 1 + ip: 10.1.1.1 + dns: "" + port: "10050" + - type: 4 + main: 1 + useip: 1 + ip: 10.1.1.1 + dns: "" + port: "12345" + register: zabbix_host1 + +- name: expect to succeed and that things have not changed + assert: + that: + - "not zabbix_host1 is changed" + +- name: "test: configure interface to useip=1 but provide no ip" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + interfaces: + - type: 1 + main: 1 + useip: 1 + port: "10050" + - type: 4 + main: 1 + useip: 1 + ip: 10.1.1.1 + port: "12345" + register: zabbix_host1 + ignore_errors: yes + +- name: expect to fail + assert: + that: + - "zabbix_host1 is failed" + +- name: "test: configure interface to useip=0 but provide no dns" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + interfaces: + - type: 1 + main: 1 + useip: 0 + ip: 10.1.1.1 + port: "10050" + - type: 4 + main: 1 + useip: 1 + ip: 10.1.1.1 + port: "12345" + register: zabbix_host1 + ignore_errors: yes + +- name: expect to fail + assert: + that: + - "zabbix_host1 is failed" + +- when: zabbix_version is version("5.0", ">=") + block: + - name: "test: configure SNMPv2 interface without details (fail)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: update details for SNMPv2 interface with bulk sub option" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: 0 + authpassphrase: secret_auth_passphrase + privprotocol: 0 + privpassphrase: secret_priv_passphrase + register: zabbix_host1 + + - name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: add IPMI settings" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + ipmi_authtype: 2 + ipmi_privilege: 4 + ipmi_username: username + ipmi_password: password + register: zabbix_host1 + +- name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: add IPMI settings again" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + ipmi_authtype: 2 + ipmi_privilege: 4 + ipmi_username: username + ipmi_password: password + register: zabbix_host1 + +- name: expect to succeed and that things have not changed + assert: + that: + - "zabbix_host1 is not changed" + +- name: "test: verify that an empty change is idempotent" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + register: zabbix_host1 + +- name: expect to succeed and that things have not changed + assert: + that: + - "zabbix_host1 is not changed" + +- name: "test: IPMI set default values" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + ipmi_authtype: -1 + ipmi_privilege: 2 + ipmi_username: "" + ipmi_password: "" + register: zabbix_host1 + +- name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: IPMI set default values (again)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + ipmi_authtype: -1 + ipmi_privilege: 2 + ipmi_username: "" + ipmi_password: "" + register: zabbix_host1 + +- name: expect to succeed and that things have not changed + assert: + that: + - "zabbix_host1 is not changed" + +- name: "test: change host inventory mode to disabled" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + inventory_mode: disabled + register: zabbix_host1 + +- name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: change host inventory mode to manual" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + inventory_mode: manual + register: zabbix_host1 + +- name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: add new set of user macros to the host" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + macros: + - macro: '{$NEWMACRO1}' + value: test123 + - macro: NEWMACRO2 + 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 user macros to the host (again - lowercase)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + macros: + - macro: '{$newmacro1}' + value: test123 + - 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 present on the host" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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" + +# 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: add user macro while keeping previous ones with force=no" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + force: no + macros: + - macro: '{$NEWMACRO3}' + 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 user macros (again)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + macros: + - macro: '{$NEWMACRO1}' + value: test1234 + - macro: NEWMACRO2 + value: abc + - macro: '{$NEWMACRO3}' + value: testing + register: zabbix_host1 + +- name: expect to succeed and that things have not changed + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + macros: + - macro: '{$NEWMACROSECRET}' + value: secretvalue + type: secret + 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 user macros" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + macros: [] + register: zabbix_host1 + +- name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: wipe out all of the user macros (again)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + macros: [] + register: zabbix_host1 + +- name: expect to succeed and that things have not changed + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + force: no + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + tags: [] + register: zabbix_host1 + + - name: expect to succeed and that things have changed + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: wipe out all of the tags (again)" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + tags: [] + register: zabbix_host1 + +- name: expect to succeed and that things have not changed + assert: + that: + - "zabbix_host1 is not changed" + +- name: "test: attempt to delete host created earlier" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + state: absent + register: zabbix_host1 + +- name: deleting a host is a change, right? + assert: + that: + - "zabbix_host1 is changed" + +- name: "test: attempt deleting a non-existant host" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + state: absent + register: zabbix_host1 + +- name: deleting a non-existant host is not a change, right? + assert: + that: + - "not zabbix_host1 is changed" + +- when: zabbix_version is version('5.2', '>=') + block: + - name: "test: create host without host interfaces" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: "cleanup" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHost + state: absent diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host_info/meta/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host_info/meta/main.yml new file mode 100644 index 00000000..d3007478 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host_info/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host_info/tasks/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host_info/tasks/main.yml new file mode 100644 index 00000000..9f072a9f --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_host_info/tasks/main.yml @@ -0,0 +1,159 @@ +--- +- name: "test - Prepare host for zabbix_host_info module" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHostForHostInfoModule + visible_name: ExampleHostForHostInfoModuleName + description: Test Host + host_groups: + - Linux servers + - Hypervisors + link_templates: + - "{{ 'Zabbix Server' if zabbix_version | float >= 5.2 else 'Template App Zabbix Server' }}" + status: enabled + inventory_mode: manual + inventory_zabbix: + tag: tag1 + os: Linux + interfaces: + - type: 1 + main: 1 + useip: 1 + ip: 192.168.0.1 + dns: "" + port: 10050 + state: present + register: prepare_host_result + +- assert: + that: + - prepare_host_result.changed is sameas true + +- name: "test - Set default parameters to zabbix_host_info" + module_defaults: + zabbix_host_info: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: ExampleHostForHostInfoModule + + block: + - name: "test - Gather all facts of zabbix host" + 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.2', '>=') + 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 == "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" + + - name: "test - Gather facts of zabbix host with host_inventory" + 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: + 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: + host_name: HostForHostInfo + exact_match: no + register: partial_match_result + + - assert: + that: + - partial_match_result.hosts | length == 1 + + - name: "test - Exact match of zabbix host name" + zabbix_host_info: + exact_match: yes + register: exact_match_result + + - assert: + that: + - exact_match_result.hosts | length == 1 + + - name: "test - Exact match of zabbix host name(expectations - host not found)" + zabbix_host_info: + host_name: HostForHostInfo + exact_match: yes + register: exact_match_host_not_found_result + ignore_errors: yes + + - assert: + that: + - exact_match_host_not_found_result.failed is sameas true diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_hostmacro/meta/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_hostmacro/meta/main.yml new file mode 100644 index 00000000..d3007478 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_hostmacro/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_hostmacro/tasks/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_hostmacro/tasks/main.yml new file mode 100644 index 00000000..3c24e8ad --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_hostmacro/tasks/main.yml @@ -0,0 +1,160 @@ +--- +- name: create helper zabbix host + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: zbx_hmacro_host01 + host_groups: + - Linux servers + interfaces: + - type: agent + main: 1 + dns: zbx_hmacro_host01 + +- name: test - attempt to create new host macro + zabbix_hostmacro: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: zbx_hmacro_host01 + macro_name: zbxhmacro_test01 + macro_value: 123 + register: zbxhmacro_new + +- name: assert that macro was created + assert: + that: zbxhmacro_new is changed + +- name: test - attempt to create same host macro + zabbix_hostmacro: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: zbx_hmacro_host01 + macro_name: zbxhmacro_test01 + macro_value: 123 + register: zbxhmacro_existing + +- name: assert that nothing has been changed + assert: + that: not zbxhmacro_existing is changed + +- name: test - attempt to create same host macro in zabbix native format + zabbix_hostmacro: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: zbx_hmacro_host01 + macro_name: "{$ZBXHMACRO_TEST01}" + macro_value: 123 + register: zbxhmacro_existing_native + +- name: assert that nothing has been changed + assert: + that: not zbxhmacro_existing_native is changed + +- name: test - attempt to create new host macro in zabbix native format + zabbix_hostmacro: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: zbx_hmacro_host01 + macro_name: "{$ZBXHMACRO_TEST02}" + macro_value: abcd + register: zbxhmacro_new_native + +- name: assert that nothing macro was created + assert: + that: zbxhmacro_new_native is changed + +- name: test - attempt to update host macro with string value while force=no + zabbix_hostmacro: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: zbx_hmacro_host01 + macro_name: zbxhmacro_test01 + macro_value: abc + force: no + register: zbxhmacro_update_noforce + +- name: assert that nothing has been changed + assert: + that: not zbxhmacro_update_noforce is changed + +- name: test - attempt to update host macro with string value + zabbix_hostmacro: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: zbx_hmacro_host01 + macro_name: zbxhmacro_test01 + macro_value: abc + register: zbxhmacro_update + ignore_errors: True + +- name: assert that host macro was updated + assert: + that: zbxhmacro_update is changed + +- name: test - attempt to create host macro with context + zabbix_hostmacro: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: zbx_hmacro_host01 + macro_name: low_space_limit:/home + macro_value: 10 + register: zbxhmacro_context_new + +- name: assert that macro was created + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: zbx_hmacro_host01 + macro_name: LOW_SPACE_LIMIT:/home + macro_value: 10 + register: zbxhmacro_context_existing + +- name: assert that nothing has been changed + assert: + that: not zbxhmacro_context_existing is changed + +- name: test - attempt to delete all host macros + zabbix_hostmacro: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: zbx_hmacro_host01 + macro_name: "{{ item }}" + state: absent + loop: + - zbxhmacro_test01 + - LOW_SPACE_LIMIT:/home + - "{$ZBXHMACRO_TEST02}" + register: zbxhmacro_delete_existing + +- name: assert that all macros have been deleted + assert: + that: item.changed is sameas True + loop: "{{ zbxhmacro_delete_existing.results }}" + +- name: test - attempt to delete non-existing host macro + zabbix_hostmacro: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: zbx_hmacro_host01 + macro_name: zbxhmacro_test01 + state: absent + register: zbxhmacro_delete_missing + +- name: assert that nothing has been changed + assert: + that: not zbxhmacro_delete_missing is changed diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_maintenance/aliases b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_maintenance/aliases new file mode 100644 index 00000000..7a68b11d --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_maintenance/aliases @@ -0,0 +1 @@ +disabled diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_maintenance/meta/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_maintenance/meta/main.yml new file mode 100644 index 00000000..d3007478 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_maintenance/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_maintenance/tasks/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_maintenance/tasks/main.yml new file mode 100644 index 00000000..f3c8d427 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_maintenance/tasks/main.yml @@ -0,0 +1,260 @@ +--- +# New host create test from here +- name: "test - Create a new host" + zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: example + host_groups: + - Linux servers + interfaces: + - type: 1 + main: 1 + useip: 1 + ip: 10.1.1.1 + dns: "" + port: 10050 + register: create_host_result + +- assert: + that: + - create_host_result.changed is sameas true + +- name: "test - Create maintenance with a host_name param" + zabbix_maintenance: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: maintenance + host_name: example + state: present + register: create_maintenance_host_name_result + +- assert: + that: + - create_maintenance_host_name_result.changed is sameas true + +- name: "test - Create maintenance with a host_name param(again - expectations: no change will occur)" + zabbix_maintenance: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: maintenance + host_name: example + state: present + register: create_maintenance_host_name_again_result + +- assert: + that: + - create_maintenance_host_name_again_result.changed is sameas false + +- name: "test - Update maintenance with a desc param" + zabbix_maintenance: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: maintenance + host_name: example + desc: "test description" + state: present + register: update_maintenance_desc_result + +- debug: msg="{{ update_maintenance_desc_result }}" + +- 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: maintenance + host_name: example + desc: "test description" + state: present + register: update_maintenance_desc_again_result + +- assert: + that: + - update_maintenance_desc_again_result.changed is sameas false + +- name: "test - Update maintenance with a collect_data" + zabbix_maintenance: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: maintenance + host_name: example + desc: "test description" + collect_data: no + state: present + register: update_maintenance_collect_data_result + +- 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: maintenance + host_name: example + desc: "test description" + collect_data: no + state: present + register: update_maintenance_collect_data_again_result + +- assert: + that: + - update_maintenance_collect_data_again_result.changed is sameas false + +- name: "test - Update maintenance with a minutes param" + zabbix_maintenance: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: maintenance + host_name: example + desc: "test description" + collect_data: no + minutes: 90 + state: present + register: update_maintenance_minutes_result + +- 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: maintenance + host_name: example + desc: "test description" + collect_data: no + minutes: 90 + state: present + register: update_maintenance_minutes_again_result + +- assert: + that: + - update_maintenance_minutes_again_result.changed is sameas false + +- name: "test - Update maintenance with a host_groups param" + zabbix_maintenance: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: maintenance + host_name: example + host_groups: + - Linux servers + - Hypervisors + desc: "test description" + collect_data: no + minutes: 90 + state: present + register: update_maintenance_host_groups_result + +- 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: maintenance + host_name: example + host_groups: + - Linux servers + - Hypervisors + desc: "test description" + collect_data: no + minutes: 90 + state: present + register: update_maintenance_host_groups_again_result + +- 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: maintenance + host_names: + - example + - Zabbix server + host_groups: + - Linux servers + - Hypervisors + desc: "test description" + collect_data: no + minutes: 90 + state: present + register: update_maintenance_host_names_result + +- 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: maintenance + host_names: + - example + - Zabbix server + host_groups: + - Linux servers + - Hypervisors + desc: "test description" + collect_data: no + minutes: 90 + state: present + register: update_maintenance_host_names_again_result + +- assert: + that: + - update_maintenance_host_names_again_result.changed is sameas false + +- name: "test - Delete maintenance" + zabbix_maintenance: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: maintenance + host_name: example + state: absent + register: delete_maintenance_result + +- assert: + that: + - delete_maintenance_result.changed is sameas true + +- name: "test - Delete maintenance(again - expectations: no change will occur)" + zabbix_maintenance: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: maintenance + host_name: example + state: absent + register: delete_maintenance_again_result + +- assert: + that: + - delete_maintenance_again_result.changed is sameas false diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_mediatype/meta/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_mediatype/meta/main.yml new file mode 100644 index 00000000..d3007478 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_mediatype/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_mediatype/tasks/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_mediatype/tasks/main.yml new file mode 100644 index 00000000..b74a5b7d --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_mediatype/tasks/main.yml @@ -0,0 +1,696 @@ +--- +- name: test - email mediatypes + module_defaults: + zabbix_mediatype: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + state: present + name: Example email + type: email + 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: yes + 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: yes + 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: yes + 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: yes + smtp_security: SSL/TLS + smtp_verify_host: yes + smtp_verify_peer: yes + 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: yes + smtp_security: SSL/TLS + smtp_verify_host: yes + smtp_verify_peer: yes + 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 - 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 concurrent settings + zabbix_mediatype: + max_sessions: 99 + max_attempts: 10 + attempt_interval: 30 + register: zbxmediatype_concur + + - assert: + that: zbxmediatype_concur.changed is sameas True + + - name: test - update email mediatype concurrent settings (again) + zabbix_mediatype: + max_sessions: 99 + max_attempts: 10 + attempt_interval: 30 + register: zbxmediatype_concur + + - assert: + that: zbxmediatype_concur.changed is sameas False + + - name: test - update email mediatype concurrent settings above range (fail) + zabbix_mediatype: + max_sessions: 102 + max_attempts: 11 + attempt_interval: 61 + register: zbxmediatype_concur_fail + ignore_errors: True + + - 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: + register: zbxmediatype_reset + + - assert: + that: zbxmediatype_reset.changed is sameas True + + - name: test - update email mediatype with message templates + zabbix_mediatype: + message_templates: + - eventsource: triggers + recovery: operations + subject: "Problem: {EVENT.NAME}" + body: "Problem started at {EVENT.TIME} on {EVENT.DATE}\r\nProblem name: {EVENT.NAME}\r\n" + - eventsource: discovery + recovery: operations + subject: "Discovery: {DISCOVERY.DEVICE.STATUS} {DISCOVERY.DEVICE.IPADDRESS}" + body: "Discovery rule: {DISCOVERY.RULE.NAME}\r\n\r\nDevice IP: {DISCOVERY.DEVICE.IPADDRESS}" + - eventsource: autoregistration + recovery: operations + subject: "Autoregistration: {HOST.HOST}" + body: "Host name: {HOST.HOST}\r\nHost IP: {HOST.IP}\r\nAgent port: {HOST.PORT}" + - eventsource: internal + recovery: operations + subject: "Internal: {EVENT.NAME}" + body: "Internal event started at {EVEN.TIME} on {EVENT.DATE}\r\nEvent name: {EVENT.NAME}\r\n" + register: zbxmediatype_msg_templates + + - assert: + that: zbxmediatype_msg_templates.changed is sameas True + + - name: test - update email mediatype with message templates (again) + zabbix_mediatype: + message_templates: + - eventsource: triggers + recovery: operations + subject: "Problem: {EVENT.NAME}" + body: "Problem started at {EVENT.TIME} on {EVENT.DATE}\r\nProblem name: {EVENT.NAME}\r\n" + - eventsource: discovery + recovery: operations + subject: "Discovery: {DISCOVERY.DEVICE.STATUS} {DISCOVERY.DEVICE.IPADDRESS}" + body: "Discovery rule: {DISCOVERY.RULE.NAME}\r\n\r\nDevice IP: {DISCOVERY.DEVICE.IPADDRESS}" + - eventsource: autoregistration + recovery: operations + subject: "Autoregistration: {HOST.HOST}" + body: "Host name: {HOST.HOST}\r\nHost IP: {HOST.IP}\r\nAgent port: {HOST.PORT}" + - eventsource: internal + recovery: operations + subject: "Internal: {EVENT.NAME}" + body: "Internal event started at {EVEN.TIME} on {EVENT.DATE}\r\nEvent name: {EVENT.NAME}\r\n" + register: zbxmediatype_msg_templates + + - assert: + that: zbxmediatype_msg_templates.changed is sameas False + + - name: test - update subject of message template in email mediatype + zabbix_mediatype: + message_templates: + - eventsource: triggers + recovery: operations + subject: "Problem: {EVENT.NAME} - test change" + body: "Problem started at {EVENT.TIME} on {EVENT.DATE}\r\nProblem name: {EVENT.NAME}\r\n" + - eventsource: discovery + recovery: operations + subject: "Discovery: {DISCOVERY.DEVICE.STATUS} {DISCOVERY.DEVICE.IPADDRESS}" + body: "Discovery rule: {DISCOVERY.RULE.NAME}\r\n\r\nDevice IP: {DISCOVERY.DEVICE.IPADDRESS}" + - eventsource: autoregistration + recovery: operations + subject: "Autoregistration: {HOST.HOST}" + body: "Host name: {HOST.HOST}\r\nHost IP: {HOST.IP}\r\nAgent port: {HOST.PORT}" + - eventsource: internal + recovery: operations + subject: "Internal: {EVENT.NAME}" + body: "Internal event started at {EVEN.TIME} on {EVENT.DATE}\r\nEvent name: {EVENT.NAME}\r\n" + register: zbxmediatype_msg_templates + + - assert: + that: zbxmediatype_msg_templates.changed is sameas True + + - name: test - update message of message template in email mediatype + zabbix_mediatype: + message_templates: + - eventsource: triggers + recovery: operations + subject: "Problem: {EVENT.NAME} - test change" + body: "Problem started at {EVENT.TIME} on {EVENT.DATE}\r\nProblem name: {EVENT.NAME}\r\n" + - eventsource: discovery + recovery: operations + subject: "Discovery: {DISCOVERY.DEVICE.STATUS} {DISCOVERY.DEVICE.IPADDRESS}" + body: "Discovery rule: {DISCOVERY.RULE.NAME}\r\n\r\nDevice IP: {DISCOVERY.DEVICE.IPADDRESS} - test" + - eventsource: autoregistration + recovery: operations + subject: "Autoregistration: {HOST.HOST}" + body: "Host name: {HOST.HOST}\r\nHost IP: {HOST.IP}\r\nAgent port: {HOST.PORT}" + - eventsource: internal + recovery: operations + subject: "Internal: {EVENT.NAME}" + body: "Internal event started at {EVEN.TIME} on {EVENT.DATE}\r\nEvent name: {EVENT.NAME}\r\n" + register: zbxmediatype_msg_templates + + - assert: + that: zbxmediatype_msg_templates.changed is sameas True + + - name: test - update subject and message of message template in email mediatype (again) + zabbix_mediatype: + message_templates: + - eventsource: triggers + recovery: operations + subject: "Problem: {EVENT.NAME} - test change" + body: "Problem started at {EVENT.TIME} on {EVENT.DATE}\r\nProblem name: {EVENT.NAME}\r\n" + - eventsource: discovery + recovery: operations + subject: "Discovery: {DISCOVERY.DEVICE.STATUS} {DISCOVERY.DEVICE.IPADDRESS}" + body: "Discovery rule: {DISCOVERY.RULE.NAME}\r\n\r\nDevice IP: {DISCOVERY.DEVICE.IPADDRESS} - test" + - eventsource: autoregistration + recovery: operations + subject: "Autoregistration: {HOST.HOST}" + body: "Host name: {HOST.HOST}\r\nHost IP: {HOST.IP}\r\nAgent port: {HOST.PORT}" + - eventsource: internal + recovery: operations + subject: "Internal: {EVENT.NAME}" + body: "Internal event started at {EVEN.TIME} on {EVENT.DATE}\r\nEvent name: {EVENT.NAME}\r\n" + register: zbxmediatype_msg_templates + + - assert: + that: zbxmediatype_msg_templates.changed is sameas False + + - name: test - disable email mediatype + zabbix_mediatype: + status: disabled + register: zbxmediatype_disable + + - assert: + that: zbxmediatype_disable.changed is sameas True + + - name: test - disable email mediatype (again) + zabbix_mediatype: + status: disabled + register: zbxmediatype_disable + + - assert: + that: zbxmediatype_disable.changed is sameas False + + - name: test - delete email mediatype + zabbix_mediatype: + state: absent + register: zbxmediatype_delete + + - assert: + that: zbxmediatype_delete.changed is sameas True + + - name: test - delete email mediatype (again) + zabbix_mediatype: + state: absent + register: zbxmediatype_delete + + - assert: + that: zbxmediatype_delete.changed is sameas False + +- name: test - script mediatypes + module_defaults: + zabbix_mediatype: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + state: present + name: Example script + 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 - sms mediatypes + module_defaults: + zabbix_mediatype: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + state: present + name: Example sms + type: sms + + block: + - name: test - create new sms mediatype + zabbix_mediatype: + gsm_modem: /dev/ttyS0 + register: zbxmediatype_sms_new + + - 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 + + - 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: + gsm_modem: /dev/ttyS0 + max_sessions: 1 + max_attempts: 3 + attempt_interval: 30 + register: zbxmediatype_sms_concur + + - assert: + that: zbxmediatype_sms_concur.changed is sameas True + + - name: test - update sms mediatype with concurrent settings (again) + zabbix_mediatype: + gsm_modem: /dev/ttyS0 + max_sessions: 1 + max_attempts: 3 + attempt_interval: 30 + register: zbxmediatype_sms_concur + + - assert: + that: zbxmediatype_sms_concur.changed is sameas False + + - name: test - update sms mediatype with invalid max sessions (fail) + zabbix_mediatype: + gsm_modem: /dev/ttyS0 + max_sessions: 2 + register: zbxmediatype_sms_fail + ignore_errors: True + + - assert: + that: zbxmediatype_sms_fail.failed is sameas True + + - name: test - delete sms mediatype + 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: + zabbix_mediatype: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + zabbix_mediatype: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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 + +- name: test - email mediatypes + when: zabbix_version is version('4.4', '>=') + module_defaults: + zabbix_mediatype: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + state: present + name: Example webhook + type: webhook + 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 diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_proxy/aliases b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_proxy/aliases new file mode 100644 index 00000000..7a68b11d --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_proxy/aliases @@ -0,0 +1 @@ +disabled diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_proxy/meta/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_proxy/meta/main.yml new file mode 100644 index 00000000..d3007478 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_proxy/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_proxy/tasks/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_proxy/tasks/main.yml new file mode 100644 index 00000000..1b493e37 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_proxy/tasks/main.yml @@ -0,0 +1,365 @@ +--- +- name: test - create new passive Zabbix proxy server + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: zbxproxy_example01 + description: Example Zabbix Proxy + state: present + status: passive + interface: + useip: 0 + ip: 10.1.1.2 + dns: zbxproxy_example01 + port: 10051 + register: zbxproxy_new + +- name: assert that proxy was created + assert: + that: zbxproxy_new is changed + +- name: test - create same passive Zabbix proxy server + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: zbxproxy_example01 + description: Example Zabbix Proxy + state: present + status: passive + interface: + useip: 0 + ip: 10.1.1.2 + dns: zbxproxy_example01 + port: 10051 + register: zbxproxy_existing + +- name: assert that nothing has been changed + assert: + that: not zbxproxy_existing is changed + +- name: test - update Zabbix proxy server description + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: zbxproxy_example01 + description: Example Zabbix Proxy desc + state: present + status: passive + interface: + useip: 0 + ip: 10.1.1.2 + dns: zbxproxy_example01 + port: 10051 + register: zbxproxy_desc_update + +- name: assert that description has been updated + assert: + that: zbxproxy_desc_update is changed + +- name: test - update Zabbix proxy server interface + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: zbxproxy_example01 + description: Example Zabbix Proxy desc + state: present + status: passive + interface: + useip: 0 + ip: 10.1.1.3 + dns: zbxproxy_example01 + port: 10051 + register: zbxproxy_interface_update + +- name: assert that interface has been updated + assert: + that: zbxproxy_interface_update is changed + +- name: test - update Zabbix proxy server description & interface (again) + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: zbxproxy_example01 + description: Example Zabbix Proxy desc + state: present + status: passive + interface: + useip: 0 + ip: 10.1.1.3 + dns: zbxproxy_example01 + port: 10051 + register: zbxproxy_desc_interface_update + +- name: assert that nothing has been changed + assert: + that: not zbxproxy_desc_interface_update is changed + +- name: test - update Zabbix proxy server interface to use only ip + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: zbxproxy_example01 + description: Example Zabbix Proxy desc + state: present + status: passive + interface: + useip: 1 + ip: 10.1.1.3 + port: 10051 + register: zbxproxy_interface_onlyip + +- name: assert that interface has been updated + assert: + that: zbxproxy_interface_onlyip is changed + +- name: test - update Zabbix proxy server interface to use only ip again + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: zbxproxy_example01 + description: Example Zabbix Proxy desc + state: present + status: passive + interface: + useip: 1 + ip: 10.1.1.3 + port: 10051 + register: zbxproxy_interface_onlyip_again + +- name: assert that nothing has been changed + assert: + that: not zbxproxy_interface_onlyip_again is changed + +- name: test - update Zabbix proxy server interface to use only dns + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: zbxproxy_example01 + description: Example Zabbix Proxy desc + state: present + status: passive + interface: + useip: 0 + dns: zbxproxy_example01 + port: 10051 + register: zbxproxy_interface_onlydns + +- name: assert that interface has been updated + assert: + that: zbxproxy_interface_onlydns is changed + +- name: test - update Zabbix proxy server interface to use only dns again + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: zbxproxy_example01 + description: Example Zabbix Proxy desc + state: present + status: passive + interface: + useip: 0 + dns: zbxproxy_example01 + port: 10051 + register: zbxproxy_interface_onlydns_again + +- name: assert that nothing has been changed + assert: + that: not zbxproxy_interface_onlydns_again is changed + +- name: test - update Zabbix proxy server interface to fail + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: zbxproxy_example01 + description: Example Zabbix Proxy desc + state: present + status: passive + interface: + useip: 1 + dns: zbxproxy_example01 + port: 10051 + register: zbxproxy_interface_fail + ignore_errors: True + +- name: assert that module has failed + assert: + that: zbxproxy_interface_fail is failed + +- name: test - update Zabbix proxy server to be active + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: zbxproxy_example01 + description: Example Zabbix Proxy + state: present + status: active + register: zbxproxy_active_update + +- name: assert that proxy was updated + assert: + that: zbxproxy_active_update is changed + +- name: test - update Zabbix proxy server to be active (again) + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: zbxproxy_example01 + description: Example Zabbix Proxy + state: present + status: active + register: zbxproxy_active_update_again + +- name: assert that nothing has been changed + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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 use encryption + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: zbxproxy_example01 + description: Example Zabbix Proxy + state: present + status: active + tls_psk_identity: test + tls_connect: PSK + tls_accept: PSK + tls_psk: 123456789abcdef123456789abcdef12 + register: zbxproxy_encryption + +- name: assert that encryption has been enabled + assert: + that: zbxproxy_encryption is changed + +- name: test - update Zabbix proxy server to use encryption (again) + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: zbxproxy_example01 + description: Example Zabbix Proxy + state: present + status: active + tls_psk_identity: test + tls_connect: PSK + tls_accept: PSK + tls_psk: 123456789abcdef123456789abcdef12 + register: zbxproxy_encryption_again + +- name: assert that nothing has been changed + assert: + that: not zbxproxy_encryption_again is changed + +- name: test - update Zabbix proxy server encryption settings + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: zbxproxy_example01 + description: Example Zabbix Proxy + state: present + status: active + tls_connect: certificate + tls_accept: certificate + tls_issuer: AcmeCorp + tls_subject: AcmeCorpServer + register: zbxproxy_encryption_update + +- name: assert that encryption has been updated + assert: + that: zbxproxy_encryption_update is changed + +- name: test - update Zabbix proxy server back to being passive + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: zbxproxy_example01 + description: Example Zabbix Proxy + state: present + status: passive + interface: + useip: 0 + ip: 10.1.1.2 + dns: zbxproxy_example01 + port: 10051 + register: zbxproxy_passive_update + +- name: assert that proxy was updated + assert: + that: zbxproxy_passive_update is changed + +- name: test - delete Zabbix proxy server + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: zbxproxy_example01 + state: absent + register: zbxproxy_delete + +- name: assert that proxy has been deleted + assert: + that: zbxproxy_delete is changed + +- name: test - delete Zabbix proxy server (again) + zabbix_proxy: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + proxy_name: zbxproxy_example01 + state: absent + register: zbxproxy_delete_again + +- name: assert that nothing has been changed + assert: + that: not zbxproxy_delete_again is changed diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_screen/meta/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_screen/meta/main.yml new file mode 100644 index 00000000..d3007478 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_screen/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_screen/tasks/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_screen/tasks/main.yml new file mode 100644 index 00000000..2d270b76 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_screen/tasks/main.yml @@ -0,0 +1,146 @@ +--- + +- name: ensure zabbix server is being monitored + community.zabbix.zabbix_host: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + host_name: Zabbix server + status: enabled + +- name: test - delete the screen again + community.zabbix.zabbix_screen: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + screens: + - screen_name: TestScreen1 + state: absent + + +# ################################################# +# Test screen creation +# ################################################# + +- name: test - Create a new screen + community.zabbix.zabbix_screen: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + screens: + - screen_name: TestScreen1 + state: absent + register: result + +- assert: + that: + - result.changed + +- name: test - delete the screen again + community.zabbix.zabbix_screen: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + screens: + - screen_name: TestScreen1 + state: absent + register: result + +- assert: + that: + - not result.changed diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_service/meta/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_service/meta/main.yml new file mode 100644 index 00000000..d3007478 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_service/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_service/tasks/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_service/tasks/main.yml new file mode 100644 index 00000000..ae6105d9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_service/tasks/main.yml @@ -0,0 +1,397 @@ +--- +- name: "test - Create a new service with check_mode" + zabbix_service: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModule + sla: 99.99 + state: present + check_mode: yes + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModule + sla: 99.99 + state: present + register: create_service_result + +- assert: + that: + - create_service_result.changed is sameas true + +- name: "test - Create a new service (idempotency check)" + zabbix_service: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModule + sla: 99.99 + state: present + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModule + sla: 99.999 + state: present + check_mode: yes + register: update_sla_check_mode_result + +- assert: + that: + - update_sla_check_mode_result.changed is sameas true + +- name: "test - Update a sla" + zabbix_service: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModule + sla: 99.999 + state: present + register: update_sla_result + +- assert: + that: + - update_sla_result.changed is sameas true + +- name: "test - Update a sla (idempotency check)" + zabbix_service: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModule + sla: 99.999 + state: present + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModule + sla: 99.999 + calculate_sla: yes + state: present + check_mode: yes + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModule + sla: 99.999 + calculate_sla: yes + state: present + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModule + sla: 99.999 + calculate_sla: yes + state: present + register: update_calculate_sla_idempotency_check_result + +- assert: + that: + - update_calculate_sla_idempotency_check_result.changed is sameas false + +- name: "test - Update trigger_host and trigger_name with check_mode" + zabbix_service: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModule + sla: 99.999 + calculate_sla: yes + trigger_host: "Zabbix server" + trigger_name: "Zabbix http poller processes more than 75% busy" + state: present + check_mode: yes + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModule + sla: 99.999 + calculate_sla: yes + trigger_host: "Zabbix server" + trigger_name: "Zabbix http poller processes more than 75% busy" + state: present + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModule + sla: 99.999 + calculate_sla: yes + trigger_host: "Zabbix server" + trigger_name: "Zabbix http poller processes more than 75% busy" + state: present + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModule + sla: 99.999 + calculate_sla: yes + trigger_host: "Zabbix server" + trigger_name: "Zabbix http poller processes more than 75% busy" + algorithm: all_children + state: present + check_mode: yes + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModule + sla: 99.999 + calculate_sla: yes + trigger_host: "Zabbix server" + trigger_name: "Zabbix http poller processes more than 75% busy" + algorithm: all_children + state: present + register: update_algorithm_result + +- assert: + that: + - update_algorithm_result.changed is sameas true + +- name: "test - Update a algorithm of service (idempotency check)" + zabbix_service: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModule + sla: 99.999 + calculate_sla: yes + trigger_host: "Zabbix server" + trigger_name: "Zabbix http poller processes more than 75% busy" + algorithm: all_children + state: present + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModuleRoot + sla: 99.99 + state: present + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModule + sla: 99.999 + calculate_sla: yes + trigger_host: "Zabbix server" + trigger_name: "Zabbix http poller processes more than 75% busy" + algorithm: all_children + parent: ExampleServiceForServiceModuleRoot + state: present + check_mode: yes + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModule + sla: 99.999 + calculate_sla: yes + trigger_host: "Zabbix server" + trigger_name: "Zabbix http poller processes more than 75% busy" + algorithm: all_children + parent: ExampleServiceForServiceModuleRoot + state: present + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModule + sla: 99.999 + calculate_sla: yes + trigger_host: "Zabbix server" + trigger_name: "Zabbix http poller processes more than 75% busy" + algorithm: all_children + parent: ExampleServiceForServiceModuleRoot + state: present + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModule + sla: 99.999 + state: absent + check_mode: yes + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + name: ExampleServiceForServiceModuleRoot + sla: 99.999 + state: absent + check_mode: yes + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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 diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template1-changed_50_lower.json b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template1-changed_50_lower.json new file mode 100644 index 00000000..8cdd460a --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template1-changed_50_lower.json @@ -0,0 +1,51 @@ +{ + "zabbix_export": { + "date": "2020-05-29T15:22:11Z", + "templates": [ + { + "template": "ExampleHost", + "name": "ExampleHost", + "description": "", + "groups": [ + { + "name": "Linux servers" + }, + { + "name": "Templates" + } + ], + "macros": [ + { + "macro": "{$EXAMPLE_MACRO1}", + "value": "1000" + }, + { + "macro": "{$EXAMPLE_MACRO2}", + "value": "text" + }, + { + "macro": "{$EXAMPLE_MACRO3}", + "value": "text2" + } + ], + "templates": [ + { + "name": "Template App FTP Service" + }, + { + "name": "Template App Zabbix Proxy" + } + ] + } + ], + "version": "3.0", + "groups": [ + { + "name": "Linux servers" + }, + { + "name": "Templates" + } + ] + } +} diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template1-changed_52_higher.json b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template1-changed_52_higher.json new file mode 100644 index 00000000..73924e5b --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template1-changed_52_higher.json @@ -0,0 +1,51 @@ +{ + "zabbix_export": { + "date": "2020-05-29T15:22:11Z", + "templates": [ + { + "template": "ExampleHost", + "name": "ExampleHost", + "description": "", + "groups": [ + { + "name": "Linux servers" + }, + { + "name": "Templates" + } + ], + "macros": [ + { + "macro": "{$EXAMPLE_MACRO1}", + "value": "1000" + }, + { + "macro": "{$EXAMPLE_MACRO2}", + "value": "text" + }, + { + "macro": "{$EXAMPLE_MACRO3}", + "value": "text2" + } + ], + "templates": [ + { + "name": "FTP Service" + }, + { + "name": "Zabbix Proxy" + } + ] + } + ], + "version": "3.0", + "groups": [ + { + "name": "Linux servers" + }, + { + "name": "Templates" + } + ] + } +} diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template1_50_lower.json b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template1_50_lower.json new file mode 100644 index 00000000..869bc54a --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template1_50_lower.json @@ -0,0 +1,47 @@ +{ + "zabbix_export": { + "date": "2020-05-29T15:22:11Z", + "templates": [ + { + "template": "ExampleHost", + "name": "ExampleHost", + "description": "", + "groups": [ + { + "name": "Linux servers" + }, + { + "name": "Templates" + } + ], + "macros": [ + { + "macro": "{$EXAMPLE_MACRO1}", + "value": "1000" + }, + { + "macro": "{$EXAMPLE_MACRO2}", + "value": "text" + } + ], + "templates": [ + { + "name": "Template App FTP Service" + }, + { + "name": "Template App Zabbix Proxy" + } + ] + } + ], + "version": "3.0", + "groups": [ + { + "name": "Linux servers" + }, + { + "name": "Templates" + } + ] + } +} diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template1_52_higher.json b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template1_52_higher.json new file mode 100644 index 00000000..a733758b --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template1_52_higher.json @@ -0,0 +1,47 @@ +{ + "zabbix_export": { + "date": "2020-05-29T15:22:11Z", + "templates": [ + { + "template": "ExampleHost", + "name": "ExampleHost", + "description": "", + "groups": [ + { + "name": "Linux servers" + }, + { + "name": "Templates" + } + ], + "macros": [ + { + "macro": "{$EXAMPLE_MACRO1}", + "value": "1000" + }, + { + "macro": "{$EXAMPLE_MACRO2}", + "value": "text" + } + ], + "templates": [ + { + "name": "FTP Service" + }, + { + "name": "Zabbix Proxy" + } + ] + } + ], + "version": "3.0", + "groups": [ + { + "name": "Linux servers" + }, + { + "name": "Templates" + } + ] + } +} diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template2_50_lower.xml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template2_50_lower.xml new file mode 100644 index 00000000..aec95810 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template2_50_lower.xml @@ -0,0 +1,53 @@ +<?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>Linux servers</name> + </group> + <group> + <name>Templates</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>Linux servers</name> + </group> + <group> + <name>Templates</name> + </group> + </groups> +</zabbix_export> diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template2_52_higher.xml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template2_52_higher.xml new file mode 100644 index 00000000..e8a7f1e5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/files/template2_52_higher.xml @@ -0,0 +1,53 @@ +<?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>Linux servers</name> + </group> + <group> + <name>Templates</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>FTP Service</name> + </template> + <template> + <name>Zabbix Proxy</name> + </template> + <template> + <name>HTTP Service</name> + </template> + </templates> + </template> + </templates> + <version>3.0</version> + <groups> + <group> + <name>Linux servers</name> + </group> + <group> + <name>Templates</name> + </group> + </groups> +</zabbix_export> diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/meta/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/meta/main.yml new file mode 100644 index 00000000..d3007478 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/tasks/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/tasks/main.yml new file mode 100644 index 00000000..839d6974 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template/tasks/main.yml @@ -0,0 +1,408 @@ +--- +- name: Create a new Zabbix template (check mode). + zabbix_template: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_name: ExampleHost + template_groups: + - 'Linux servers' + - 'Templates' + state: present + register: create_zabbix_template_result + check_mode: yes + +- assert: + that: + - create_zabbix_template_result.changed is sameas true + +- name: Create a new Zabbix template. + zabbix_template: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_name: ExampleHost + template_groups: + - 'Linux servers' + - 'Templates' + state: present + register: create_zabbix_template_result + +- assert: + that: + - create_zabbix_template_result.changed is sameas true + +- name: Create a new Zabbix template (idempotency check). + zabbix_template: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_name: ExampleHost + template_groups: + - 'Linux servers' + - 'Templates' + state: present + register: create_zabbix_template_result + +- assert: + that: + - create_zabbix_template_result.changed is sameas false + +- name: Gather Zabbix template infomation. + zabbix_template_info: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + template_export_key: "{{ item }}" + loop: "{{ gather_template_result.template_json.keys() | list }}" + when: + - item | regex_search('_export') + +- assert: + that: + - gather_template_result.template_json[template_export_key].groups.0.name == 'Linux servers' + - gather_template_result.template_json[template_export_key].groups.1.name == 'Templates' + +- name: Add link_templates to Zabbix template. + zabbix_template: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_name: ExampleHost + template_groups: + - 'Linux servers' + - 'Templates' + link_templates: + - "{{ 'Zabbix Proxy' if zabbix_version | float >= 5.2 else 'Template App Zabbix Proxy' }}" + - "{{ 'FTP Service' if zabbix_version | float >= 5.2 else 'Template App FTP Service' }}" + state: present + register: update_zabbix_template_result + +- assert: + that: + - update_zabbix_template_result.changed is sameas true + +- name: Add link_templates to Zabbix template (idempotency check). + zabbix_template: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_name: ExampleHost + template_groups: + - 'Linux servers' + - 'Templates' + link_templates: + - "{{ 'Zabbix Proxy' if zabbix_version | float >= 5.2 else 'Template App Zabbix Proxy' }}" + - "{{ 'FTP Service' if zabbix_version | float >= 5.2 else 'Template App FTP Service' }}" + state: present + register: update_zabbix_template_result + +- assert: + that: + - update_zabbix_template_result.changed is sameas false + +- name: Gather Zabbix template infomation. + zabbix_template_info: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_name: ExampleHost + format: json + register: gather_template_result + +- when: zabbix_version is version('5.2', '<') + block: + - assert: + that: + - gather_template_result.template_json[template_export_key].groups.0.name == 'Linux servers' + - gather_template_result.template_json[template_export_key].groups.1.name == 'Templates' + - 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.2', '>=') + block: + - assert: + that: + - gather_template_result.template_json[template_export_key].groups.0.name == 'Linux servers' + - gather_template_result.template_json[template_export_key].groups.1.name == 'Templates' + - 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' + +- name: Add macros to Zabbix template. + zabbix_template: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_name: ExampleHost + template_groups: + - 'Linux servers' + - 'Templates' + link_templates: + - "{{ 'Zabbix Proxy' if zabbix_version | float >= 5.2 else 'Template App Zabbix Proxy' }}" + - "{{ 'FTP Service' if zabbix_version | float >= 5.2 else 'Template App FTP Service' }}" + macros: + - macro: '{$EXAMPLE_MACRO1}' + value: 1000 + - macro: '{$EXAMPLE_MACRO2}' + value: 'text' + state: present + register: update_zabbix_template_result + +- assert: + that: + - update_zabbix_template_result.changed is sameas true + +- name: Add macros to Zabbix template (idempotency check). + zabbix_template: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_name: ExampleHost + template_groups: + - 'Linux servers' + - 'Templates' + link_templates: + - "{{ 'Zabbix Proxy' if zabbix_version | float >= 5.2 else 'Template App Zabbix Proxy' }}" + - "{{ 'FTP Service' if zabbix_version | float >= 5.2 else 'Template App FTP Service' }}" + macros: + - macro: '{$EXAMPLE_MACRO1}' + value: 1000 + - macro: '{$EXAMPLE_MACRO2}' + value: 'text' + state: present + register: update_zabbix_template_result + +- assert: + that: + - update_zabbix_template_result.changed is sameas false + +- name: Gather Zabbix template infomation. + zabbix_template_info: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_name: ExampleHost + format: json + register: gather_template_result + +- when: zabbix_version is version('5.2', '<') + block: + - assert: + that: + - gather_template_result.template_json[template_export_key].groups.0.name == 'Linux servers' + - gather_template_result.template_json[template_export_key].groups.1.name == 'Templates' + - 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' + +- when: zabbix_version is version('5.2', '>=') + block: + - assert: + that: + - gather_template_result.template_json[template_export_key].groups.0.name == 'Linux servers' + - gather_template_result.template_json[template_export_key].groups.1.name == 'Templates' + - 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' + - 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' + +- when: zabbix_version is version('5.2', '<') + block: + - name: Import Zabbix template from JSON file with matching values (idempotency check). + zabbix_template: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_json: "{{ lookup('file', 'template1_50_lower.json') }}" + state: present + register: import_template_json + + - assert: + that: + - import_template_json.changed is sameas false + +- when: zabbix_version is version('5.2', '>=') + block: + - name: Import Zabbix template from JSON file with matching values (idempotency check). + zabbix_template: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_json: "{{ lookup('file', 'template1_52_higher.json') }}" + state: present + register: import_template_json + + - assert: + that: + - import_template_json.changed is sameas false + +- when: zabbix_version is version('5.2', '<') + block: + - name: Import Zabbix template from JSON file with updated values. + zabbix_template: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_json: "{{ lookup('file', 'template1-changed_50_lower.json') }}" + state: present + register: import_template_json + + - assert: + that: + - import_template_json.changed is sameas true + +- when: zabbix_version is version('5.2', '>=') + block: + - name: Import Zabbix template from JSON file with updated values. + zabbix_template: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_json: "{{ lookup('file', 'template1-changed_52_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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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' + +- when: zabbix_version is version('5.2', '<') + block: + - name: Import Zabbix template from XML file with updated values. + zabbix_template: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_xml: "{{ lookup('file', 'template2_50_lower.xml') }}" + state: present + register: import_template_xml + + - assert: + that: + - import_template_xml.changed is sameas true + +- when: zabbix_version is version('5.2', '>=') + block: + - name: Import Zabbix template from XML file with updated values. + zabbix_template: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_xml: "{{ lookup('file', 'template2_52_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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_name: ExampleHost + format: json + register: gather_template_result + +# zabbix returns values sorted alphabetically so HTTP Service template comes before Zabbix Proxy template +- when: zabbix_version is version('5.2', '<') + 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' + +- when: zabbix_version is version('5.2', '>=') + 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 == 'HTTP Service' + - gather_template_result.template_json[template_export_key].templates.0.templates.2.name == 'Zabbix Proxy' + +- name: Dump Zabbix template to XML format. + zabbix_template: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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' + +- name: Dump Zabbix template to JSON format. + zabbix_template: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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' + +- name: Delete Zabbix template. + zabbix_template: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_name: ExampleHost + state: absent + register: delete_zabbix_template_result + +- assert: + that: + - delete_zabbix_template_result.changed is sameas false diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template_info/meta/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template_info/meta/main.yml new file mode 100644 index 00000000..d3007478 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template_info/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template_info/tasks/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template_info/tasks/main.yml new file mode 100644 index 00000000..b66f8a0b --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_template_info/tasks/main.yml @@ -0,0 +1,86 @@ +--- +- name: "test - Prepare integration tests for zabbix_template_info module" + zabbix_template: + server_url: "{{ zabbix_server_url }} " + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_name: ExampleTemplateForTempleteInfoModule + template_groups: + - Templates + state: present + register: prepare_result + +- assert: + that: + - prepare_result.changed is sameas true + +- name: "test - Fetch template info as a JSON format from Zabbix Server" + zabbix_template_info: + server_url: "{{ zabbix_server_url }} " + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + template_export_key: "{{ item }}" + loop: "{{ fetch_template_json_format_result.template_json.keys() | list }}" + when: + - item | regex_search('_export') + +- assert: + that: + - fetch_template_json_format_result.template_json[template_export_key].date is defined + - fetch_template_json_format_result.template_json[template_export_key].groups.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: + server_url: "{{ zabbix_server_url }} " + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_name: ExampleTemplateForTempleteInfoModule + format: json + omit_date: yes + register: fetch_template_json_format_omit_date_result + +- 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].groups.0.name == "Templates" + - fetch_template_json_format_omit_date_result.template_json[template_export_key].templates.0.name == "ExampleTemplateForTempleteInfoModule" + - 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: + server_url: "{{ zabbix_server_url }} " + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_name: ExampleTemplateForTempleteInfoModule + format: xml + register: fetch_template_xml_format_result + +- 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: + server_url: "{{ zabbix_server_url }} " + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + template_name: ExampleTemplateForTempleteInfoModule + format: xml + omit_date: yes + register: fetch_template_xml_format_omit_date_result + +- 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 diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user/meta/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user/meta/main.yml new file mode 100644 index 00000000..d3007478 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user/tasks/for_zabbix_50_lower.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user/tasks/for_zabbix_50_lower.yml new file mode 100644 index 00000000..88ccbe22 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user/tasks/for_zabbix_50_lower.yml @@ -0,0 +1,1020 @@ +--- +# New user create test from here +- name: test - Create a new Zabbix user with check_mode and diff + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example + surname: test + usrgrps: + - Guests + passwd: password + check_mode: yes + diff: yes + register: create_zabbix_user_result + +- assert: + that: + - create_zabbix_user_result.changed is sameas true + +- name: test - Create a new Zabbix user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example + surname: test + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + override_passwd: yes + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example + surname: test + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologin: yes + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + check_mode: yes + diff: yes + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + check_mode: yes + diff: yes + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + state: absent + check_mode: yes + diff: yes + register: delete_existing_user_result + +- assert: + that: + - delete_existing_user_result.changed is sameas true + +- name: test - Delete existing user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example2alias + state: absent + register: delete_existing_user_result + + - assert: + that: + - delete_existing_user_result.changed is sameas true diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user/tasks/for_zabbix_52_higher.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user/tasks/for_zabbix_52_higher.yml new file mode 100644 index 00000000..fbffa27f --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user/tasks/for_zabbix_52_higher.yml @@ -0,0 +1,1077 @@ +--- +# New user create test from here +- name: test - Create a new Zabbix user with check_mode and diff + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example + surname: test + usrgrps: + - Guests + passwd: password + check_mode: yes + diff: yes + register: create_zabbix_user_result + +- assert: + that: + - create_zabbix_user_result.changed is sameas true + +- name: test - Create a new Zabbix user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example + surname: test + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + override_passwd: yes + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + name: example + surname: test + usrgrps: + - Guests + - Zabbix administrators + passwd: update_password + autologin: yes + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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_GB + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + check_mode: yes + diff: yes + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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_GB + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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_GB + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + - mediatype: SMS + sendto: example@example.com + period: 1-5,01:00-23:00 + severity: + not_classified: no + information: yes + warning: yes + average: no + high: yes + disaster: yes + active: yes + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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_GB + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + check_mode: yes + diff: yes + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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_GB + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: en_GB + user_medias: + - mediatype: Email + sendto: example@example.com + period: 1-7,00:00-24:00 + severity: + not_classified: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: yes + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example1 + state: absent + check_mode: yes + diff: yes + register: delete_existing_user_result + +- assert: + that: + - delete_existing_user_result.changed is sameas true + +- name: test - Delete existing user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example2alias + state: absent + register: delete_existing_user_result + + - assert: + that: + - delete_existing_user_result.changed is sameas true diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user/tasks/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user/tasks/main.yml new file mode 100644 index 00000000..298c9b46 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user/tasks/main.yml @@ -0,0 +1,10 @@ +--- +- 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.2 and higher + include_tasks: for_zabbix_52_higher.yml + when: + - zabbix_version | float >= 5.2 diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user_info/meta/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user_info/meta/main.yml new file mode 100644 index 00000000..d3007478 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user_info/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user_info/tasks/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user_info/tasks/main.yml new file mode 100644 index 00000000..90f4efe1 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_user_info/tasks/main.yml @@ -0,0 +1,208 @@ +--- +# New user create test from here +- when: zabbix_version is version('5.2', '<') + block: + - name: test - Create a new Zabbix user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example + name: user name + surname: user surname + usrgrps: + - Guests + - Disabled + passwd: password + lang: en_GB + theme: blue-theme + autologin: no + 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: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: no + 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.2', '>=') + block: + - name: test - Create a new Zabbix user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example + name: user name + surname: user surname + usrgrps: + - Guests + - Disabled + passwd: password + lang: en_GB + theme: blue-theme + autologin: no + 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: no + information: yes + warning: yes + average: yes + high: yes + disaster: yes + active: no + 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 + + - name: test - Set definition_of_results variable of Zabbix 5.2 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 - Get a zabbix user information" + zabbix_user_info: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example + register: get_user_info_result + +- name: "test - Set key to user_info_key variable(This deals with the key being masked)" + set_fact: + user_info_key: "{{ item }}" + loop: "{{ get_user_info_result.keys() | list }}" + when: + - item | regex_search('_user') + +- assert: + that: definition_of_results + + +- name: test - Create a new Zabbix user + zabbix_user: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example2 + usrgrps: + - Guests + - Disabled + passwd: password + state: present + register: create_zabbix_user_result2 + +- assert: + that: + - create_zabbix_user_result2.changed is sameas true + +- name: "test - Get a zabbix user information" + zabbix_user_info: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + alias: example2 + register: get_user_info_result2 + +- name: "test - Set key to user_info_key variable(This deals with the key being masked)" + 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" diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_usergroup/meta/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_usergroup/meta/main.yml new file mode 100644 index 00000000..d3007478 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_usergroup/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_zabbix diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_usergroup/tasks/main.yml b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_usergroup/tasks/main.yml new file mode 100644 index 00000000..5e783301 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/integration/targets/test_zabbix_usergroup/tasks/main.yml @@ -0,0 +1,138 @@ +--- +- 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: + zabbix_usergroup: + server_url: "{{ zabbix_server_url }}" + login_user: "{{ zabbix_login_user }}" + login_password: "{{ zabbix_login_password }}" + 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 + + - name: test - update Zabbix user group with one right + zabbix_usergroup: + rights: + - host_group: Discovered hosts + permission: read-only + register: usergroup_updated_right + + - name: assert that user group was updated + assert: + that: usergroup_updated_right 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: assert that user group was updated + assert: + that: usergroup_updated_rights 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 + + - 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 - 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 diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/sanity/ignore-2.10.txt b/collections-debian-merged/ansible_collections/community/zabbix/tests/sanity/ignore-2.10.txt new file mode 100644 index 00000000..280617e4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/sanity/ignore-2.10.txt @@ -0,0 +1,48 @@ +scripts/inventory/zabbix.py future-import-boilerplate +scripts/inventory/zabbix.py metaclass-boilerplate +plugins/modules/zabbix_action.py validate-modules:doc-choices-do-not-match-spec +plugins/modules/zabbix_action.py validate-modules:doc-default-does-not-match-spec +plugins/modules/zabbix_action.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_action.py validate-modules:doc-required-mismatch +plugins/modules/zabbix_action.py validate-modules:invalid-argument-name +plugins/modules/zabbix_action.py validate-modules:missing-suboption-docs +plugins/modules/zabbix_action.py validate-modules:nonexistent-parameter-documented +plugins/modules/zabbix_action.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_action.py validate-modules:parameter-type-not-in-doc +plugins/modules/zabbix_action.py validate-modules:undocumented-parameter +plugins/modules/zabbix_group.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_group.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_group_info.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_group_info.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_host.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_host.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_host_info.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_host_info.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_maintenance.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_maintenance.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_mediatype.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_mediatype.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_template.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_template.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_user.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_user.py validate-modules:parameter-list-no-elements +plugins/doc_fragments/zabbix.py future-import-boilerplate +plugins/doc_fragments/zabbix.py metaclass-boilerplate +roles/zabbix_agent/molecule/with-server/tests/test_agent.py future-import-boilerplate +roles/zabbix_agent/molecule/with-server/tests/test_default.py future-import-boilerplate +roles/zabbix_agent/molecule/with-server/tests/test_agent.py metaclass-boilerplate +roles/zabbix_agent/molecule/with-server/tests/test_default.py metaclass-boilerplate +molecule/zabbix_web/tests/test_default.py metaclass-boilerplate +molecule/zabbix_web/tests/test_default.py future-import-boilerplate +molecule/zabbix_javagateway/tests/test_default.py metaclass-boilerplate +molecule/zabbix_javagateway/tests/test_default.py future-import-boilerplate +molecule/zabbix_server/tests/test_default.py future-import-boilerplate +molecule/zabbix_server/tests/test_default.py metaclass-boilerplate +molecule/zabbix_agent/tests/test_agent2.py future-import-boilerplate +molecule/zabbix_agent/tests/test_agent.py future-import-boilerplate +molecule/zabbix_agent/tests/test_docker.py future-import-boilerplate +molecule/zabbix_agent/tests/test_agent2.py metaclass-boilerplate +molecule/zabbix_agent/tests/test_agent.py metaclass-boilerplate +molecule/zabbix_agent/tests/test_docker.py metaclass-boilerplate +molecule/zabbix_proxy/tests/test_default.py future-import-boilerplate +molecule/zabbix_proxy/tests/test_default.py metaclass-boilerplate
\ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/sanity/ignore-2.11.txt b/collections-debian-merged/ansible_collections/community/zabbix/tests/sanity/ignore-2.11.txt new file mode 100644 index 00000000..36d703a9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/sanity/ignore-2.11.txt @@ -0,0 +1,48 @@ +scripts/inventory/zabbix.py future-import-boilerplate +scripts/inventory/zabbix.py metaclass-boilerplate +plugins/modules/zabbix_action.py validate-modules:doc-choices-do-not-match-spec +plugins/modules/zabbix_action.py validate-modules:doc-default-does-not-match-spec +plugins/modules/zabbix_action.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_action.py validate-modules:doc-required-mismatch +plugins/modules/zabbix_action.py validate-modules:invalid-argument-name +plugins/modules/zabbix_action.py validate-modules:missing-suboption-docs +plugins/modules/zabbix_action.py validate-modules:nonexistent-parameter-documented +plugins/modules/zabbix_action.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_action.py validate-modules:parameter-type-not-in-doc +plugins/modules/zabbix_action.py validate-modules:undocumented-parameter +plugins/modules/zabbix_group.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_group.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_group_info.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_group_info.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_host.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_host.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_host_info.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_host_info.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_maintenance.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_maintenance.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_mediatype.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_mediatype.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_template.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_template.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_user.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_user.py validate-modules:parameter-list-no-elements +plugins/doc_fragments/zabbix.py future-import-boilerplate +plugins/doc_fragments/zabbix.py metaclass-boilerplate +roles/zabbix_agent/molecule/with-server/tests/test_agent.py future-import-boilerplate +roles/zabbix_agent/molecule/with-server/tests/test_default.py future-import-boilerplate +roles/zabbix_agent/molecule/with-server/tests/test_agent.py metaclass-boilerplate +roles/zabbix_agent/molecule/with-server/tests/test_default.py metaclass-boilerplate +molecule/zabbix_web/tests/test_default.py future-import-boilerplate +molecule/zabbix_web/tests/test_default.py metaclass-boilerplate +molecule/zabbix_javagateway/tests/test_default.py metaclass-boilerplate +molecule/zabbix_javagateway/tests/test_default.py future-import-boilerplate +molecule/zabbix_server/tests/test_default.py future-import-boilerplate +molecule/zabbix_server/tests/test_default.py metaclass-boilerplate +molecule/zabbix_agent/tests/test_agent2.py future-import-boilerplate +molecule/zabbix_agent/tests/test_agent.py future-import-boilerplate +molecule/zabbix_agent/tests/test_docker.py future-import-boilerplate +molecule/zabbix_agent/tests/test_agent2.py metaclass-boilerplate +molecule/zabbix_agent/tests/test_agent.py metaclass-boilerplate +molecule/zabbix_agent/tests/test_docker.py metaclass-boilerplate +molecule/zabbix_proxy/tests/test_default.py future-import-boilerplate +molecule/zabbix_proxy/tests/test_default.py metaclass-boilerplate
\ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/sanity/ignore-2.9.txt b/collections-debian-merged/ansible_collections/community/zabbix/tests/sanity/ignore-2.9.txt new file mode 100644 index 00000000..f61953e5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/sanity/ignore-2.9.txt @@ -0,0 +1,48 @@ +scripts/inventory/zabbix.py future-import-boilerplate +scripts/inventory/zabbix.py metaclass-boilerplate +plugins/modules/zabbix_action.py validate-modules:doc-choices-do-not-match-spec +plugins/modules/zabbix_action.py validate-modules:doc-default-does-not-match-spec +plugins/modules/zabbix_action.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_action.py validate-modules:doc-required-mismatch +plugins/modules/zabbix_action.py validate-modules:invalid-argument-name +plugins/modules/zabbix_action.py validate-modules:missing-suboption-docs +plugins/modules/zabbix_action.py validate-modules:nonexistent-parameter-documented +plugins/modules/zabbix_action.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_action.py validate-modules:parameter-type-not-in-doc +plugins/modules/zabbix_action.py validate-modules:undocumented-parameter +plugins/modules/zabbix_group.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_group.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_group_info.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_group_info.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_host.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_host.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_host_info.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_host_info.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_maintenance.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_maintenance.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_mediatype.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_mediatype.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_template.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_template.py validate-modules:parameter-list-no-elements +plugins/modules/zabbix_user.py validate-modules:doc-elements-mismatch +plugins/modules/zabbix_user.py validate-modules:parameter-list-no-elements +plugins/doc_fragments/zabbix.py future-import-boilerplate +plugins/doc_fragments/zabbix.py metaclass-boilerplate +roles/zabbix_agent/molecule/with-server/tests/test_agent.py future-import-boilerplate +roles/zabbix_agent/molecule/with-server/tests/test_default.py future-import-boilerplate +roles/zabbix_agent/molecule/with-server/tests/test_agent.py metaclass-boilerplate +roles/zabbix_agent/molecule/with-server/tests/test_default.py metaclass-boilerplate +molecule/zabbix_web/tests/test_default.py metaclass-boilerplate +molecule/zabbix_web/tests/test_default.py future-import-boilerplate +molecule/zabbix_javagateway/tests/test_default.py future-import-boilerplate +molecule/zabbix_javagateway/tests/test_default.py metaclass-boilerplate +molecule/zabbix_server/tests/test_default.py future-import-boilerplate +molecule/zabbix_server/tests/test_default.py metaclass-boilerplate +molecule/zabbix_agent/tests/test_agent2.py future-import-boilerplate +molecule/zabbix_agent/tests/test_agent.py future-import-boilerplate +molecule/zabbix_agent/tests/test_docker.py future-import-boilerplate +molecule/zabbix_agent/tests/test_agent2.py metaclass-boilerplate +molecule/zabbix_agent/tests/test_agent.py metaclass-boilerplate +molecule/zabbix_agent/tests/test_docker.py metaclass-boilerplate +molecule/zabbix_proxy/tests/test_default.py metaclass-boilerplate +molecule/zabbix_proxy/tests/test_default.py future-import-boilerplate
\ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/community/zabbix/tests/sanity/requirements.txt b/collections-debian-merged/ansible_collections/community/zabbix/tests/sanity/requirements.txt new file mode 100644 index 00000000..3e3a9669 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/zabbix/tests/sanity/requirements.txt @@ -0,0 +1,4 @@ +packaging # needed for update-bundled and changelog +sphinx ; python_version >= '3.5' # docs build requires python 3+ +sphinx-notfound-page ; python_version >= '3.5' # docs build requires python 3+ +straight.plugin ; python_version >= '3.5' # needed for hacking/build-ansible.py which will host changelog generation and requires python 3+ |