Hi everyone,
I put this little patch together for a customer a few months ago, and a number of people have found it useful:
https://github.com/tgerla/ansible/compare/ec2-fqdn
Basically it allows you to set the inventory hostname of an EC2 host to the contents of a tag. If the specified tag doesn’t exist for a host, it defaults to the normal EC2 hostname. For example, if your instance has a “tag:Name=foobar” and you specify hostname_tag_map=Name, that instance will come out of inventory with the inventory hostname of “foobar” and the ansible_ssh_host variable will be set to the ec2-xxx-xxx-xxx-xxx hostname.
This has been tested by a number of people, and it’s pretty simple. Only one question: I’m not totally happy with the parameter name of “hostname_tag_map” so suggestions would be appreciated.
I’ll do a pull request shortly, but I’m curious to know what people think!
-Tim