ansible / ansible.utils / 4.0.0 / test / subnet_of Test if a network is a subnet of another network | "added in version" 2.2.0 of ansible.utils" Authors: Priyam Sahoo (@priyamsahoo)ansible.utils.subnet_of (4.0.0) — test
Install with ansible-galaxy collection install ansible.utils:==4.0.0
collections: - name: ansible.utils version: 4.0.0
This plugin checks if the first network is a subnet of the second network amongst the provided network addresses
- name: Check if 10.1.1.0/24 is a subnet of 10.0.0.0/8 ansible.builtin.set_fact: data: "{{ '10.1.1.0/24' is ansible.utils.subnet_of '10.0.0.0/8' }}"
# TASK [Check if 10.1.1.0/24 is a subnet of 10.0.0.0/8] ************************** # ok: [localhost] => { # "ansible_facts": { # "data": true # }, # "changed": false # } - name: Check if 192.168.1.0/24 is not a subnet of 10.0.0.0/8 ansible.builtin.set_fact: data: "{{ '192.168.1.0/24' is not ansible.utils.subnet_of '10.0.0.0/8' }}"
network_a: description: - A string that represents the first network address - 'For example: C(10.1.1.0/24)' required: true type: str network_b: description: - A string that represents the second network address - 'For example: C(10.0.0.0/8)' required: true type: str
data: description: - If jinja test satisfies plugin expression C(true) - If jinja test does not satisfy plugin expression C(false)