create subnets and routes
authorLorin Hochstein <lhochstein@netflix.com>
Sat, 11 Feb 2017 20:36:58 +0000 (12:36 -0800)
committerLorin Hochstein <lhochstein@netflix.com>
Sat, 11 Feb 2017 20:36:58 +0000 (12:36 -0800)
ch12/playbooks/create-vpc.yml

index 8d05c6d..9dce009 100644 (file)
         cidr_block: 10.0.0.0/16
         tags:
           env: production
-      register: vpc
-    - debug: var=vpc
-
-
+      register: result
+    - set_fact: "vpc_id={{ result.vpc.id }}"
+    - name: add gateway
+      ec2_vpc_igw:
+        region: "{{ region }}"
+        vpc_id: "{{ vpc_id }}"
+    - name:  create web subnet
+      ec2_vpc_subnet:
+        region: "{{ region }}"
+        vpc_id: "{{ vpc_id }}"
+        cidr: 10.0.0.0/24
+        tags:
+          env: production
+          tier: web
+    - name: create db subnet
+      ec2_vpc_subnet:
+        region: "{{ region }}"
+        vpc_id: "{{ vpc_id }}"
+        cidr: 10.0.1.0/24
+        tags:
+          env: production
+          tier: db
+    - name: set routes
+      ec2_vpc_route_table:
+        region: "{{ region }}"
+        vpc_id: "{{ vpc_id }}"
+        tags:
+          purpose: permit-outbound
+        subnets:
+          - 10.0.0.0/24
+          - 10.0.1.0/24
+        routes:
+          - dest: 0.0.0.0/0
+            gateway_id: igw