Skip to content

ipv6form

Collection Note

This module is part of the ansible.utils collection. To install the collection, use:

ansible-galaxy collection install ansible.utils
Added in version 2.11.0.

Synopsis

  • This filter is designed to convert ipv6 addresses in different formats.

Parameters

Parameter Defaults / Choices Comments
format
str
Choices: compress, expand, x509 Different formats example. compress, expand, x509
value
str
required
individual ipv6 address input for ipv6_format plugin.

Examples

#### examples
# Ipv6form filter plugin with different format.
- name: Expand given Ipv6 address
  debug:
      msg: "{{ '1234:4321:abcd:dcba::17' | ansible.utils.ipv6form('expand') }}"

- name: Compress  given Ipv6 address
  debug:
      msg: "{{ '1234:4321:abcd:dcba:0000:0000:0000:0017' | ansible.utils.ipv6form('compress') }}"

- name: Covert given Ipv6 address in x509
  debug:
      msg: "{{ '1234:4321:abcd:dcba::17' | ansible.utils.ipv6form('x509') }}"

# TASK [Expand given Ipv6 address] ************************************************************************************
# task path: /home/amhatre/dev/playbook/test_ipform.yaml:7
# Loading collection ansible.utils from /home/amhatre/dev/collections/ansible_collections/ansible/utils
# ok: [localhost] => {
#     "msg": "1234:4321:abcd:dcba:0000:0000:0000:0017"
# }

# TASK [Compress  given Ipv6 address] *********************************************************************************
# task path: /home/amhatre/dev/playbook/test_ipform.yaml:11
# Loading collection ansible.utils from /home/amhatre/dev/collections/ansible_collections/ansible/utils
# ok: [localhost] => {
#     "msg": "1234:4321:abcd:dcba::17"
# }

# TASK [Covert given Ipv6 address in x509] ****************************************************************************
# task path: /home/amhatre/dev/playbook/test_ipform.yaml:15
# Loading collection ansible.utils from /home/amhatre/dev/collections/ansible_collections/ansible/utils
# ok: [localhost] => {
#     "msg": "1234:4321:abcd:dcba:0:0:0:17"
# }

# PLAY RECAP **********************************************************************************************************
# localhost                  : ok=3    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Return Values

Key Data Type Description Returned
data str Returns result ipv6 address in expected format.

Authors

  • Ashwini Mhatre (@amhatre)