ipv4_netmask¶
Collection Note
This module is part of the ansible.utils collection. To install the collection, use:
Added in version2.2.0.
Synopsis¶
- This plugin checks if the provided ip address is a valid IPv4 netmask or not
Parameters¶
| Parameter | Defaults / Choices | Comments |
|---|---|---|
| mask str required |
A string that represents the value against which the test is going to be performed For example: C(0.1.255.255) or C(255.255.255.0) |
Examples¶
#### Simple examples
- name: Check if 255.255.255.0 is a netmask
ansible.builtin.set_fact:
data: "{{ '255.255.255.0' is ansible.utils.ipv4_netmask }}"
# TASK [Check if 255.255.255.0 is a netmask] *******************************************
# ok: [localhost] => {
# "ansible_facts": {
# "data": true
# },
# "changed": false
# }
- name: Check if 255.255.255.128 is a netmask
ansible.builtin.set_fact:
data: "{{ '255.255.255.128' is ansible.utils.ipv4_netmask }}"
# TASK [Check if 255.255.255.128 is a netmask] *****************************************
# ok: [localhost] => {
# "ansible_facts": {
# "data": true
# },
# "changed": false
# }
- name: Check if 255.255.255.127 is not a netmask
ansible.builtin.set_fact:
data: "{{ '255.255.255.127' is not ansible.utils.ipv4_netmask }}"
# TASK [Check if 255.255.255.127 is not a netmask] *************************************
# 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)