forked from redhat-cop/agnosticd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ec2_infrastructure_deployment.yml
126 lines (112 loc) · 3.51 KB
/
ec2_infrastructure_deployment.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
---
- import_playbook: ec2_pre_checks.yml
- name: Step 001.1 Deploy Infrastructure
hosts: localhost
connection: local
gather_facts: false
become: false
tags:
- step001
- step001.1
- deploy_infrastructure
tasks:
- name: Run infra-ec2-template-generate Role
import_role:
name: infra-ec2-template-generate
- name: Run infra-ec2-template-create Role
import_role:
name: infra-ec2-template-create
vars:
aws_region_loop: "{{aws_region}}"
- name: Run infra-ec2-template-create Role into FallBack region
include_role:
name: infra-ec2-template-create
vars:
aws_region_loop: "{{item}}"
with_items: "{{ fallback_regions }}"
when:
- fallback_regions is defined
- cloudformation_out is failed
- name: report Cloudformation error
fail:
msg: "FAIL {{ project_tag }} Create Cloudformation"
when: not cloudformation_out is succeeded
tags:
- provision_cf_template
- name: Step 001.2 Create Inventory and SSH config setup
hosts: localhost
connection: local
gather_facts: false
become: false
tags:
- step001
- step001.2
- create_inventory
- create_ssh_config
tasks:
# Sometimes the infra step is skipped, for example when scaling up a cluster.
# when step001.1 is skipped, aws_region_final is not defined.
- when: aws_region_final is not defined
include_tasks: ec2_detect_region_tasks.yml
- name: Run infra-ec2-create-inventory Role
import_role:
name: infra-ec2-create-inventory
- name: Run Common SSH Config Generator Role
import_role:
name: infra-common-ssh-config-generate
# include global vars again, this time for all hosts now that the inventory is built
- import_playbook: ../include_vars.yml
tags:
- create_inventory
- must
- name: Step 001.3 Configure Linux Hosts and Wait for Connection
hosts:
- all:!windows:!network
gather_facts: false
any_errors_fatal: true
ignore_errors: false
become: true
tags:
- step001
- step001.3
- wait_ssh
- set_hostname
tasks:
- name: set facts for remote access
tags:
- create_inventory
set_fact:
aws_region_final: "{{hostvars['localhost'].aws_region_final}}"
ansible_ssh_extra_args: "{{ ansible_ssh_extra_args|d() }} -F {{output_dir}}/{{ env_type }}_{{ guid }}_ssh_conf"
- name: Run infra-ec2-wait_for_linux_hosts Role
import_role:
name: infra-ec2-wait_for_linux_hosts
- name: Run infra-ec2-linux-set-hostname Role
import_role:
name: infra-ec2-linux-set-hostname
- name: Step 001.4 Configure Windows Hosts and Wait for Connection
gather_facts: false
hosts:
- windows
tags:
- step001
- step001.4
tasks:
- name: set facts for remote access
tags:
- create_inventory
set_fact:
ansible_become: false
ansible_connection: winrm
ansible_host: "{{ public_dns_name }}"
ansible_password: "{{ hostvars['localhost'].windows_password | default(hostvars['localhost'].generated_windows_password) }}"
ansible_port: 5986
ansible_user: Administrator
ansible_winrm_server_cert_validation: ignore
aws_region_final: "{{hostvars['localhost'].aws_region_final}}"
- name: Run infra-ec2-wait_for_linux_hosts Role
import_role:
name: infra-ec2-wait_for_windows_hosts
- name: Set output_dir for all windows hosts
set_fact:
output_dir: "{{ hostvars.localhost.output_dir }}"