ansible.utils.ipv4 (4.0.0) — filter

To filter only Ipv4 addresses Ipv4 filter is used.

| "added in version" 2.5.0 of ansible.utils"

Authors: Ashwini Mhatre (@amhatre)

Install collection

Install with ansible-galaxy collection install ansible.utils:==4.0.0


Add to requirements.yml

  collections:
    - name: ansible.utils
      version: 4.0.0

Description

Sometimes you need only IPv4 addresses. To filter only Ipv4 addresses Ipv4 filter is used.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
#### examples
# Ipv4 filter plugin with different queries.
- name: Set value as input list
  ansible.builtin.set_fact:
    value:
      - 192.24.2.1
      - host.fqdn
      - ::1
      - ''
      - 192.168.32.0/24
      - fe80::100/10
      - 42540766412265424405338506004571095040/64
      - true
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: IPv4 filter to filter Ipv4 Address
  debug:
    msg: "{{ value|ansible.utils.ipv4 }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: convert IPv4 addresses into IPv6 addresses.
  debug:
    msg: "{{ value|ansible.utils.ipv4('ipv6') }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: convert IPv4 addresses into IPv6 addresses.
  debug:
    msg: "{{ value|ansible.utils.ipv4('address') }}"

Inputs

    
query:
    default: ''
    description:
    - You can provide a single argument to each ipv4() filter.
    - Example. query type 'ipv6' to convert ipv4 into ipv6
    type: str

value:
    description:
    - list of subnets or individual address or any other values input for ipv4 plugin
    required: true
    type: raw

Outputs

data:
  description:
  - Returns values valid for a particular query.
  type: raw