The following task:
- name: Filter out private IPs from addresses
set_fact:
private_ips: "{{ addresses | ansible.utils.ipaddr('private') | list }}"
Failed with this output, but had worked before!
TASK [Filter out private IPs from addresses] **********************************************************************
The full traceback is:
Traceback (most recent call last):
File "/Users/timh/.pyenv/versions/3.11.8/lib/python3.11/site-packages/ansible/executor/task_executor.py", line 526, in _execute
self._task.post_validate(templar=templar)
File "/Users/timh/.pyenv/versions/3.11.8/lib/python3.11/site-packages/ansible/playbook/task.py", line 290, in post_validate
super(Task, self).post_validate(templar)
File "/Users/timh/.pyenv/versions/3.11.8/lib/python3.11/site-packages/ansible/playbook/base.py", line 543, in post_validate
value = method(attribute, getattr(self, name), templar)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/timh/.pyenv/versions/3.11.8/lib/python3.11/site-packages/ansible/playbook/task.py", line 298, in _post_validate_args
args = templar.template(value)
^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/timh/.pyenv/versions/3.11.8/lib/python3.11/site-packages/ansible/template/__init__.py", line 791, in template
d[k] = self.template(
^^^^^^^^^^^^^^
File "/Users/timh/.pyenv/versions/3.11.8/lib/python3.11/site-packages/ansible/template/__init__.py", line 764, in template
result = self.do_template(
^^^^^^^^^^^^^^^^^
File "/Users/timh/.pyenv/versions/3.11.8/lib/python3.11/site-packages/ansible/template/__init__.py", line 1010, in do_template
res = myenv.concat(rf)
^^^^^^^^^^^^^^^^
File "/Users/timh/.pyenv/versions/3.11.8/lib/python3.11/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 "/Users/timh/.pyenv/versions/3.11.8/lib/python3.11/site-packages/ansible/template/__init__.py", line 295, in wrapper
ret = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/timh/.pyenv/versions/3.11.8/lib/python3.11/site-packages/ansible_collections/ansible/utils/plugins/filter/ipaddr.py", line 283, in _ipaddr
return ipaddr(**updated_data)
^^^^^^^^^^^^^^^^^^^^^^
File "/Users/timh/.pyenv/versions/3.11.8/lib/python3.11/site-packages/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 "/Users/timh/.pyenv/versions/3.11.8/lib/python3.11/site-packages/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 "/Users/timh/.pyenv/versions/3.11.8/lib/python3.11/site-packages/ansible_collections/ansible/utils/plugins/plugin_utils/base/ipaddr_utils.py", line 573, in ipaddr
return query_func_map[query](v, *extras)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/timh/.pyenv/versions/3.11.8/lib/python3.11/site-packages/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: [host-2]: FAILED! => {
"changed": false
}
The other key piece of information is that I had the latest version of netaddr
installed:
% pip list | grep netaddr
netaddr 1.2.1
How can I fix this code? It seems to comply with the documentation.