ipaddr always compresses IPv6 addresses

14 views
Skip to first unread message

Dick Visser

unread,
Apr 2, 2024, 3:44:53 PM4/2/24
to ansible...@googlegroups.com
Hii,
I noticed that the ipaddr filter seems to compress IPv6 addresses.
For example I feed a list to ipaddr that contains (among other things)
uncompressed IPv6 addresses:

---
- name: Testing
hosts: localhost
connection: local
gather_facts: no

vars:
ips:
- 192.168.178.1
- fd00:0000:0000:0000:06b4:feff:fe59:ebf4
- 2a10:3782:542d:0001:06b4:feff:fe59:ebf4
- fritz.box

tasks:
- debug: var=ips|ipaddr('address')

gives:

TASK [debug] **********************************************************************
ok: [localhost] =>
ips|ipaddr('address'):
- 192.168.178.1
- fd00::6b4:feff:fe59:ebf4
- 2a10:3782:542d:1:6b4:feff:fe59:ebf4



Is there a way to keep the original format?
Or a more generic filter that can (de)compress IPv6 addresses?

thx

Dick

Dick Visser

unread,
Apr 2, 2024, 4:19:53 PM4/2/24
to ansible...@googlegroups.com
On Tue, 2 Apr 2024 at 21:44, Dick Visser <dnmv...@gmail.com> wrote:

> Is there a way to keep the original format?
> Or a more generic filter that can (de)compress IPv6 addresses?

To answer my own question, it seems there is: ipv6form.
The docs are mangled though:
https://docs.ansible.com/ansible/latest/collections/ansible/utils/ipv6form_filter.html
I was able to get what I need by reading the source.

Dick
Reply all
Reply to author
Forward
0 new messages