# dynamic inventory - hostname or ip address

**URL:** <https://forum.ansible.com/t/dynamic-inventory-hostname-or-ip-address/21309>\
**Category:** Ansible Project\
**Created:** [April 29, 2016, 4:47am UTC](https://forum.ansible.com/t/dynamic-inventory-hostname-or-ip-address/21309 "2016-04-29T04:47:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bill\_WANG](https://avatars.discourse-cdn.com/v4/letter/b/fbc32d/32.png) [@Bill\_WANG](https://forum.ansible.com/u/Bill_WANG)\
**Post date:** [April 29, 2016, 4:47am UTC](https://forum.ansible.com/t/dynamic-inventory-hostname-or-ip-address/21309/1 "2016-04-29T04:47:24Z")

</div>

Hi all,

I got dynamic inventory for ec2 instances via ansible. But the host in export are all IP addresses.

In ec2.ini

`vpc_destination_variable = private_ip_address`

Sample of dynamic inventory output:

`  
“tag\_Name\_abc01\_example\_com”: [  
“10\_1\_1\_15”  
],

`

So when run playbook, I have limit with it IP address, such as 10\_1\_1\_15

What can I do do to use its tag Name as host in inventory?

---

<div class="post-metadata">

**Author:** ![Bill\_WANG](https://avatars.discourse-cdn.com/v4/letter/b/fbc32d/32.png) [@Bill\_WANG](https://forum.ansible.com/u/Bill_WANG)\
**Post date:** [April 29, 2016, 6:27am UTC](https://forum.ansible.com/t/dynamic-inventory-hostname-or-ip-address/21309/2 "2016-04-29T06:27:00Z")

</div>

In ansible cache, the index is built and archive with private ip address.

“10\_1\_1\_15”: [  
“us-east-2”,  
“i-6652342vs”  
],

---

<div class="post-metadata">

**Author:** ![alexey.vazhnov](https://avatars.discourse-cdn.com/v4/letter/a/b487fb/32.png) [@alexey.vazhnov](https://forum.ansible.com/u/alexey.vazhnov)\
**Post date:** [May 4, 2016, 12:34pm UTC](https://forum.ansible.com/t/dynamic-inventory-hostname-or-ip-address/21309/3 "2016-05-04T12:34:36Z")

</div>

You can use in ec2.ini:  
`tag_destination_variable = Name`
