network_in_usable¶
Collection Note
This module is part of the ansible.utils collection. To install the collection, use:
Added in version2.5.0.
Synopsis¶
- The network_in_usable filter returns whether an address passed as an argument is usable in a network Usable addresses are addresses that can be assigned to a host.
- The network ID and the broadcast address are not usable addresses.
Parameters¶
| Parameter | Defaults / Choices | Comments |
|---|---|---|
| test str |
The address or network is usable or not. | |
| value str required |
The network address or range to test against. |
Examples¶
#### examples
- name: Check ip address is usable in a network
debug:
msg: "{{ '192.168.0.0/24' | ansible.utils.network_in_usable( '192.168.0.1' ) }}"
- name: Check broadcast address is usable in a network
debug:
msg: "{{ '192.168.0.0/24' | ansible.utils.network_in_usable( '192.168.0.255' ) }}"
- name: Check in a network is part of another network.
debug:
msg: "{{ '192.168.0.0/16' | ansible.utils.network_in_usable( '192.168.0.255' ) }}"
# TASK [Check ip address is usable in a network] **************************************************************
# task path: /Users/amhatre/ansible-collections/playbooks/test_network_in_usable.yaml:7
# Loading collection ansible.utils from /Users/amhatre/ansible-collections/collections/ansible_collections/ansible/utils
# ok: [localhost] => {
# "msg": true
# }
#
# TASK [Check broadcast address is usable in a network] *******************************************************
# task path: /Users/amhatre/ansible-collections/playbooks/test_network_in_usable.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_usable.yaml:15
# Loading collection ansible.utils from /Users/amhatre/ansible-collections/collections/ansible_collections/ansible/utils
# ok: [localhost] => {
# "msg": true
# }
Return Values¶
| Key | Data Type | Description | Returned |
|---|---|---|---|
| data | bool | Returns whether an address or a network passed as argument is in a network. |
Authors¶
- Ashwini Mhatre (@amhatre)