# Ansible dynamic inventory, AWS and ec2\_dns\_name

**URL:** <https://forum.ansible.com/t/ansible-dynamic-inventory-aws-and-ec2-dns-name/23219>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [December 9, 2016, 7:34pm UTC](https://forum.ansible.com/t/ansible-dynamic-inventory-aws-and-ec2-dns-name/23219 "2016-12-09T19:34:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robert\_Haskins](https://avatars.discourse-cdn.com/v4/letter/r/d9b06d/32.png) [@Robert\_Haskins](https://forum.ansible.com/u/Robert_Haskins)\
**Post date:** [December 9, 2016, 7:34pm UTC](https://forum.ansible.com/t/ansible-dynamic-inventory-aws-and-ec2-dns-name/23219/1 "2016-12-09T19:34:04Z")

</div>

Using the ec2.py script, I am trying to select an AWS machine by ec2\_dns\_name. It always seems to not match:

e$ ansible -i ./ec2.py [ec2-34-192-103-30.compute-1.amazonaws.com](http://ec2-34-192-103-30.compute-1.amazonaws.com) -m ping  
[WARNING]: No hosts matched, nothing to do

The output from the ec2.py script regarding the DNS name is this:

“ec2\_public\_dns\_name”: “[ec2-34-192-103-30.compute-1.amazonaws.com](http://ec2-34-192-103-30.compute-1.amazonaws.com)”,

I can use the script to connect to machines by IP address, region and tag name so I know the basic infrastructure is working (SSH, AWS keys, IAM rights, etc.). I have looked in the ec2.ini file and played with the settings for destination\_variable. A setting of “public\_dns” makes the most sense, since I am accessing the machine via that way.

I have looked at these both the Ansible docs for AWS and the AWS docs for Ansible:

[http://docs.ansible.com/ansible/guide\_aws.html](http://docs.ansible.com/ansible/guide_aws.html)

[https://aws.amazon.com/blogs/apn/getting-started-with-ansible-and-dynamic-amazon-ec2-inventory-management/](https://aws.amazon.com/blogs/apn/getting-started-with-ansible-and-dynamic-amazon-ec2-inventory-management/)

Where can I look/what can I run to troubleshoot this? What am I doing wrong?

Thanks!
