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

9 views
Skip to first unread message

Guy Knights

unread,
Jul 8, 2020, 1:10:14 PM7/8/20
to Ansible Project
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

Dick Visser

unread,
Jul 8, 2020, 5:01:10 PM7/8/20
to ansible...@googlegroups.com
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
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/b7365801-91d6-46f3-b681-b4ff6ba29ef1n%40googlegroups.com.



--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT
Reply all
Reply to author
Forward
0 new messages