ansible/ansible — pull request #9630 by isegal (2014-11-26 01:27:50+00:00)
Title: EC2 Inventory Enhancement - Adds ability to address dynamic servers by local DNS or /etc/hosts.

If you run a local DNS server and/or have your EC2 hosts stored in /etc/hosts using friendlier names than the default amazon FQDN, it is convenient to be able to address them. This also allows for nice tricks such as defining groups and variables in a static inventory/hosts file and merging them with the dynamic inventory such that all the variables become available.

Example: assuming that a host web0 is defined in /etc/hosts,
Default behavior:
```
ansible tag_Name_web0 -m ping
ec2-xx-xx-xx-xx.us-west-1.compute.amazonaws.com | success >> {
"changed": false,
"ping": "pong"
}
```

New behavior when enabled via ec2.ini: use_local_dns = True
```
ansible tag_Name_web0 -m ping
web0 | success >> {
"changed": false,
"ping": "pong"
}
```

As a bonus - it allows merging with groups defined in inventory/hosts.
For example:

```
[my_group]
web0

[my_group:vars]
server_type=development
```

In the above example assuming that web0 exists in /etc/hosts, one can address it via tag_Name or via web0, and the server_type variable will properly be pulled. This helps avoid accidents in certain configurations when one invokes a playbook via tag and another via a hostname and causes differences in configured variables.