next_nth_usable¶
Collection Note
This module is part of the ansible.utils collection. To install the collection, use:
Added in version2.5.0.
Synopsis¶
- This filter returns the next nth usable ip within a network described by value.
- Use next_nth_usable to find the next nth usable IP address in relation to another within a range
Parameters¶
| Parameter | Defaults / Choices | Comments |
|---|---|---|
| offset int |
index value next nth usable IP address |
|
| value str required |
subnets or individual address input for next_nth_usable plugin |
Examples¶
#### examples
# Ipv4 filter plugin with different queries.
- name: next_nth_usable returns the second usable IP address for the given IP range
debug:
msg: "{{ '192.168.122.1/24' | ansible.utils.next_nth_usable(2) }}"
- name: If there is no usable address, it returns an empty string.
debug:
msg: "{{ '192.168.122.254/24' | ansible.utils.next_nth_usable(2) }}"
# TASK [next_nth_usable returns the second usable IP address for the given IP range] **************************
# task path: /Users/amhatre/ansible-collections/playbooks/test_next_nth_usable.yaml:9
# Loading collection ansible.utils from /Users/amhatre/ansible-collections/collections/ansible_collections/ansible/utils
# ok: [localhost] => {
# "msg": "192.168.122.3"
# }
#
# TASK [If there is no usable address, it returns an empty string.] *******************************************
# task path: /Users/amhatre/ansible-collections/playbooks/test_next_nth_usable.yaml:14
# Loading collection ansible.utils from /Users/amhatre/ansible-collections/collections/ansible_collections/ansible/utils
# ok: [localhost] => {
# "msg": ""
# }
Return Values¶
| Key | Data Type | Description | Returned |
|---|---|---|---|
| data | str | Returns the next nth usable ip within a network described by value. |
Authors¶
- Ashwini Mhatre (@amhatre)