If you are creating an unique security group for an RDS with ansible in AWS (Elastic Cloud 2). You may have to identify the group_id.
One possible way is to capture the id right after group creation. The group_id will be captured even if there is no new group created. The capture is accomplished by adding register: my_result_var to the end of the action. Of course you can put whatever name you need instead of my_result_var.
For example:
- name: Create RDS security group
ec2_group:
description: Allow PostgreSQL
vpc_id: "{{ my_vpc_id }}"
...
- proto: tcp
to port: 5432
cidr_ip:
state: present
register: rds_sg_result
- name: Create RDS instance
rds:
command: create
...
subnet: "{{ my_subnet }}"
vpc_security_groups: "{{ rds_sg_result.group_id }}"