ansible/ansible — pull request #8004 by psa (2014-07-01 16:26:59+00:00)
Title: ec2_group: Flag to allow creating a group but not modifying existing rules

Originally in #7288
May be obsoleted by #7818

* ec2_group:
* add `create_group_only` flag which restricts the operations to only creating the group (rules are not touched). This is useful where you have two groups that need to include each other in their rules so it's possible to create the groups and then reference the group IDs of the already created groups when updating rules. Without this, if the group is declared twice (so that the group ID can be referenced), all the rules from the group are removed during the invocation for creating the group.

e.g.

```

- name: "Initialize group_a"
ec2_group:
name: "group_a"
description: "group_a"
vpc_id: "{{ test_vpc_id }}"
region: "us-east-1"
state: "present"
create_group_only: true
register: "group_a"

- name: "Initialize group_b"
ec2_group:
name: "group_b"
description: "group_b"
vpc_id: "{{ test_vpc_id }}"
region: "us-east-1"
state: "present"
create_group_only: true
register: "group_b"

- name: "Create rules for group_a"
ec2_group:
name: "group_a"
description: "group_a"
vpc_id: "{{ test_vpc_id }}"
region: "us-east-1"
state: "present"
rules:
- proto: tcp
group_id: "{{ group_b.group_id }}"
from_port: 80
to_port: 80
rules_egress:
- proto: tcp
group_id: "{{ group_b.group_id }}"
from_port: 443
to_port: 443

- name: "Create rules for group_b"
ec2_group:
name: "group_b"
description: "group_b"
vpc_id: "{{ test_vpc_id }}"
region: "us-east-1"
state: "present"
rules:
- proto: tcp
group_id: "{{ group_a.group_id }}"
from_port: 443
to_port: 443
rules_egress:
- proto: tcp
group_id: "{{ group_a.group_id }}"
from_port: 80
to_port: 80
```