# Ansible - AWS - Security Group

**URL:** <https://forum.ansible.com/t/ansible-aws-security-group/26477>\
**Category:** Ansible Project\
**Tags:** ansible-project, aws\
**Created:** [January 14, 2018, 8:12am UTC](https://forum.ansible.com/t/ansible-aws-security-group/26477 "2018-01-14T08:12:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pshem\_Kowalczyk](https://avatars.discourse-cdn.com/v4/letter/p/e480ec/32.png) [@Pshem\_Kowalczyk](https://forum.ansible.com/u/Pshem_Kowalczyk)\
**Post date:** [January 14, 2018, 8:12am UTC](https://forum.ansible.com/t/ansible-aws-security-group/26477/1 "2018-01-14T08:12:20Z")

</div>

This looks like a definition of a role, not a play. If you want this to be a play you have to turn this into the ‘tasks’ section of the yaml file and specify at least hosts you want this ran against.

kind regards  
Pshem

---

<div class="post-metadata">

**Author:** ![Pshem\_Kowalczyk](https://avatars.discourse-cdn.com/v4/letter/p/e480ec/32.png) [@Pshem\_Kowalczyk](https://forum.ansible.com/u/Pshem_Kowalczyk)\
**Post date:** [January 16, 2018, 7:55pm UTC](https://forum.ansible.com/t/ansible-aws-security-group/26477/2 "2018-01-16T19:55:37Z")

</div>

It seems like you have any tasks in your playbook. Could you show the content of the playbook?

kind regards  
Pshem

---

<div class="post-metadata">

**Author:** ![Pshem\_Kowalczyk](https://avatars.discourse-cdn.com/v4/letter/p/e480ec/32.png) [@Pshem\_Kowalczyk](https://forum.ansible.com/u/Pshem_Kowalczyk)\
**Post date:** [January 17, 2018, 3:38am UTC](https://forum.ansible.com/t/ansible-aws-security-group/26477/3 "2018-01-17T03:38:10Z")

</div>

Hi,

Firstly - please regenerate access keys used for that account, as now the whole internet can access your account.

Secondly - can you run the playbook with -vv to see what’s actually going on.

kind regards  
Pshem

---

<div class="post-metadata">

**Author:** ![Reddy\_Myyb](https://avatars.discourse-cdn.com/v4/letter/r/ce73a5/32.png) [@Reddy\_Myyb](https://forum.ansible.com/u/Reddy_Myyb)\
**Post date:** [January 19, 2018, 4:39am UTC](https://forum.ansible.com/t/ansible-aws-security-group/26477/4 "2018-01-19T04:39:29Z")

</div>

Hi Pshem,  
Please find below error details with -vvv.

Using module file /usr/lib/python2.7/site-packages/ansible/modules/cloud/amazon/ec2\_group.py  
\<127.0.0.1\> ESTABLISH LOCAL CONNECTION FOR USER: devopsadmin  
\<127.0.0.1\> EXEC /bin/sh -c ‘echo ~ && sleep 0’  
\<127.0.0.1\> EXEC /bin/sh -c ‘( umask 77 && mkdir -p “`echo /home/devopsadmin/.ansible/tmp/ansible-tmp-1516336698.6-150169371339163`” && echo ansible-tmp-1516336698.6-150169371339163=“`echo /home/devopsadmin/.ansible/tmp/ansible-tmp-1516336698.6-150169371339163`” ) && sleep 0’  
\<127.0.0.1\> PUT /tmp/tmplD4zPE TO /home/devopsadmin/.ansible/tmp/ansible-tmp-1516336698.6-150169371339163/ec2\_group.py  
\<127.0.0.1\> EXEC /bin/sh -c ‘chmod u+x /home/devopsadmin/.ansible/tmp/ansible-tmp-1516336698.6-150169371339163/ /home/devopsadmin/.ansible/tmp/ansible-tmp-1516336698.6-150169371339163/ec2\_group.py && sleep 0’  
\<127.0.0.1\> EXEC /bin/sh -c ‘sudo -H -S -n -u root /bin/sh -c ‘"’“‘echo BECOME-SUCCESS-wqtfwybgoqhbfezogxxtowkktmtihqlj; /usr/bin/python /home/devopsadmin/.ansible/tmp/ansible-tmp-1516336698.6-150169371339163/ec2\_group.py; rm -rf “/home/devopsadmin/.ansible/tmp/ansible-tmp-1516336698.6-150169371339163/” \> /dev/null 2\>&1’”’"’ && sleep 0’  
The full traceback is:  
Traceback (most recent call last):  
File “/tmp/ansible\_jB7bqT/ansible\_module\_ec2\_group.py”, line 487, in   
main()  
File “/tmp/ansible\_jB7bqT/ansible\_module\_ec2\_group.py”, line 283, in main  
for curGroup in ec2.get\_all\_security\_groups():  
File “/usr/lib/python2.7/site-packages/boto/ec2/connection.py”, line 2984, in get\_all\_security\_groups  
[(‘item’, SecurityGroup)], verb=‘POST’)  
File “/usr/lib/python2.7/site-packages/boto/connection.py”, line 1186, in get\_list  
raise self.ResponseError(response.status, response.reason, body)  
boto.exception.EC2ResponseError: EC2ResponseError: 401 Unauthorized

\<?xml version="1.0" encoding="UTF-8"?\>

`AuthFailure`Credential must have exactly 5 slash-delimited elements, e.g. keyid/date/region/service/term, got ‘Dt4q191m7+gPbrnkQfEZT9QUoIWDVyq0ous/TS76/20180119/ap-southeast-2/ec2/aws4\_request,SignedHeaders=host;x-amz-date,Signature=76afdaaa0c55e555680cc35ef200f75d660d90fb98022bd412e216822af4c110’f8c83e5f-a069-41eb-956a-126440cf0730

fatal: [localhost]: FAILED! =\> {  
“changed”: false,  
“failed”: true,  
“module\_stderr”: “Traceback (most recent call last):\n File "/tmp/ansible\_jB7bqT/ansible\_module\_ec2\_group.py", line 487, in \n main()\n File "/tmp/ansible\_jB7bqT/ansible\_module\_ec2\_group.py", line 283, in main\n for curGroup in ec2.get\_all\_security\_groups():\n File "/usr/lib/python2.7/site-packages/boto/ec2/connection.py", line 2984, in get\_all\_security\_groups\n [(‘item’, SecurityGroup)], verb=‘POST’)\n File "/usr/lib/python2.7/site-packages/boto/connection.py", line 1186, in get\_list\n raise self.ResponseError(response.status, response.reason, body)\nboto.exception.EC2ResponseError: EC2ResponseError: 401 Unauthorized\n\<?xml version=\"1.0\" encoding=\"UTF-8\"?\>\n`AuthFailure`Credential must have exactly 5 slash-delimited elements, e.g. keyid/date/region/service/term, got ‘Dt4q191m7+gPbrnkQfEZT9QUoIWDVyq0ous/TS76/20180119/ap-southeast-2/ec2/aws4\_request,SignedHeaders=host;x-amz-date,Signature=76afdaaa0c55e555680cc35ef200f75d660d90fb98022bd412e216822af4c110’f8c83e5f-a069-41eb-956a-126440cf0730\n”,  
“module\_stdout”: “”,  
“msg”: “MODULE FAILURE”,  
“rc”: 0

PS: I have chnaged my security creds.

---

<div class="post-metadata">

**Author:** ![Reddy\_Myyb](https://avatars.discourse-cdn.com/v4/letter/r/ce73a5/32.png) [@Reddy\_Myyb](https://forum.ansible.com/u/Reddy_Myyb)\
**Post date:** [January 19, 2018, 6:08am UTC](https://forum.ansible.com/t/ansible-aws-security-group/26477/5 "2018-01-19T06:08:42Z")

</div>

Hi Pshem,  
Please find below the latest error details.

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ClientError: An error occurred (AuthFailure) when calling the DescribeSecurityGroups operation: Credential must have exactly 5 slash-delimited elements, e.g. keyid/date/region/service/term, got ‘Dt4q191m7+gPbrnkQfEZT9QUoIWDVyq0ous/TS76/20180119/ap-southeast-2/ec2/aws4\_request,’  
fatal: [localhost]: FAILED! =\> {“changed”: false, “error”: {“code”: “AuthFailure”, “message”: “Credential must have exactly 5 slash-delimited elements, e.g. keyid/date/region/service/term, got ‘Dt4q191m7+gPbrnkQfEZT9QUoIWDVyq0ous/TS76/20180119/ap-southeast-2/ec2/aws4\_request,’”}, “msg”: “Error in describe\_security\_groups: An error occurred (AuthFailure) when calling the DescribeSecurityGroups operation: Credential must have exactly 5 slash-delimited elements, e.g. keyid/date/region/service/term, got ‘Dt4q191m7+gPbrnkQfEZT9QUoIWDVyq0ous/TS76/20180119/ap-southeast-2/ec2/aws4\_request,’”, “response\_metadata”: {“http\_headers”: {“date”: “Fri, 19 Jan 2018 06:06:24 GMT”, “server”: “AmazonEC2”, “transfer-encoding”: “chunked”}, “http\_status\_code”: 401, “request\_id”: “096c5f20-ff34-4c4f-b5ff-7e5216ec727d”, “retry\_attempts”: 0}}

Regards,  
Reddy

---

<div class="post-metadata">

**Author:** ![Pshem\_Kowalczyk](https://avatars.discourse-cdn.com/v4/letter/p/e480ec/32.png) [@Pshem\_Kowalczyk](https://forum.ansible.com/u/Pshem_Kowalczyk)\
**Post date:** [January 21, 2018, 11:07pm UTC](https://forum.ansible.com/t/ansible-aws-security-group/26477/6 "2018-01-21T23:07:24Z")

</div>

Hi,

Looking at your debug it’s some sort of authentication issue with AWS:

boto.exception.EC2ResponseError: EC2ResponseError: 401 Unauthorized

This might mean that the keys are not correct or the user that the keys are associated with doesn’t have the permission to carry out the operation.

kind regards  
Pshem
