Role zabbix_agent fails with recent netaddr version
matthijs-oosterhoff opened this issue · comments
SUMMARY
The zabbix_agent
seems to be incompatible with a recent version of netaddr
. The readme doesn't specify a version to install, so I would assume using the latest from pip3
should work.
I am running v2.3.1 of community.zabbix
, but I tested with te current main
branch too, results are the same.
The role fails on a task where it tries to list private IP addresses:
TASK [community.zabbix.zabbix_agent : Get Total Private IP Addresses] **********
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'IPNetwork' object has no attribute 'is_private'
fatal: [zabbix1.shockdev.nl]: FAILED! => {
"changed": false
}
ISSUE TYPE
- Bug Report
COMPONENT NAME
Role: zabbix_agent
ANSIBLE VERSION
ansible [core 2.16.5]
config file = /home/matthijs/git/dev/ansible/admx_playbooks/admx/ansible.cfg
configured module search path = ['/home/matthijs/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/matthijs/git/dev/ansible/admx_playbooks/venv/lib/python3.10/site-packages/ansible
ansible collection location = /home/matthijs/.ansible/collections:/usr/share/ansible/collections
executable location = /home/matthijs/git/dev/ansible/admx_playbooks/venv/bin/ansible
python version = 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (/home/matthijs/git/dev/ansible/admx_playbooks/venv/bin/python3)
jinja version = 3.1.3
libyaml = True
CONFIGURATION
CALLBACKS_ENABLED(/home/matthijs/git/dev/ansible/admx_playbooks/admx/ansible.cfg) = ['auto_tags']
CONFIG_FILE() = /home/matthijs/git/dev/ansible/admx_playbooks/admx/ansible.cfg
DEFAULT_CALLBACK_PLUGIN_PATH(/home/matthijs/git/dev/ansible/admx_playbooks/admx/ansible.cfg) = ['/home/matthijs/git/dev/ansible/admx>
DEFAULT_FORKS(/home/matthijs/git/dev/ansible/admx_playbooks/admx/ansible.cfg) = 10
DEFAULT_JINJA2_EXTENSIONS(/home/matthijs/git/dev/ansible/admx_playbooks/admx/ansible.cfg) = jinja2.ext.do
DEFAULT_STDOUT_CALLBACK(/home/matthijs/git/dev/ansible/admx_playbooks/admx/ansible.cfg) = debug
DEFAULT_STRATEGY(/home/matthijs/git/dev/ansible/admx_playbooks/admx/ansible.cfg) = free
OS / ENVIRONMENT / Zabbix Version
Workstation:
matthijs@ws61:~$ uname -r
6.5.0-26-generic
matthijs@ws61:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.4 LTS
Release: 22.04
Codename: jammy
Zabbix host:
(shockdev.nl) root@zabbix1:~# uname -r
5.15.0-88-generic
(shockdev.nl) root@zabbix1:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.3 LTS
Release: 22.04
Codename: jammy
STEPS TO REPRODUCE
Roll out the zabbix_agent
role on some host while the machine running Ansible has netaddr==1.2.1
EXPECTED RESULTS
Success
ACTUAL RESULTS
See summary. Below is the output with -vvv
:
TASK [community.zabbix.zabbix_agent : Get Total Private IP Addresses] ***************************************************************
task path: /home/matthijs/.ansible/collections/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/Linux.yml:11
The full traceback is:
Traceback (most recent call last):
File "/home/matthijs/git/dev/ansible/admx_playbooks/venv/lib/python3.10/site-packages/ansible/executor/task_executor.py", line 526, in _execute
self._task.post_validate(templar=templar)
File "/home/matthijs/git/dev/ansible/admx_playbooks/venv/lib/python3.10/site-packages/ansible/playbook/task.py", line 290, in post_validate
super(Task, self).post_validate(templar)
File "/home/matthijs/git/dev/ansible/admx_playbooks/venv/lib/python3.10/site-packages/ansible/playbook/base.py", line 543, in post_validate
value = method(attribute, getattr(self, name), templar)
File "/home/matthijs/git/dev/ansible/admx_playbooks/venv/lib/python3.10/site-packages/ansible/playbook/task.py", line 298, in _post_validate_args
args = templar.template(value)
File "/home/matthijs/git/dev/ansible/admx_playbooks/venv/lib/python3.10/site-packages/ansible/template/__init__.py", line 791, in template
d[k] = self.template(
File "/home/matthijs/git/dev/ansible/admx_playbooks/venv/lib/python3.10/site-packages/ansible/template/__init__.py", line 764, in template
result = self.do_template(
File "/home/matthijs/git/dev/ansible/admx_playbooks/venv/lib/python3.10/site-packages/ansible/template/__init__.py", line 1010, in do_template
res = myenv.concat(rf)
File "/home/matthijs/git/dev/ansible/admx_playbooks/venv/lib/python3.10/site-packages/ansible/template/native_helpers.py", line 43, in ansible_eval_concat
head = list(islice(nodes, 2))
File "<template>", line 24, in root
File "/home/matthijs/git/dev/ansible/admx_playbooks/venv/lib/python3.10/site-packages/ansible/template/__init__.py", line 295, in wrapper
ret = func(*args, **kwargs)
File "/home/matthijs/.ansible/collections/ansible_collections/ansible/utils/plugins/filter/ipaddr.py", line 283, in _ipaddr
return ipaddr(**updated_data)
File "/home/matthijs/.ansible/collections/ansible_collections/ansible/utils/plugins/plugin_utils/base/ipaddr_utils.py", line 458, in ipaddr
_ret = [ipaddr(element, str(query), version) for element in value]
File "/home/matthijs/.ansible/collections/ansible_collections/ansible/utils/plugins/plugin_utils/base/ipaddr_utils.py", line 458, in <listcomp>
_ret = [ipaddr(element, str(query), version) for element in value]
File "/home/matthijs/.ansible/collections/ansible_collections/ansible/utils/plugins/plugin_utils/base/ipaddr_utils.py", line 573, in ipaddr
return query_func_map[query](v, *extras)
File "/home/matthijs/.ansible/collections/ansible_collections/ansible/utils/plugins/plugin_utils/base/ipaddr_utils.py", line 292, in _private_query
if v.is_private():
AttributeError: 'IPNetwork' object has no attribute 'is_private'
fatal: [zabbix1.shockdev.nl]: FAILED! => {
"changed": false
}
I only just found out about ansible-collections/ansible.utils#338. I guess my issue is a duplicate and I'll have to await the ansible.utils
release.
Thanks @matthijs-oosterhoff for the link :) helped me find the info I was looking for. Much appreciated!
For anyone else who happens to stumble upon this thread, the 4.0.0 release of ansible.utils just came out today.
I added this to my requirements.yml:
collections:
- name: community.zabbix
version: 1.9.3
- name: ansible.utils
version: ">=4.0.0"