# ansible\_ipaddresses - select specific IP in template

**URL:** <https://forum.ansible.com/t/ansible-ipaddresses-select-specific-ip-in-template/28003>\
**Category:** Ansible Project\
**Created:** [July 10, 2018, 12:48pm UTC](https://forum.ansible.com/t/ansible-ipaddresses-select-specific-ip-in-template/28003 "2018-07-10T12:48:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Carsten\_Lenz](https://avatars.discourse-cdn.com/v4/letter/c/76d3ee/32.png) [@Carsten\_Lenz](https://forum.ansible.com/u/Carsten_Lenz)\
**Post date:** [July 10, 2018, 12:48pm UTC](https://forum.ansible.com/t/ansible-ipaddresses-select-specific-ip-in-template/28003/1 "2018-07-10T12:48:25Z")

</div>

Hi all,  
all my target hosts have 2 or more IP addresses configured:

`

# ansible host -m setup

[…]  
“ansible\_ip\_addresses”: [  
“192.1.2.3”,  
“172.1.2.3”  
],  
[…]  
`

Now I’m lost on how to use/select a specific IP Address from ansible\_ip\_addresses in a jinja template. I’m not really aware of filters/lookups yet, so a friendly hint would be great!

Thanks in advance  
Carsten

---

<div class="post-metadata">

**Author:** ![liubo](https://avatars.discourse-cdn.com/v4/letter/l/e274bd/32.png) [@liubo](https://forum.ansible.com/u/liubo)\
**Post date:** [July 10, 2018, 1:04pm UTC](https://forum.ansible.com/t/ansible-ipaddresses-select-specific-ip-in-template/28003/2 "2018-07-10T13:04:28Z")

</div>

use “ip\_addr” filter

---

<div class="post-metadata">

**Author:** ![Pshem\_Kowalczyk](https://avatars.discourse-cdn.com/v4/letter/p/e480ec/32.png) [@Pshem\_Kowalczyk](https://forum.ansible.com/u/Pshem_Kowalczyk)\
**Post date:** [July 11, 2018, 12:32am UTC](https://forum.ansible.com/t/ansible-ipaddresses-select-specific-ip-in-template/28003/3 "2018-07-11T00:32:29Z")

</div>

ansible\_ip\_addresses[0] gives you the first one, ansible\_ip\_addresses[1] the second one.

kind regards  
Pshem

---

<div class="post-metadata">

**Author:** ![Carsten\_Lenz](https://avatars.discourse-cdn.com/v4/letter/c/76d3ee/32.png) [@Carsten\_Lenz](https://forum.ansible.com/u/Carsten_Lenz)\
**Post date:** [July 11, 2018, 6:57am UTC](https://forum.ansible.com/t/ansible-ipaddresses-select-specific-ip-in-template/28003/4 "2018-07-11T06:57:22Z")

</div>

Ok, got it. Thanks for the hint 🙂
