Skip to content

Latest commit

 

History

History
161 lines (126 loc) · 5.2 KB

ansible.utils.network_in_network_filter.rst

File metadata and controls

161 lines (126 loc) · 5.2 KB

ansible.utils.network_in_network

This filter returns whether an address or a network passed as argument is in a network.

Version added: 2.5.0

  • This filter returns whether an address or a network passed as argument is in a network.
Parameter Choices/Defaults Configuration Comments
test
string
The address or network to validate if it is within the range of 'value'.
value
string / required
The network address or range to test against.

#### examples
- name: Check ip address 1 is part of another network
  debug:
    msg: "{{ '192.168.0.0/24' | ansible.utils.network_in_network( '192.168.0.1' ) }}"

- name: Check ip address 2 is part of another network
  debug:
    msg: "{{ '192.168.0.0/24' | ansible.utils.network_in_network( '10.0.0.1' ) }}"

- name: Check in a network is part of another network.
  debug:
    msg: "{{ '192.168.0.0/16' | ansible.utils.network_in_network( '192.168.0.0/24' ) }}"

# TASK [Check ip address 1 is part of another network] ********************************************************
# task path: /Users/amhatre/ansible-collections/playbooks/test_network_in_network.yaml:7
# Loading collection ansible.utils from /Users/amhatre/ansible-collections/collections/ansible_collections/ansible/utils
# ok: [localhost] => {
#     "msg": true
# }
#
# TASK [Check ip address 2 is part of another network] ********************************************************
# task path: /Users/amhatre/ansible-collections/playbooks/test_network_in_network.yaml:11
# Loading collection ansible.utils from /Users/amhatre/ansible-collections/collections/ansible_collections/ansible/utils
# ok: [localhost] => {
#     "msg": false
# }
#
# TASK [Check in a network is part of another network.] *******************************************************
# task path: /Users/amhatre/ansible-collections/playbooks/test_network_in_network.yaml:15
# Loading collection ansible.utils from /Users/amhatre/ansible-collections/collections/ansible_collections/ansible/utils
# ok: [localhost] => {
#     "msg": true
# }

Common return values are documented here, the following are the fields unique to this filter:

Key Returned Description
data
boolean
Returns whether an address or a network passed as argument is in a network.



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.