# ec2\_group task creates security group but not rules

**URL:** <https://forum.ansible.com/t/ec2-group-task-creates-security-group-but-not-rules/16548>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [October 18, 2014, 4:12pm UTC](https://forum.ansible.com/t/ec2-group-task-creates-security-group-but-not-rules/16548 "2014-10-18T16:12:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dan\_Farrell](https://avatars.discourse-cdn.com/v4/letter/d/f08c70/32.png) [@Dan\_Farrell](https://forum.ansible.com/u/Dan_Farrell)\
**Post date:** [October 18, 2014, 4:12pm UTC](https://forum.ansible.com/t/ec2-group-task-creates-security-group-but-not-rules/16548/1 "2014-10-18T16:12:02Z")

</div>

Hi All, I’m just getting started trying to use ansible for provisioning and orchestration of cloud resources in AWS, so I’ll apologize in advance for this noob question.

I’ve used ec2\_group successfully before, but I can’t figure out why this task isn’t working. I can see it run the playlist is run, but the group is devoid of any egress or ingress rules. Can anybody spot what I’m doing wrong?

> TASK: [Create Jenkins Security Group] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
> skipping: [54.69.241.118]  
> skipping: [54.193.116.57]  
> changed: [54.164.169.157 → 127.0.0.1]
> 
> TASK: [debug var=jenkins\_sg] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
> ok: [54.193.116.57] =\> {  
> “jenkins\_sg”: {  
> “changed”: false,  
> “skipped”: true  
> }  
> }  
> ok: [54.164.169.157] =\> {  
> “jenkins\_sg”: {  
> “changed”: true,  
> “group\_id”: “sg-23494f46”,  
> “invocation”: {  
> “module\_args”: “”,  
> “module\_name”: “ec2\_group”  
> }  
> }  
> }  
> ok: [54.69.241.118] =\> {  
> “jenkins\_sg”: {  
> “changed”: false,  
> “skipped”: true  
> }  
> }

Here’s how I have the task defined:

- name: Create Jenkins Security Group  
local\_action:  
module: ec2\_group  
name: Jenkins SG  
description: Jenkins Security Group  
region: “{{preferred\_region}}”  
vpc\_id: “{{vpc}}”  
rules:
- proto: tcp  
from\_port: 22  
to\_port: 22  
cidr: 0.0.0.0/0
- proto: tcp  
from\_port: 8080  
to\_port: 8080  
cidr: 0.0.0.0/0  
rules\_egress:
- proto: all  
from\_port: 0  
to\_port: 65535  
cidr: 0.0.0.0/0  
when: ec2\_region == preferred\_region

And evidence that it has no rules set::

> $ aws --profile=farrellit ec2 describe-security-groups --group-id sg-23494f46
> 
> {
> 
> “SecurityGroups”: [
> 
> {
> 
> “IpPermissionsEgress”: ,
> 
> “Description”: “Jenkins Security Group”,
> 
> “IpPermissions”: ,
> 
> “GroupName”: “Jenkins SG”,
> 
> “VpcId”: “vpc-f12baf94”,
> 
> “OwnerId”: “122377349983”,
> 
> “GroupId”: “sg-23494f46”
> 
> }
> 
> ]
> 
> }

Thanks very much for your time.
