Skip to content

supernet_of

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.2.0.

Synopsis

  • This plugin checks if the first network is a supernet of the second network amongst the provided network addresses

Parameters

Parameter Defaults / Choices Comments
network_a
str
required
A string that represents the first network address
For example: C(10.1.1.0/24)
network_b
str
required
A string that represents the second network address
For example: C(10.0.0.0/8)

Examples

- name: Check if 10.0.0.0/8 is a supernet of 10.1.1.0/24
  ansible.builtin.set_fact:
    data: "{{ '10.0.0.0/8' is ansible.utils.supernet_of '10.1.1.0/24' }}"

# TASK [Check if 10.0.0.0/8 is a supernet of 10.1.1.0/24] ************************
# ok: [localhost] => {
#     "ansible_facts": {
#         "data": true
#     },
#     "changed": false
# }

- name: Check if 10.0.0.0/8 is not a supernet of 192.168.1.0/24
  ansible.builtin.set_fact:
    data: "{{ '10.0.0.0/8' is not ansible.utils.supernet_of '192.168.1.0/24' }}"

# TASK [Check if 10.0.0.0/8 is not a supernet of 192.168.1.0/24] *****************
# ok: [localhost] => {
#     "ansible_facts": {
#         "data": true
#     },
#     "changed": false
# }

Return Values

Key Data Type Description Returned
data If jinja test satisfies plugin expression C(true) If jinja test does not satisfy plugin expression C(false)

Authors

  • Priyam Sahoo (@priyamsahoo)