further progress on infrastructure buildout
[awsible] / roles / aws-vpc-infrastructure / tasks / main.yml
1 ---
2 - assert:
3 that:
4 - vpc_region != ''
5 - vpc_subnets_pub != ''
6 - vpc_subnets_priv != ''
7 tags: ['check_vars']
8
9 - name: IGW
10 ec2_vpc_igw:
11 state: present
12 vpc_id: "{{ vpc.vpc.id }}"
13 region: "{{ vpc_region }}"
14 register: igw
15
16 - name: Name IGW
17 ec2_tag:
18 state: present
19 resource: "{{ igw.gateway_id }}"
20 region: "{{ vpc_region }}"
21 tags:
22 Name: "igw-{{ vpc_region }}"
23
24 - name: Subnets
25 with_items: "{{ vpc_subnets_pub + vpc_subnets_priv }}"
26 ec2_vpc_subnet:
27 state: present
28 vpc_id: "{{ vpc.vpc.id }}"
29 region: "{{ vpc_region }}"
30 cidr: "{{ item.cidr }}"
31 az: "{{ item.az }}"
32 tags: "{{ item.resource_tags }}"
33
34 - name: Access/NAT EIP
35 ec2_eip:
36 in_vpc: yes
37 region: "{{ vpc_region }}"
38 reuse_existing_ip_allowed: yes
39 register: access_eip
40
41 - name: Private route table
42 ec2_vpc_route_table:
43 state: present
44 vpc_id: "{{ vpc.vpc.id }}"
45 region: "{{ vpc_region }}"
46 tags:
47 Name: "Private-Routes-vpc-{{ vpc_region }}"
48 zone: priv
49 managed: 'yes'
50 subnets: "{{ vpc_subnets_priv|map(attribute='cidr')|list }}"
51 register: private_rt
52
53 - name: Public route table
54 ec2_vpc_route_table:
55 state: present
56 vpc_id: "{{ vpc.vpc.id }}"
57 region: "{{ vpc_region }}"
58 tags:
59 Name: "Public-Routes-vpc-{{ vpc_region }}"
60 zone: pub
61 managed: 'no'
62 subnets: "{{ vpc_subnets_pub|map(attribute='cidr')|list }}"
63 routes:
64 - dest: 0.0.0.0/0
65 gateway_id: "{{ igw.gateway_id }}"
66 register: public_rt
67
68 - name: not implemented yet
69 debug:
70 msg: |
71 Change pub-subnets to auto-assign external IPs