Hi All

I'm very new to Ansible and loving it. Not sure if Im doing this right but 
having trouble getting the vpc_id from ec2_vpc_subnet_facts

1. My code runs the module 

- name: Get the VPC ID
      ec2_vpc_subnet_facts:
        region: "{{ aws_region }}"
        filters:
          subnet-id: "{{ aws_subnet_id }}"
      register: subnet_facts

2.  Get debug information to make sure what data I have in the variable

 - debug: "var=subnet_facts.subnets"

Output 

TASK [debug] 
*******************************************************************
ok: [localhost] => {
    "subnet_facts.subnets": [
        {
            "availability_zone": "ap-southeast-2a",
            "available_ip_address_count": 251,
            "cidr_block": "10.0.1.0/24",
            "default_for_az": "false",
            "id": "subnet-534f2736",
            "map_public_ip_on_launch": "false",
            "state": "available",
            "tags": {
                "Name": "Public A"
            },
            "vpc_id": "vpc-776ce112"
        }
    ]

3. Set the fact. 

 - set_fact: aws_vpc_id={{ subnet_facts.subnets }}

4. Tried to have VPC_ID set in the ec2_group

- name: Create Security group for Sinatra Servers
      ec2_group:
        name: "{{ aws_security_group }}"
        description: Security Group for Sinatra Web Servers
        state: present
        vpc_id: "{ {aws_vpc_id.vpc_id }}"
        rules:
           - proto: tcp
             from_port: 80
             to_port: 80
             cidr_ip: 0.0.0.0/0
           - proto: tcp
             from_port: 22
             to_port: 22
             cidr_ip: 10.0.0.0/8


5. Get this error

TASK [Create Security group for Sinatra Servers] 
*******************************
fatal: [localhost]: FAILED! => {"failed": true, "msg": "ERROR! 'unicode 
object' has no attribute 'vpc_id'"}

Tried a few different things but Im missing something. Im sure its 
something silly

Regards
M

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/39c0ddef-032f-41eb-9a53-ff4cfd3c9af6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to