.. _ansible.utils.nthhost_filter: ********************* ansible.utils.nthhost ********************* **This filter returns the nth host within a network described by value.** Version added: 2.5.0 .. contents:: :local: :depth: 1 Synopsis -------- - This filter returns the nth host within a network described by value. To return the nth ip from a network, use the filter nthhost. - Nthhost also supports a negative value. Parameters ---------- .. raw:: html
Parameter Choices/Defaults Configuration Comments
query
string
nth host
value
string / required
The network address or range to test against.

Examples -------- .. code-block:: yaml #### examples - name: To return the nth ip from a network, use the filter nthhost. debug: msg: "{{ '10.0.0.0/8' | ansible.utils.nthhost(305) }}" - name: nthhost also supports a negative value. debug: msg: "{{ '10.0.0.0/8' | ansible.utils.nthhost(-1) }}" # TASK [To return the nth ip from a network, use the filter nthhost.] ***************************************** # task path: /Users/amhatre/ansible-collections/playbooks/test_nthhost.yaml:7 # Loading collection ansible.utils from /Users/amhatre/ansible-collections/collections/ansible_collections/ansible/utils # ok: [localhost] => { # "msg": "10.0.1.49" # } # # TASK [nthhost also supports a negative value.] ************************************************************** # task path: /Users/amhatre/ansible-collections/playbooks/test_nthhost.yaml:11 # Loading collection ansible.utils from /Users/amhatre/ansible-collections/collections/ansible_collections/ansible/utils # ok: [localhost] => { # "msg": "10.255.255.255" # } Return Values ------------- Common return values are documented `here `_, the following are the fields unique to this filter: .. raw:: html
Key Returned Description
data
string
Returns nth host from network



Status ------ Authors ~~~~~~~ - Ashwini Mhatre (@amhatre) .. hint:: Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up.