# Error when running ec2\_tag action

**URL:** <https://forum.ansible.com/t/error-when-running-ec2-tag-action/15535>\
**Category:** Ansible Project\
**Created:** [June 24, 2014, 4:51pm UTC](https://forum.ansible.com/t/error-when-running-ec2-tag-action/15535 "2014-06-24T16:51:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![douglaslopespereira](https://avatars.discourse-cdn.com/v4/letter/d/a87d85/32.png) [@douglaslopespereira](https://forum.ansible.com/u/douglaslopespereira)\
**Post date:** [June 24, 2014, 4:51pm UTC](https://forum.ansible.com/t/error-when-running-ec2-tag-action/15535/1 "2014-06-24T16:51:32Z")

</div>

I’ve being trying to get the tag “Name” I’ve created for my ec2 instance using the ec2\_tag module with this task file:  
$cat getTagTask.yml

- name: Testing  
action: ec2\_facts  
tags: [metric-alarms]

- name: list resource tags  
local\_action: ec2\_tag resource=ansible\_ec2\_instance-id region=us-east-1 state=list  
tags: [metric-alarms]

I’m running this task file as part of a playbook. Something like:  
$ cat myEnv.yml

#!./ansi-playbook

- include: playbooks/config/component.yml env\_tag=tag\_environment\_perf

The command I’m using to run this specific ansible tag is:  
./myEnv.yml -l tag\_Name\_myInstanceName-0 -t metric-alarms -vvvvv

Which means run tag ‘metric-alarms’ for all instances that have the tag Name equals myInstanceName-0  
Unfortunately I get this error:

failed: [[ec2-11-222-333-444.compute-1.amazonaws.com](http://ec2-11-222-333-444.compute-1.amazonaws.com)] =\> {“failed”: true, “parsed”: false}  
invalid output was: [sudo via ansible, key=yuojjsthkixxxxircogegeobqhnzhqmp] password:

FATAL: all hosts have already failed – aborting

If I change local\_action to action, I then get this other error:

failed: [[ec2-11-222-333-444.compute-1.amazonaws.com](http://ec2-11-222-333-444.compute-1.amazonaws.com)] =\> {“failed”: true}  
msg: No handler was ready to authenticate. 1 handlers were checked. [‘QuerySignatureV2AuthHandler’] Check your credentials

FATAL: all hosts have already failed – aborting

Can someone help me to fix it?

---

<div class="post-metadata">

**Author:** ![James\_Cammarata](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@James\_Cammarata](https://forum.ansible.com/u/James_Cammarata)\
**Post date:** [June 25, 2014, 5:11pm UTC](https://forum.ansible.com/t/error-when-running-ec2-tag-action/15535/2 "2014-06-25T17:11:28Z")

</div>

Are you using the ec2.py inventory script to retrieve the inventory? If so, the ec2 tag you’ve specified would be a group name, and the “-” would be turned into an underscore character (all dashes are).

Also, the last error indicates a problem with your AWS credentials. If you’re running the command remotely, that would most likely be why.

---

<div class="post-metadata">

**Author:** ![douglaslopespereira](https://avatars.discourse-cdn.com/v4/letter/d/a87d85/32.png) [@douglaslopespereira](https://forum.ansible.com/u/douglaslopespereira)\
**Post date:** [June 25, 2014, 5:24pm UTC](https://forum.ansible.com/t/error-when-running-ec2-tag-action/15535/3 "2014-06-25T17:24:23Z")

</div>

I just realized that it was running the command as root and probably using the incorrect credentials.

I just added sudo: false and it is now working.

Thanks for your attention.
