-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.yaml
53 lines (44 loc) · 1.44 KB
/
deploy.yaml
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
---
- name: Deploy stack
hosts: localhost
connection: local
gather_facts: false
vars:
region: ap-southeast-2
ami_id: /aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-gp2
network: 10
stack_name: Nginx
tasks:
- name: VPC
cloudformation:
stack_name: "{{ stack_name }}-VPC"
state: present
region: "{{ region }}"
template: cloudformation/vpc.yaml
template_parameters:
VPCCidr: "{{ network }}"
- name: get facts
cloudformation_facts:
stack_name: "{{ stack_name }}-VPC"
region: "{{ region }}"
register: vpc
- name: set facts
set_fact:
subnet_a: "{{ vpc.ansible_facts.cloudformation[stack_name + '-VPC'].stack_outputs['PublicSubnetA'] }}"
subnet_b: "{{ vpc.ansible_facts.cloudformation[stack_name + '-VPC'].stack_outputs['PublicSubnetB'] }}"
subnet_c: "{{ vpc.ansible_facts.cloudformation[stack_name + '-VPC'].stack_outputs['PublicSubnetC'] }}"
- name: SSM
cloudformation:
stack_name: "{{ stack_name }}-SSM"
state: present
region: "{{ region }}"
template: cloudformation/ssm.yaml
- name: Webserver
cloudformation:
stack_name: "{{ stack_name }}-Webserver"
state: present
region: "{{ region }}"
template: cloudformation/webserver.yaml
template_parameters:
AMIId: "{{ ami_id }}"
Subnet: "{{ subnet_a }}"