Skip to content

ipcut

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 fetch 1st or last few bits of Ip address.

Parameters

Parameter Defaults / Choices Comments
amount
int
integer for arithmetic. Example -1,2,3
value
str
required
list of subnets or individual address or any other values input for ip_cut plugin

Examples

#### examples
- name: Get first 64 bits of Ipv6 address
  debug:
    msg: "{{ '1234:4321:abcd:dcba::17' | ansible.utils.ipcut(64) }}"

- name: Get last 80 bits of Ipv6 address
  debug:
    msg: "{{ '1234:4321:abcd:dcba::17' | ansible.utils.ipcut(-80) }}"
# PLAY [IPCUT filter plugin examples] ************************************************************************************************

# TASK [Get first X bits of Ipv6 address] ********************************************************************************************
# ok: [localhost] => {
#     "msg": "1234:4321:abcd:dcba"
# }

# TASK [Get last X bits of Ipv6 address] *********************************************************************************************
# ok: [localhost] => {
#     "msg": "dcba:0:0:0:17"
# }

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

Return Values

Key Data Type Description Returned
data str Returns result of portion of IP.

Authors

  • Ashwini Mhatre (@amhatre)