# EC2 tag instance

**URL:** <https://forum.ansible.com/t/ec2-tag-instance/19603>\
**Category:** Ansible Project\
**Tags:** ubuntu, aws\
**Created:** [October 24, 2015, 2:29pm UTC](https://forum.ansible.com/t/ec2-tag-instance/19603 "2015-10-24T14:29:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adithya\_Khamithkar](https://avatars.discourse-cdn.com/v4/letter/a/e495f1/32.png) [@Adithya\_Khamithkar](https://forum.ansible.com/u/Adithya_Khamithkar)\
**Post date:** [October 24, 2015, 2:29pm UTC](https://forum.ansible.com/t/ec2-tag-instance/19603/1 "2015-10-24T14:29:13Z")

</div>

Hi,

I am trying to using the EC2 module to take my EC2 instances.

I have using the following code:

`

- name: Tag a resource  
local\_action:  
module: ec2\_tag  
region: “{{region}}”  
resource: “{{ansible\_ec2\_instance\_id}}”  
state: present  
aws\_access\_key: “{{aws\_access\_key}}”  
aws\_secret\_key: “{{aws\_secret\_key}}”  
tags:  
Name: “{{hostname}}”  
ansible\_groups: “{{group\_names}}”  
`

And I am getting this error:

`  
failed: [admin-tools-1a-1 → 127.0.0.1] =\> {“failed”: true, “parsed”: false}  
BECOME-SUCCESS-wychszsawibcrhvcntiegoiavgejvyti  
Traceback (most recent call last):  
File “/Users/adithyakhamithkar/.ansible/tmp/ansible-tmp-1445691490.31-80227808849885/ec2\_tag”, line 1958, in   
main()  
File “/Users/adithyakhamithkar/.ansible/tmp/ansible-tmp-1445691490.31-80227808849885/ec2\_tag”, line 114, in main  
if set(tags.items()).issubset(set(tagdict.items())):  
TypeError: unhashable type: ‘list’

FATAL: all hosts have already failed – aborting

`

Then I tried to modify the code and make it execute on the hosts by using this code:

`

- name: Update aws server name tags  
ec2\_tag: resource=“{{ansible\_ec2\_instance\_id}}” state=present region=“{{region}}” aws\_access\_key=“{{aws\_access\_key}}” aws\_secret\_key=“{{aws\_secret\_key}}”  
args:  
tags:  
Name: “{{hostname}}”  
ansible\_groups: “{{group\_names}}”

`

Any while executing this I get a similar error:

`  
failed: [admin-tools-1a-1] =\> {“failed”: true, “parsed”: false}  
BECOME-SUCCESS-cmwuofalbatwwgukuucqqhgziywpobse  
Traceback (most recent call last):  
File “/home/ubuntu/.ansible/tmp/ansible-tmp-1445689484.39-278827584206569/ec2\_tag”, line 1958, in   
main()  
File “/home/ubuntu/.ansible/tmp/ansible-tmp-1445689484.39-278827584206569/ec2\_tag”, line 114, in main  
if set(tags.items()).issubset(set(tagdict.items())):  
TypeError: unhashable type: ‘list’  
OpenSSH\_6.9p1, LibreSSL 2.1.7  
debug1: Reading configuration data /Users/adithyakhamithkar/.ssh/config  
debug1: /Users/adithyakhamithkar/.ssh/config line 1: Applying options for \*  
debug1: Reading configuration data /etc/ssh/ssh\_config  
debug1: /etc/ssh/ssh\_config line 21: Applying options for \*  
debug1: auto-mux: Trying existing master  
debug1: mux\_client\_request\_session: master session id: 2  
Shared connection to closed.

FATAL: all hosts have already failed – aborting

`

I am not able to find what is the issue. Can some one please help me.

Thanks,

---

<div class="post-metadata">

**Author:** ![Adithya\_Khamithkar](https://avatars.discourse-cdn.com/v4/letter/a/e495f1/32.png) [@Adithya\_Khamithkar](https://forum.ansible.com/u/Adithya_Khamithkar)\
**Post date:** [October 25, 2015, 4:51pm UTC](https://forum.ansible.com/t/ec2-tag-instance/19603/2 "2015-10-25T16:51:46Z")

</div>

I fixed it, I was looking at the wrong region
