| 1 |
--- |
| 2 |
- name: test - create new Zabbix group |
| 3 |
community.zabbix.zabbix_group: |
| 4 |
host_groups: |
| 5 |
- zbxgrp_example_group01 |
| 6 |
state: present |
| 7 |
register: zbxgrp_new |
| 8 |
|
| 9 |
- name: assert that group was created |
| 10 |
ansible.builtin.assert: |
| 11 |
that: zbxgrp_new is changed |
| 12 |
|
| 13 |
- name: test - create simple zabbix host to assign to group |
| 14 |
community.zabbix.zabbix_host: |
| 15 |
host_name: zbxgrp_example_host01 |
| 16 |
host_groups: |
| 17 |
- zbxgrp_example_group01 |
| 18 |
interfaces: |
| 19 |
- type: agent |
| 20 |
main: 1 |
| 21 |
dns: zbxgrp_example_host01 |
| 22 |
state: present |
| 23 |
register: zbxgrp_host_assignement |
| 24 |
|
| 25 |
- name: assert that host was assigned successfully |
| 26 |
ansible.builtin.assert: |
| 27 |
that: zbxgrp_host_assignement is changed |
| 28 |
|
| 29 |
- name: test - create same Zabbix group once again |
| 30 |
community.zabbix.zabbix_group: |
| 31 |
host_groups: |
| 32 |
- zbxgrp_example_group01 |
| 33 |
state: present |
| 34 |
register: zbxgrp_existing |
| 35 |
|
| 36 |
- name: assert that nothing has been changed |
| 37 |
ansible.builtin.assert: |
| 38 |
that: not zbxgrp_existing is changed |
| 39 |
|
| 40 |
- name: test - attempt to create new Zabbix group matching name of default Zabbix group |
| 41 |
community.zabbix.zabbix_group: |
| 42 |
host_groups: |
| 43 |
- Linux servers |
| 44 |
state: present |
| 45 |
register: zbxgrp_default_existing |
| 46 |
|
| 47 |
- name: assert that nothing has been changed |
| 48 |
ansible.builtin.assert: |
| 49 |
that: not zbxgrp_default_existing is changed |
| 50 |
|
| 51 |
- name: test - attempt to delete host group while its only group host has assigned |
| 52 |
community.zabbix.zabbix_group: |
| 53 |
host_groups: |
| 54 |
- zbxgrp_example_group01 |
| 55 |
state: absent |
| 56 |
register: zbxgrp_existing_delete_failed |
| 57 |
ignore_errors: true |
| 58 |
|
| 59 |
- name: assert that group deletion failed |
| 60 |
ansible.builtin.assert: |
| 61 |
that: zbxgrp_existing_delete_failed is failed |
| 62 |
|
| 63 |
- name: delete helper zabbix host |
| 64 |
community.zabbix.zabbix_host: |
| 65 |
host_name: zbxgrp_example_host01 |
| 66 |
state: absent |
| 67 |
|
| 68 |
- name: test - attempt to delete previously created zabbix group |
| 69 |
community.zabbix.zabbix_group: |
| 70 |
host_groups: |
| 71 |
- zbxgrp_example_group01 |
| 72 |
state: absent |
| 73 |
register: zbxgrp_existing_delete |
| 74 |
|
| 75 |
- name: assert that group was deleted |
| 76 |
ansible.builtin.assert: |
| 77 |
that: zbxgrp_existing_delete is changed |
| 78 |
|
| 79 |
- name: test - attempt to delete non-existing zabbix group |
| 80 |
community.zabbix.zabbix_group: |
| 81 |
host_groups: |
| 82 |
- zbxgrp_example_group01 |
| 83 |
state: absent |
| 84 |
register: zbxgrp_missing_delete |
| 85 |
|
| 86 |
- name: assert that nothing has been changed |
| 87 |
ansible.builtin.assert: |
| 88 |
that: not zbxgrp_missing_delete is changed |
| 89 |
|
| 90 |
- when: zabbix_version is version('7.0', '>=') |
| 91 |
name: support propagate option for Zabbix version (>=7.0) |
| 92 |
block: |
| 93 |
- name: test - create hostgroup with propagation |
| 94 |
community.zabbix.zabbix_group: |
| 95 |
host_groups: |
| 96 |
- zbxgrp_example_group01 |
| 97 |
- zbxgrp_example_group01/subhostgroup |
| 98 |
propagate: |
| 99 |
permissions: true |
| 100 |
tag_filters: true |
| 101 |
state: present |
| 102 |
register: zbxgrp_create |
| 103 |
|
| 104 |
- name: assert that group was created |
| 105 |
ansible.builtin.assert: |
| 106 |
that: zbxgrp_create is changed |
| 107 |
|
| 108 |
- name: test - propagate without creation hostgroup |
| 109 |
community.zabbix.zabbix_group: |
| 110 |
host_groups: |
| 111 |
- zbxgrp_example_group01 |
| 112 |
- zbxgrp_example_group01/subhostgroup |
| 113 |
propagate: |
| 114 |
permissions: true |
| 115 |
tag_filters: true |
| 116 |
state: present |
| 117 |
register: zbxgrp_propagate |
| 118 |
|
| 119 |
- name: assert that group was propagated |
| 120 |
ansible.builtin.assert: |
| 121 |
that: zbxgrp_propagate is changed |
| 122 |
|
| 123 |
- name: test - delete hostgroups |
| 124 |
community.zabbix.zabbix_group: |
| 125 |
host_groups: |
| 126 |
- zbxgrp_example_group01 |
| 127 |
- zbxgrp_example_group01/subhostgroup |
| 128 |
state: absent |