# tag\_Name issue with ec2.py

**URL:** <https://forum.ansible.com/t/tag-name-issue-with-ec2-py/16726>\
**Category:** Ansible Project\
**Created:** [November 9, 2014, 1:59am UTC](https://forum.ansible.com/t/tag-name-issue-with-ec2-py/16726 "2014-11-09T01:59:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jimmy](https://avatars.discourse-cdn.com/v4/letter/j/ee59a6/32.png) [@jimmy](https://forum.ansible.com/u/jimmy)\
**Post date:** [November 9, 2014, 1:59am UTC](https://forum.ansible.com/t/tag-name-issue-with-ec2-py/16726/1 "2014-11-09T01:59:41Z")

</div>

Hi all. I am running into an issue and I am having trouble figuring out the problem.

I am trying to set up Ansible with the ec2.py script replacing /etc/ansible/hosts with ec2.py and I am attempting to list my instances with tag\_Name.

I am running Ansible inside an Amazon VPC so I have the following settings in ec2.ini

destination\_variable = private\_dns\_name  
vpc\_destination\_variable = private\_ip\_address

When I run ec2.py --list it works:

: ./ec2.py --list  
{  
“\_meta”: {  
“hostvars”: {  
“10.30.15.0”: {  
“ec2\_\_in\_monitoring\_element”: false,  
“ec2\_ami\_launch\_index”: “0”,

If I change vpc\_destination\_variable to other things like id or image\_id it works. But if I set it to tag\_Name I get the following error:

AttributeError: ‘Instance’ object has no attribute ‘tag\_Name’

I see tag\_Name as an attribute when I do ec2.py --host HOST

What am I missing here? I am using Ansible 1.7.2

Thanks!

---

<div class="post-metadata">

**Author:** ![Michael\_Peters](https://avatars.discourse-cdn.com/v4/letter/m/c2a13f/32.png) [@Michael\_Peters](https://forum.ansible.com/u/Michael_Peters)\
**Post date:** [November 10, 2014, 3:25pm UTC](https://forum.ansible.com/t/tag-name-issue-with-ec2-py/16726/2 "2014-11-10T15:25:52Z")

</div>

This is because tags are not properties on the instance objects. I do  
agree that it's weird that you can only pick properties of the  
underlying python object for the destination variable.  
The list of those properties is available here:  
[http://docs.pythonboto.org/en/latest/ref/ec2.html#module-boto.ec2.instance](http://docs.pythonboto.org/en/latest/ref/ec2.html#module-boto.ec2.instance)

I think it could be improved if instance it waited until all the data  
was gathered and then allowed you to pick anything that was a property  
in the json hash instead.

---

<div class="post-metadata">

**Author:** ![jimmy](https://avatars.discourse-cdn.com/v4/letter/j/ee59a6/32.png) [@jimmy](https://forum.ansible.com/u/jimmy)\
**Post date:** [November 10, 2014, 5:14pm UTC](https://forum.ansible.com/t/tag-name-issue-with-ec2-py/16726/3 "2014-11-10T17:14:33Z")

</div>

Thanks for the reply. I wasn’t able to update this earlier as the post was being moderated. I was trying to figure out how to group my instances like you would with the standard /etc/ansible/hosts but after RTFM’ing further I discovered I could group them by adding a tag named class and calling those in my playbooks with tag\_class\_groupname. I started another post with a similar question about how to display tag\_Name during the playbook runs but I’ll wait for that post to be approved and update that one as well.

Now I would like to figure out how to

---

<div class="post-metadata">

**Author:** ![Chris\_Church1](https://avatars.discourse-cdn.com/v4/letter/c/ac8455/32.png) [@Chris\_Church1](https://forum.ansible.com/u/Chris_Church1)\
**Post date:** [November 13, 2014, 1:14pm UTC](https://forum.ansible.com/t/tag-name-issue-with-ec2-py/16726/4 "2014-11-13T13:14:53Z")

</div>

There is an open PR for using tags as names: [https://github.com/ansible/ansible/pull/7601](https://github.com/ansible/ansible/pull/7601)

Until this one is merged, you could try applying those changes to your copy of ec2.py.

---

<div class="post-metadata">

**Author:** ![jimmy](https://avatars.discourse-cdn.com/v4/letter/j/ee59a6/32.png) [@jimmy](https://forum.ansible.com/u/jimmy)\
**Post date:** [November 13, 2014, 1:30pm UTC](https://forum.ansible.com/t/tag-name-issue-with-ec2-py/16726/5 "2014-11-13T13:30:26Z")

</div>

Hi Chris,

Thanks! I’ll give this a try.

-Jimmy
