ec2_vpc default gw not working?

78 views
Skip to first unread message

Pablo Escobar

unread,
Feb 24, 2015, 3:37:04 PM2/24/15
to ansible...@googlegroups.com
Hi,

I have been doing some tests to deploy a ec2 vpc with ansible but I cannot manage to configure the default gw so the machines inside the vpc have no internet access.

After doing some debugging in my playbook I just copied&paste the example from the documentation in http://docs.ansible.com/ec2_vpc_module.html to see if it works but still I don't get the default gw in the vpc

This is the example I tried from documentation which is not working for me.  (just changing availability zone and region)  I am using ansible 1.8.2 in ubuntu14.04 with python 2.7.6

any clue about how to fix this?


# Full creation example with subnets and optional availability zones.
# The absence or presence of subnets deletes or creates them respectively.
      ec2_vpc:
        state: present
        cidr_block: 172.22.0.0/16
        resource_tags: { "Environment":"Development" }
        subnets:
          - cidr: 172.22.1.0/24
            az: us-west-2c
            resource_tags: { "Environment":"Dev", "Tier" : "Web" }
          - cidr: 172.22.2.0/24
            az: us-west-2b
            resource_tags: { "Environment":"Dev", "Tier" : "App" }
          - cidr: 172.22.3.0/24
            az: us-west-2a
            resource_tags: { "Environment":"Dev", "Tier" : "DB" }
        internet_gateway: True
        route_tables:
          - subnets:
              - 172.22.2.0/24
              - 172.22.3.0/24
            routes:
              - dest: 0.0.0.0/0
                gw: igw
          - subnets:
              - 172.22.1.0/24
            routes:
              - dest: 0.0.0.0/0
                gw: igw
        region: us-west-2
      register: vpc

thanks in advance,

Pablo

Dan Vaida

unread,
Feb 26, 2015, 4:41:52 AM2/26/15
to ansible...@googlegroups.com
So you're saying that after running that the IGW is not associated with your subnet(s)?
Also, can you confirm that the routing tables have the correct subnets associations?

Pablo Escobar

unread,
Feb 28, 2015, 6:52:13 AM2/28/15
to ansible...@googlegroups.com
2015-02-26 10:41 GMT+01:00 Dan Vaida <vaid...@gmail.com>:
So you're saying that after running that the IGW is not associated with your subnet(s)?

yes. I have to manually add the IGW to the vpc in the console so the machines have internet access
 
Also, can you confirm that the routing tables have the correct subnets associations?


in the routes section I only get this;

Destination       Target      Status         Propagated 
172.1.0.0/16     local          Active        No

In the "subnets associations" section I get this:

Subnet   CIDR
You do not have any subnet associations.
The following subnets have not been associated with any route tables and are therefore using the main table routes:

Subnet  CIDR
All your subnets are associated with a route table.


 

--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/df05af4c-bdb0-4d54-9861-efdb14b237e3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dan Vaida

unread,
Feb 28, 2015, 12:11:32 PM2/28/15
to ansible...@googlegroups.com
Just had a look at all my tasks involving ec2_vpc module and all of them have
internet_gateway: yes
I believe that is your problem. In that case, the documentation example should reflect this, as per the shown parameter values in the table.
I took a look at ec2_vpc.py and there isn't anything suggesting that True/False values wouldn't work, hence you get no error.

Hope this helps,

Dan.

Pablo Escobar

unread,
Mar 4, 2015, 4:35:23 PM3/4/15
to ansible...@googlegroups.com
Hi Dan,

thanks for your help, but I run this playbook and still no IGW


---

- name: vpc deploy test
  hosts: localhost
  connection: local
  gather_facts: False

  tasks:

    # Creates
    - name: Create VPC and default subnet
      ec2_vpc:        
        state: present
        resource_tags: { "Name":"test-to-delete-2"}
        cidr_block: 172.23.0.0/16
        region: eu-west-1
        internet_gateway: yes
        subnets:
          - cidr: 172.23.3.0/24
            az: eu-west-1c
        route_tables:
          - subnets:
              - 172.23.3.0/24
            routes:
              - dest: 0.0.0.0/0
                gw: igw

Arbab Nazar

unread,
Mar 5, 2015, 12:30:46 AM3/5/15
to ansible...@googlegroups.com
Hi Pablo,

This is my working ansible task to create vpc:

- name: VPC | Creating and AWS VPC inside mentioned Region
   local_action:
     module: ec2_vpc
     region: "{{ vpc_region }}"
     state: present
     cidr_block: "{{ cidr_block }}"
     resource_tags: { "Name":"{{ vpc_name| default(test) }}_vpc" }
     subnets:
       - cidr: "{{ public_cidr }}"
         az: "{{ public_az }}"
         resource_tags: { "Name":"{{ vpc_name| default(test) }}_public_subnet" }
       - cidr: "{{ private_cidr }}"
         az: "{{ private_az }}"
         resource_tags: { "Name":"{{ vpc_name| default(test) }}_private_subnet" }
     internet_gateway: True
     route_tables:
       - subnets:
           - "{{ public_cidr }}"
         routes:
           - dest: 0.0.0.0/0
             gw: igw
   register: vpc

here is my var/main.yml

---
 vpc_name: test_vpc
 vpc_region: ap-southeast-2
 cidr_block: 172.25.0.0/16
 public_cidr: 172.25.10.0/24
 public_az: ap-southeast-2a
 private_cidr: 172.25.20.0/24
 private_az: ap-southeast-2b
 nat_private_ip: 172.25.10.10
Hope this will help you. Thanks 
Reply all
Reply to author
Forward
0 new messages