EC2 tag instance

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,

I fixed it, I was looking at the wrong region