generated from ansible-collections/collection_template
-
Notifications
You must be signed in to change notification settings - Fork 86
Open
Description
SUMMARY
ansible.utils.* filters break if used in template macro.
Tested with ipaddr filters (ipaddr, cidr_merge), keep_keys.
ISSUE TYPE
- Bug Report
COMPONENT NAME
ANSIBLE VERSION
ansible [core 2.19.1]
config file = None
configured module search path = ['/home/username/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
ansible collection location = /home/username/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/bin/ansible
python version = 3.13.7 (main, Aug 20 2025, 22:17:40) [GCC 14.3.0] (/usr/bin/python3)
jinja version = 3.1.6
pyyaml version = 6.0.2 (with libyaml v0.2.5)
COLLECTION VERSION
CONFIGURATION
OS / ENVIRONMENT
Tested on: Ubuntu 24.04, Debian sid
STEPS TO REPRODUCE
Playbook:
---
- hosts: localhost
gather_facts: no
tasks:
- template:
src: template.j2
dest: /tmp/wtf
diff: yes
template.j2:
{% import 'macros.j2' as macros with context %}
{{ macros.merge(cidrs=['10.0.0.0/32', '10.0.0.1/32']) }}
macros.j2:
{% macro merge(cidrs=[]) %}
{{ cidrs | ansible.utils.cidr_merge }}
{% endmacro %}
EXPECTED RESULTS
['10.0.0.0/31']
in template
ACTUAL RESULTS
TASK [template] **********************************************************************************************************************************
[ERROR]: Task failed: The filter plugin 'ansible.utils.cidr_merge' failed: Template.__new__() missing 1 required positional argument: 'source'
Task failed.
Origin: /tmp/test/test.yaml:5:7
3 gather_facts: no
4 tasks:
5 - template:
^ column 7
<<< caused by >>>
The filter plugin 'ansible.utils.cidr_merge' failed: Template.__new__() missing 1 required positional argument: 'source'
Origin: /tmp/test/template.j2
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Task failed: The filter plugin 'ansible.utils.cidr_merge' failed: Template.__new__() missing 1 required positional argument: 'source'"}
Metadata
Metadata
Assignees
Labels
No labels