152 lines
4.5 KiB
ReStructuredText
152 lines
4.5 KiB
ReStructuredText
.. _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
|
|
|
|
<table border=0 cellpadding=0 class="documentation-table">
|
|
<tr>
|
|
<th colspan="1">Parameter</th>
|
|
<th>Choices/<font color="blue">Defaults</font></th>
|
|
<th>Configuration</th>
|
|
<th width="100%">Comments</th>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1">
|
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
|
<b>query</b>
|
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
|
<div style="font-size: small">
|
|
<span style="color: purple">string</span>
|
|
</div>
|
|
</td>
|
|
<td>
|
|
</td>
|
|
<td>
|
|
</td>
|
|
<td>
|
|
<div>nth host</div>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1">
|
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
|
<b>value</b>
|
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
|
<div style="font-size: small">
|
|
<span style="color: purple">string</span>
|
|
/ <span style="color: red">required</span>
|
|
</div>
|
|
</td>
|
|
<td>
|
|
</td>
|
|
<td>
|
|
</td>
|
|
<td>
|
|
<div>The network address or range to test against.</div>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<br/>
|
|
|
|
|
|
|
|
|
|
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 <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this filter:
|
|
|
|
.. raw:: html
|
|
|
|
<table border=0 cellpadding=0 class="documentation-table">
|
|
<tr>
|
|
<th colspan="1">Key</th>
|
|
<th>Returned</th>
|
|
<th width="100%">Description</th>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1">
|
|
<div class="ansibleOptionAnchor" id="return-"></div>
|
|
<b>data</b>
|
|
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
|
|
<div style="font-size: small">
|
|
<span style="color: purple">string</span>
|
|
</div>
|
|
</td>
|
|
<td></td>
|
|
<td>
|
|
<div>Returns nth host from network</div>
|
|
<br/>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<br/><br/>
|
|
|
|
|
|
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.
|