ec2 Dynamic inventory and hostname

Hi,

I wanted to use the machine hostnames with ec2.py, which I was able to by customizing the script to return the Name tag for the hostname instead of the public or private dns name, however, that requires an extra step which is maintaining a ~/.ssh/config with corresponding proper dns since I’m not currently using fqdns as the hostnames (will do in the near future so this will not actually be necessary). But in the meanwhile I’d like to be able to do as in the static inventory:

foo ansible_ssh_host=192.168.1.50

Is it possible to do this with the dynamic inventory (have an alias for a machine which is the name tag i already set but connect using public dns)?

+1 this would be awesome.

There’s a pull request for this. It allows you to specify a hostname_variable in ec2.ini to a host attr or tag, so that inventory_hostname will be set to this value while still keeping ansible_ssh_host intact (i.e. still using the destination_variable setting).

https://github.com/ansible/ansible/pull/7395