Noob Issue with using AWS hostnames in inventory

Hey Guys,

I am successful executing ansible against an AWS ec2 when I put the public IP in the /etc/ansible/hosts file. However, when I replace that with the ec2 hostname, ansible complains with:

ec2-xx-xxx-xxx-xx.compute-1.amazonaws.com | UNREACHABLE! => {
“changed”: false,
“msg”: “Failed to connect to the host via ssh.”,
“unreachable”: true
}

Any help would be appreciated…

To debug, run with -vvv and you’ll see the full ssh command, see if you can run that manually.

There's also some ec2.ini configuration that controls whether Ansible uses
private or public addresses or names to refer to your instances, and the
ability to have Ansible use one thing for inventory_hostname and another
for the actual SSH connection. Which combination of things you want
depends on what you're doing, e.g. Ansible running on the same private
network as your instances or not, etc.

                                      -Josh (jbs@care.com)

(apologies for the automatic corporate disclaimer that follows)

This email is intended for the person(s) to whom it is addressed and may contain information that is PRIVILEGED or CONFIDENTIAL. Any unauthorized use, distribution, copying, or disclosure by any person other than the addressee(s) is strictly prohibited. If you have received this email in error, please notify the sender immediately by return email and delete the message and any attachments from your system.

Thanks for the pointer, Josh.

However, I don’t think that is the issue, within the ini file I do have:

destination_variable = public_dns_name

Thanks for the pointer, Josh.

However, I don't think that is the issue, within the ini file I do have:

destination_variable = public_dns_name

Mm. And can you in fact SSH to your instances from your Ansible control
host by their public DNS names?

                                      -Josh (jbs@care.com)
This email is intended for the person(s) to whom it is addressed and may contain information that is PRIVILEGED or CONFIDENTIAL. Any unauthorized use, distribution, copying, or disclosure by any person other than the addressee(s) is strictly prohibited. If you have received this email in error, please notify the sender immediately by return email and delete the message and any attachments from your system.