.. _ansible.utils.ipv6_filter:
******************
ansible.utils.ipv6
******************
**To filter only Ipv6 addresses Ipv6 filter is used.**
Version added: 2.5.0
.. contents::
:local:
:depth: 1
Synopsis
--------
- Sometimes you need only IPv6 addresses. To filter only Ipv6 addresses Ipv6 filter is used.
Parameters
----------
.. raw:: html
Parameter |
Choices/Defaults |
Configuration |
Comments |
query
string
|
Default:
""
|
|
You can provide a single argument to each ipv6() filter.
Example. query type 'ipv4' to convert ipv6 into ipv4
|
value
raw
/ required
|
|
|
list of subnets or individual address or any other values input for ipv6 plugin
|
Examples
--------
.. code-block:: yaml
#### examples
# Ipv6 filter plugin with different queries.
- name: Set value as input list
ansible.builtin.set_fact:
value:
- 192.24.2.1
- ::ffff:192.168.32.0/120
- ''
- ::ffff:192.24.2.1/128
- 192.168.32.0/24
- fe80::100/10
- true
- name: IPv6 filter to filter Ipv6 Address
debug:
msg: "{{ value|ansible.utils.ipv6 }}"
- name: convert IPv6 addresses into IPv4 addresses.
debug:
msg: "{{ value|ansible.utils.ipv6('ipv4') }}"
- name: filter only IPv6 addresses.
debug:
msg: "{{ value|ansible.utils.ipv6('address') }}"
# PLAY [Ipv6 filter plugin with different queries.] ******************************************************************
# TASK [Set value as input list] ***************************************************************************************
# ok: [localhost] => {
# "ansible_facts": {
# "value": [
# "192.24.2.1",
# "::ffff:192.168.32.0/120",
# "",
# "::ffff:192.24.2.1/128",
# "192.168.32.0/24",
# "fe80::100/10",
# true
# ]
# },
# "changed": false
# }
#
# TASK [IPv6 filter to filter Ipv6 Address] ****************************************************************************
# ok: [localhost] => {
# "msg": [
# "::ffff:192.168.32.0/120",
# "::ffff:192.24.2.1/128",
# "fe80::100/10"
# ]
# }
#
# TASK [convert IPv6 addresses into IPv4 addresses.] *******************************************************************
# ok: [localhost] => {
# "msg": [
# "192.168.32.0/24",
# "192.24.2.1/32"
# ]
# }
#
# TASK [filter only IPv6 addresses] *******************************************************************
# ok: [localhost] => {
# "msg": [
# "::ffff:192.168.32.0",
# "::ffff:192.24.2.1",
# "fe80::100"
# ]
# }
#
Return Values
-------------
Common return values are documented `here `_, the following are the fields unique to this filter:
.. raw:: html
Key |
Returned |
Description |
data
raw
|
|
Returns values valid for a particular query.
|
Status
------
Authors
~~~~~~~
- Ashwini Mhatre (@amhatre)
.. hint::
Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up.