community.zabbix
community.zabbix copied to clipboard
Create new host group fails in check mode (`name 'Already_Exists' is not defined`)
zabbix_group fails in check mode, if host group is not existing yet.
Task:
- name: "API | Create host groups"
zabbix_group:
host_group:
- Other servers3
vars:
ansible_connection: httpapi
ansible_network_os: community.zabbix.zabbix
ansible_user: '{{ zabbix_api_login_user }}'
ansible_httpapi_pass: '{{ zabbix_api_login_pass }}'
ansible_httpapi_use_ssl: '{{ (zabbix_api_server_url | urlsplit("scheme") == "https") | ternary(true, false) }}'
delegate_to: '{{ zabbix_api_server_url | urlsplit("hostname") }}'
Command: ansible-playbook site.yml -l prod_hosts --check -vvv
Result:
TASK [zabbix : API | Create host groups] [CHECK MODE] ******************************************************************************** task path: /srv/Projects/example.com/infra/roles/zabbix/tasks/main.yml:157 redirecting (type: connection) ansible.builtin.httpapi to ansible.netcommon.httpapi redirecting (type: modules) ansible.builtin.zabbix_group to community.zabbix.zabbix_group redirecting (type: modules) ansible.builtin.zabbix_group to community.zabbix.zabbix_group Using module file /opt/pipx/venvs/ansible/lib/python3.10/site-packages/ansible_collections/community/zabbix/plugins/modules/zabbix_group.py Pipelining is enabled. <zabbix.example.com> ESTABLISH LOCAL CONNECTION FOR USER: root <zabbix.example.com> EXEC /bin/sh -c '/opt/pipx/venvs/ansible/bin/python && sleep 0' fatal: [prod_host_node -> zabbix.example.com]: FAILED! => changed: false module_stderr: '' module_stdout: |4-
{"changed": true, "invocation": {"module_args": {"host_group": ["Other servers3"], "host_groups": ["Other servers3"], "timeout": 10, "validate_certs": true, "state": "present", "server_url": null, "login_user": null, "login_password": null}}, "warnings": ["Option "server_url" is deprecated with the move to httpapi connection and will be removed in the next release", "Option "login_user" is deprecated with the move to httpapi connection and will be removed in the next release", "Option "login_password" is deprecated with the move to httpapi connection and will be removed in the next release", "Option "timeout" is deprecated with the move to httpapi connection and will be removed in the next release", "Option "validate_certs" is deprecated with the move to httpapi connection and will be removed in the next release"]}
{"failed": true, "msg": "Failed to create host group(s): name 'Already_Exists' is not defined", "exception": " File "/tmp/ansible_zabbix_group_payload_ea42hbg6/ansible_zabbix_group_payload.zip/ansible_collections/community/zabbix/plugins/modules/zabbix_group.py", line 119, in create_host_group\n", "invocation": {"module_args": {"host_group": ["Other servers3"], "host_groups": ["Other servers3"], "timeout": 10, "validate_certs": true, "state": "present", "server_url": null, "login_user": null, "login_password": null}}, "warnings": ["Option "server_url" is deprecated with the move to httpapi connection and will be removed in the next release", "Option "login_user" is deprecated with the move to httpapi connection and will be removed in the next release", "Option "login_password" is deprecated with the move to httpapi connection and will be removed in the next release", "Option "timeout" is deprecated with the move to httpapi connection and will be removed in the next release", "Option "validate_certs" is deprecated with the move to httpapi connection and will be removed in the next release"]} msg: |- MODULE FAILURE See stdout/stderr for the exact error rc: 1
Environment:
ansible [core 2.14.1]
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/pipx/venvs/ansible/lib/python3.10/site-packages/ansible
ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/pipx/bin/ansible
python version = 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0] (/opt/pipx/venvs/ansible/bin/python)
jinja version = 3.1.2
libyaml = True
community.zabbix 1.9.0
ANSIBLE_PIPELINING(/srv/Projects/xxx/infra/ansible.cfg) = True
CONFIG_FILE() = /srv/Projects/xxx/infra/ansible.cfg
DEFAULT_FORCE_HANDLERS(/srv/Projects/xxx/infra/ansible.cfg) = True
DEFAULT_JINJA2_NATIVE(/srv/Projects/xxx/infra/ansible.cfg) = True
DIFF_ALWAYS(/srv/Projects/xxx/infra/ansible.cfg) = True
INTERPRETER_PYTHON(/srv/Projects/xxx/infra/ansible.cfg) = auto
Zabbix 6.2.6