-
Notifications
You must be signed in to change notification settings - Fork 2
/
provision_new_cluster.yml
216 lines (182 loc) · 6.19 KB
/
provision_new_cluster.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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
---
- hosts: utility
gather_facts: true
vars:
reprovision: no
tasks:
- name: Set up ignition fragment list
set_fact:
additional_ignition_fragments: []
- name: Clean up old install directory when reprovisioning
file:
path: "{{installer_dir}}"
state: absent
when: reprovision == "yes"
- name: Clean up old files directory when reprovisioning
file:
path: "{{files_dir}}"
state: absent
when: reprovision == "yes"
- name: Check if installation config directory exists
stat:
path: "{{installer_dir}}"
register: stat_result
- name: Fail if conflicting install directory exists
fail:
msg: "{{installer_dir}} exists! Remove before creating a new cluster."
when: stat_result.stat.exists
- name: Create installation config directory
file:
path: "{{installer_dir}}"
state: directory
- name: Create installation config directory
file:
path: "{{files_dir}}"
state: directory
- name: Create install-config.yaml
template:
src: install-config.yaml.j2
dest: "{{files_dir}}/install-config.yaml"
- name: Create per-cluster webroot
file:
path: "/var/www/html/{{cluster_name}}"
state: directory
owner: apache
group: apache
become: true
- name: Fetch RHCOS ISO
get_url:
url: "{{source_urls['rhcos_live_iso']}}"
dest: "{{files_dir}}/rhcos-base.iso"
environment:
http_proxy: "{{proxy_url|default(omit)}}"
https_proxy: "{{proxy_url|default(omit)}}"
- name: Extract RHCOS ISO if needed(Podman)
shell:
#!/bin/bash
podman run \
--security-opt label=disable \
--rm \
-v {{files_dir}}:/data \
-w /data {{coreos_installer_image}} \
iso extract minimal-iso \
--output-rootfs rhcos-rootfs.img \
rhcos-base.iso \
rhcos-minimal.iso
chmod 666 {{files_dir}}/rhcos-minimal.iso
become: true
when: source_urls.rhcos_image is not defined
- name: Fetch RHCOS Root FS if needed
get_url:
url: "{{source_urls['rhcos_image']}}"
dest: "{{files_dir}}/rhcos-rootfs.img"
environment:
http_proxy: "{{proxy_url|default(omit)}}"
https_proxy: "{{proxy_url|default(omit)}}"
when: source_urls.rhcos_image is defined
- name: Symlink rhcos-minimal.iso for pre-4.10
file:
state: link
src: "{{files_dir}}/rhcos-base.iso"
path: "{{files_dir}}/rhcos-minimal.iso"
when: source_urls.rhcos_image is defined
- name: Copy RHCOS Root FS
copy:
src: "{{files_dir}}/rhcos-rootfs.img"
dest: /var/www/html/{{cluster_name}}/rhcos-rootfs.img
owner: apache
group: apache
become: true
- name: Create TLS CA ignition
include_tasks: "include/tls_ignition_patch.yaml"
when: tls_additional_cas
- name: Create disk wiping ignition
include_tasks: "include/wipe_disks_patch.yaml"
when: wipe_disks == true
- name: Create installer customization ignition
include_tasks: "include/installer_customization_patch.yaml"
when: enable_kargs_in_dest == true and source_urls.rhcos_image is defined
- name: Compile combined ignition
include_tasks: "include/create_live_ignition.yaml"
when: additional_ignition_fragments
- name: Copy install-config
copy:
src: "{{files_dir}}/install-config.yaml"
dest: "{{installer_dir}}/install-config.yaml"
remote_src: yes
- name: Create manifests
shell: "{{bin_dir}}/openshift-install --dir={{installer_dir}} create manifests"
- name: Create custom Network Operator config
template:
src: cluster-network-operator-config.yaml.j2
dest: "{{installer_dir}}/manifests/cluster-network-03-config.yml"
when: customize_network_operator_config
- name: Configure disk encryption
include_tasks: "include/enable_disk_encryption.yaml"
when: encrypt_master_disks or encrypt_worker_disks
- name: Set masters to unschedulable
shell: "sed -i s/true/false/ {{installer_dir}}/manifests/cluster-scheduler-02-config.yml"
- name: Create base ignition configs
shell: "{{bin_dir}}/openshift-install --dir={{installer_dir}} create ignition-configs"
- hosts: openshift_nodes
gather_facts: false
tasks:
- name: Gather node information
include_tasks: "include/gather_{{pm_type}}_facts.yaml"
when: provision == true
- name: Build ISOs
include_tasks: include/coreos_build_iso.yaml
when: provision == true
- hosts: utility
gather_facts: true
tasks:
- name: Copy ignition files
shell: "cp {{installer_dir}}/*.ign /var/www/html/{{cluster_name}} && chown apache:apache /var/www/html/{{cluster_name}}/*.ign"
become: true
- name: Upload ISOs
copy:
src: "{{iso_tmp_dir}}/ocp-iso-build/isos"
dest: /var/www/html/{{cluster_name}}/boot-isos
owner: apache
group: apache
become: true
- hosts: openshift_nodes
gather_facts: false
tasks:
- name: Boot nodes
include_tasks: "include/boot_{{pm_type}}.yaml"
when: provision == true
- hosts: utility
gather_facts: true
tasks:
- name: Wait for bootstrap
shell: "{{bin_dir}}/openshift-install --dir={{installer_dir}} wait-for bootstrap-complete"
register: result
until: result.rc == 0
retries: 3
delay: 5
- hosts: openshift_nodes
gather_facts: false
tasks:
- name: Do post-install node cleanup
include_tasks: "include/cleanup_{{pm_type}}.yaml"
when: provision == true
- hosts: utility
gather_facts: true
tasks:
- name: Clean up utilty host
include_tasks: "include/cleanup_utility.yaml"
- hosts: bootstraps
gather_facts: false
tasks:
- name: Power off bootstrap node(s)
vmware_guest_powerstate:
hostname: "{{vcenter_host}}"
username: "{{vcenter_user}}"
password: "{{vcenter_password}}"
validate_certs: no
name: "{{short_name|default(inventory_hostname)}}"
state: powered-off
force: yes
delegate_to: localhost
when: provision == true