create_routes.yml - ansible-roles - A collection of ansible roles I have created over the years.
(HTM) git clone git://jay.scot/ansible-roles
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
create_routes.yml (1146B)
---
1 ---
2 - name: lists
3 set_fact:
4 public_subnets: []
5 private_subnets: []
6
7 - name: public subnets
8 set_fact:
9 public_subnets: "{{ public_subnets + [ item.name ] }}"
10 with_items: "{{ vpc.subnets }}"
11 when: 'item.gateway is defined and item.gateway == "igw"'
12
13 - name: create public route table
14 ec2_vpc_route_table:
15 region: "{{ aws_region }}"
16 routes:
17 - dest: 0.0.0.0/0
18 gateway_id: igw
19 state: present
20 subnets: "{{ public_subnets }}"
21 tags:
22 Name: "{{ vpc_name }}_public"
23 vpc_id: "{{ my_vpc.vpc.id }}"
24
25 - name: private subnets with outbound access
26 set_fact:
27 private_subnets: "{{ private_subnets + [ item.name ] }}"
28 with_items: "{{ vpc.subnets }}"
29 when: 'vpc.nat_gateway_subnet_name is defined and item.gateway is defined and item.gateway == "nat"'
30
31 - name: create private routes table with NAT gateway
32 ec2_vpc_route_table:
33 region: "{{ aws_region }}"
34 routes:
35 - dest: 0.0.0.0/0
36 gateway_id: "{{ nat_gateway.nat_gateway_id }}"
37 state: present
38 subnets: "{{ private_subnets }}"
39 tags:
40 Name: "{{ vpc_name }}_private_nat"
41 vpc_id: "{{ my_vpc.vpc.id }}"