# Possible to use more than one hostname/identifier in inventory?

**URL:** <https://forum.ansible.com/t/possible-to-use-more-than-one-hostname-identifier-in-inventory/33348>\
**Category:** Ansible Project\
**Created:** [July 8, 2020, 5:10pm UTC](https://forum.ansible.com/t/possible-to-use-more-than-one-hostname-identifier-in-inventory/33348 "2020-07-08T17:10:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guy\_Knights1](https://avatars.discourse-cdn.com/v4/letter/g/82dd89/32.png) [@Guy\_Knights1](https://forum.ansible.com/u/Guy_Knights1)\
**Post date:** [July 8, 2020, 5:10pm UTC](https://forum.ansible.com/t/possible-to-use-more-than-one-hostname-identifier-in-inventory/33348/1 "2020-07-08T17:10:14Z")

</div>

We gather most of our host inventory using the aws\_ec2 inventory plugin, and from this each host’s private IP address is used as the host identifier. Is there a way we can also gather and use other unique identifiers to refer to hosts as an alternative?

Each of our hosts has an assigned EC2 “Name” tag that uniquely ids the host so it’d be handy to be able to use this in some situations, though as we’ve already been using IPs for a long time I’d prefer to just continue to keep this as the primary means of referencing hosts.

Is the above feasible or can hosts only have one ID?

Thanks,  
Guy

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [July 8, 2020, 9:00pm UTC](https://forum.ansible.com/t/possible-to-use-more-than-one-hostname-identifier-in-inventory/33348/2 "2020-07-08T21:00:37Z")

</div>

Hi

In our deployments I assign a number of tags to instances at  
instantiation time, like Customer, Environment, Name, OS, Type,  
Username, etc.  
One tag is InventoryHostname, which is actually based on the other  
tags, so it looks as Customer-Environment-Type-number:  
"uber-prod-proxy2".  
I use this tag for the inventory\_hostname. It can be configured in ec2.ini:

hostname\_variable = tag\_InventoryHostname
