ansible.utils.reduce_on_network (4.0.0) — filter

This filter reduces a list of addresses to only the addresses that match a given network.

| "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

This filter reduces a list of addresses to only the addresses that match a given network.

To check whether multiple addresses belong to a network, use the reduce_on_network filter.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.

- name: To check whether multiple addresses belong to a network, use the reduce_on_network filter.
  debug:
    msg: "{{ ['192.168.0.34', '10.3.0.3', '192.168.2.34'] | ansible.utils.reduce_on_network( '192.168.0.0/24' ) }}"

Inputs

    
value:
    description: the list of addresses to filter on.
    elements: str
    required: true
    type: list

network:
    description: The network to validate against.
    type: str

Outputs

data:
  description:
  - Returns whether an address or a network passed as argument is in a network.
  type: bool