-
Notifications
You must be signed in to change notification settings - Fork 19
/
provision_resources.yml
167 lines (159 loc) · 5.53 KB
/
provision_resources.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
---
- name: Provision AWS Resources
hosts: localhost
gather_facts: no
vars_files:
- ./vars/default-vars.yml
- ./credentials/snow_creds.yml
tasks:
- name: Provision Resources on GCP
block:
- name: Provision Resources on GCP
ansible.builtin.include_role:
name: gcp-deploy
tasks_from: provision-resources
when: cloud_provider == "gcp"
- name: Provision Resources on AWS
block:
- name: Provision Resources on AWS
ansible.builtin.include_role:
name: aws-deploy
tasks_from: provision-resources
when: cloud_provider == "aws"
# - name: Deploy AWS Resources
# block:
# # VPC or Virtual Private Cloud. The instance will be tied to a subnet that belongs to this particular VPC
# - name: "Create AWS VPC {{ ec2_prefix }}-vpc"
# ec2_vpc_net:
# region: "{{ ec2_region }}"
# name: "{{ ec2_prefix }}-vpc"
# cidr_block: "{{ ec2_vpc_cidr }}"
# tags:
# provisioner: mford
# application: "{{ application }}"
# demo: appdeployment
# register: create_vpc
#
# # If a secruity group is not created, instances will be tied to the Default secruity grouop that allows all traffic (non-secure)
# - name: "Create EC2 Security Group {{ec2_prefix }}-sg"
# ec2_group:
# region: "{{ ec2_region }}"
# name: "{{ ec2_prefix }}-sg"
# description: "Application VPC for {{ ec2_prefix }}"
# vpc_id: "{{create_vpc.vpc.id}}"
# tags:
# provisioner: mford
# Name: "{{ ec2_prefix }}-sg"
# application: "{{ application }}"
# demo: appdeployment
# rules:
# - proto: tcp
# ports:
# - 22
# cidr_ip: 0.0.0.0/0
# - proto: tcp
# ports:
# - 80
# cidr_ip: 0.0.0.0/0
# - proto: tcp
# ports:
# - 443
# cidr_ip: 0.0.0.0/0
# - proto: tcp
# ports:
# - 3306 # for mysql
# cidr_ip: 0.0.0.0/0
# - proto: tcp
# ports:
# - 8200 # Hashicorp vault
# cidr_ip: 0.0.0.0/0
#
# # This task is subdiving up the 192.168.0.0/24 and getting a smaller chunk, a /28
# - name: "Create Subnet for {{ ec2_prefix }}-vpc"
# ec2_vpc_subnet:
# region: "{{ ec2_region }}"
# vpc_id: "{{ create_vpc.vpc.id }}"
# map_public: yes
# cidr: "{{ ec2_vpc_subnet }}"
# tags:
# provisioner: mford
# application: "{{ application }}"
# demo: appdeployment
# register: create_subnet
#
# - name: Set ec2_subnet_id fact
# set_fact:
# ec2_vpc_subnet_id: "{{ create_subnet.subnet.id }}"
#
# # Create Internet Gateway and attach it to VPC. This allows instances on this VPC to reach the Internet
# - name: "Create VPC Internet Gateway for {{ ec2_prefix }}-vpc"
# ec2_vpc_igw:
# region: "{{ ec2_region }}"
# vpc_id: "{{ create_vpc.vpc.id }}"
# tags:
# provisioner: mford
# application: "{{ application }}"
# demo: appdeployment
# register: igw
#
# # This task adds a route to the internet from the subnet through the IGW
# - name: Create a Default Route for the Subnet
# ec2_vpc_route_table:
# region: "{{ ec2_region }}"
# vpc_id: "{{ create_vpc.vpc.id }}"
# subnets:
# - "{{ create_subnet.subnet.id }}"
# routes:
# - dest: 0.0.0.0/0
# gateway_id: "{{ igw.gateway_id }}"
# tags:
# provisioner: mford
# application: "{{ application }}"
# demo: appdeployment
#
# when: cloud_provider == "aws"
#
# - name: Deploy GCP Resources
# block:
# # VPC or Virtual Private Cloud. The instance will be tied to a subnet that belongs to this particular VPC
# - name: "Create GCP VPC {{ gcp_prefix }}-vpc"
# gcp_compute_network:
# name: "{{ gcp_prefix }}-vpc"
# auto_create_subnetworks: 'false'
# state: present
# register: gcp_vpc
#
# # - debug:
# # var: gcp_vpc
#
#
# - name: "Create GCP Firewall for {{ gcp_prefix }}-vpc"
# gcp_compute_firewall:
# name: "{{ gcp_prefix }}-firewall"
# network: "{{ gcp_vpc }}"
# allowed:
# - ip_protocol: icmp
# - ip_protocol: tcp
# ports:
# - '22'
# - '80'
# - '443'
# - '8200'
# - '3306'
# target_tags:
# - appdeployment
# - "{{ application }}"
# state: present
# register: gcp_firewall
#
#
# - name: "Create GCP Subnet for {{ gcp_prefix }}-vpc"
# gcp_compute_subnetwork:
# name: "{{ gcp_prefix }}-subnet"
# region: "{{ gcp_region }}"
# network: "{{ gcp_vpc }}"
# ip_cidr_range: "{{ gcp_vpc_subnet }}"
# state: present
# register: gcp_subnet
#
# when: cloud_provider == "gcp"