forked from waynedovey/ocp4-vsphere-upi-automation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpost-install.yml
384 lines (344 loc) · 11.7 KB
/
post-install.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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
---
- hosts: localhost
connection: local
vars:
htpasswdpath: "./postinstall/users.htpasswd"
htpasswd_name: "my_htpasswd_provider"
htpasswd_pw: "redhat"
htpasswd_admin_users: "admin"
ldap_name: "my_ldap_provider"
ldap_pw: "testuser3"
ldap_bindDN: "uid=testuser3,ou=People,dc=example,dc=com"
ldap_url: "ldap://helper.ocp4.lab.gsslab.pek2.redhat.com/ou=people,dc=example,dc=com?uid"
ldap_admin_users: "testuser3"
oc_admin_role: "cluster-admin"
oc_app_domain: "apps.ocp4.lab.gsslab.pek2.redhat.com"
oc_api_domain: "api.ocp4.lab.gsslab.pek2.redhat.com"
environment:
# KUBECONFIG: ./kubeconfig
KUBECONFIG: /root/ocp4-vsphere-upi-automation/install-dir/auth/kubeconfig
tasks:
- name: POSTINSTALL 1.0 | Get Storage Nodes
shell: oc get nodes | grep storage | awk '{print $1}'
register: result
# register: storagenodes
tags:
- "1"
- name: POSTINSTALL 1.1 | Set fact storagenodes
set_fact:
storagenodes: "{{ result.stdout | from_yaml }}"
tags:
- "1"
- name: POSTINSTALL 1.2 | Display the fact storagenodes
debug:
msg: "{{ storagenodes }}"
tags:
- "1"
- name: POSTINSTALL 2.0 | Create HTPasswd file
htpasswd:
path: "{{ htpasswdpath }}"
name: "{{ htpasswd_admin_users }}"
password: "{{ htpasswd_pw }}"
crypt_scheme: md5_crypt
register: htpasswd
tags:
- "2"
- name: POSTINSTALL 2.1 | Create HTPasswd Secret
command: oc create secret generic htpass-secret --from-file=htpasswd="{{ htpasswdpath }}" -n openshift-config
ignore_errors: yes
tags:
- "2"
- name: POSTINSTALL 2.2 | Enable the HTPasswd User
k8s:
state: present
# apply: "yes"
definition:
apiVersion: config.openshift.io/v1
kind: OAuth
metadata:
name: cluster
spec:
identityProviders:
- name: "{{ htpasswd_name }}"
mappingMethod: claim
type: HTPasswd
htpasswd:
fileData:
name: htpasswd-secret
tags:
- "2"
- name: POSTINSTALL 3.0 | Create LDAP Secret
command: oc create secret generic ldap-secret --from-file=htpasswd="{{ htpasswdpath }}" -n openshift-config
register: result
ignore_errors: yes
tags:
- "3"
- name: POSTINSTALL 3.1 | Enable the LDAP User
k8s:
state: present
# apply: "yes"
definition:
apiVersion: config.openshift.io/v1
kind: OAuth
metadata:
name: cluster
spec:
identityProviders:
- name: "{{ ldap_name }}"
mappingMethod: claim
type: LDAP
ldap:
attributes:
id:
- dn
email:
- mail
name:
- cn
preferredUsername:
- uid
bindDN: "{{ ldap_bindDN }}"
bindPassword:
name: ldap-secret
insecure: true
url: "{{ ldap_url }}"
tags:
- "3"
- name: POSTINSTALL 4.0 | Elevate Users
command: oc adm policy add-cluster-role-to-user "{{ oc_admin_role }}" "{{ item }}"
loop:
- "{{ htpasswd_admin_users }}"
- "{{ ldap_admin_users }}"
tags:
- "4"
- name: POSTINSTALL 5.0 | Remove generic Kubeadmin User
command: oc delete secrets kubeadmin -n kube-system
register: result
ignore_errors: yes
tags:
- "5"
- name: POSTINSTALL 6.0 | Create Chrony configuration for masters
k8s:
state: present
apply: "yes"
definition:
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfig
metadata:
labels:
machineconfiguration.openshift.io/role: master
name: masters-chrony-configuration
spec:
config:
ignition:
config: {}
security:
tls: {}
timeouts: {}
version: 2.2.0
networkd: {}
passwd: {}
storage:
files:
- contents:
source: data:text/plain;charset=utf-8;base64,"{{ lookup('file', 'templates/chrony.conf.j2') | string | b64encode }}"
verification: {}
filesystem: root
mode: 420
path: /etc/chrony.conf
osImageURL: ""
tags:
- "6"
# - name: POSTINSTALL 6.1 | Get status of Authentication
# shell: "oc describe authentication | grep -i PROGRESSING -b1 | grep Status | awk '{print $3}'"
# async: 45
# poll: 5
# tags:
# - "6"
- name: POSTINSTALL 7.0 | Create Chrony configuration for workers
k8s:
state: present
apply: "yes"
definition:
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfig
metadata:
labels:
machineconfiguration.openshift.io/role: worker
name: workers-chrony-configuration
spec:
config:
ignition:
config: {}
security:
tls: {}
timeouts: {}
version: 2.2.0
networkd: {}
passwd: {}
storage:
files:
- contents:
source: data:text/plain;charset=utf-8;base64,"{{ lookup('file', 'templates/chrony.conf.j2') | string | b64encode }}"
verification: {}
filesystem: root
mode: 420
path: /etc/chrony.conf
osImageURL: ""
tags:
- "7"
# - name: POSTINSTALL 7.1 | Get status of MachineConfigPool
# # Example: Ready Machine Count: 3
# shell: "oc describe machineconfigpool master | tail -n7 | grep Ready | awk '{print $4}'"
# async: 45
# poll: 5
# tags:
# - "7"
# TODO Figure out how to declare storage nodes
- name: POSTINSTALL 8.0 | Label and Taint Storage Nodes
command: "{{ item }}"
register: result
loop:
- "oc label nodes {{ storagenodes }} cluster.ocs.openshift.io/openshift-storage='' --overwrite"
- "oc adm taint nodes {{ storagenodes }} node.ocs.openshift.io/storage=true:NoSchedule --overwrite"
when: enable_ocs_storage|bool == True
tags:
- "8"
- name: POSTINSTALL 9.0 | Drain and uncordon Storage Nodes
command: "{{ item }}"
register: result
loop:
- "oc adm drain {{ storagenodes }} --ignore-daemonsets --delete-local-data"
- "oc adm uncordon {{ storagenodes }}"
when: enable_ocs_storage|bool == True
tags:
- "9"
- name: POSTINSTALL 10.0 | Create Storage Namespace
k8s:
state: present
src: "./postinstall/rhocs-namespace.yml"
when: enable_ocs_storage|bool == True
tags:
- "10"
- name: POSTINSTALL 10.1 | Create Storage Operator Group
k8s:
state: present
src: "./postinstall/rhocs-operatorgroup.yml"
when: enable_ocs_storage|bool == True
tags:
- "10"
- name: POSTINSTALL 10.2 | Create the Storage OLM
k8s:
state: present
apply: "yes"
src: "./postinstall/ocs-olm.yml"
when: enable_ocs_storage|bool == True
tags:
- "10"
# - name: POSTINSTALL 10.3 | Get status of Red Hat OpenShift Container Storage (OCS) operator
# shell: "oc get csv | grep ocs-operator | awk '{print $6}'"
# async: 45
# poll: 5
# tags:
# - "10"
- name: POSTINSTALL 10.4 | Create the Storage Cluster
k8s:
state: present
apply: "yes"
src: "./postinstall/ocs-StorageCluster.yml"
when: enable_ocs_storage|bool == True
tags:
- "10"
# TODO Figure out the escape sequence
- name: POSTINSTALL 10.5 | Patch the Storage cluster
command: "{{ item }}"
register: result
loop:
- "oc patch storageclass thin -p '{\"metadata\": {\"annotations\": {\"storageclass.kubernetes.io/is-default-class\": \"false\"}}}'"
- "oc patch storageclass ocs-storagecluster-cephfs -p '{\"metadata\": {\"annotations\": {\"storageclass.kubernetes.io/is-default-class\": \"true\"}}}'"
when: enable_ocs_storage|bool == True
tags:
- "10"
- name: POSTINSTALL 11.0 | Change registry Operator to "Managed"
command: "oc patch configs.imageregistry.operator.openshift.io/cluster --type merge -p '{\"spec\":{\"managementState\": \"Managed\"}}' -n openshift-image-registry"
register: result
tags:
- "11"
- name: POSTINSTALL 12.0 | Enable Registry PVC
k8s:
state: present
apply: "yes"
namespace: "openshift-image-registry"
src: "./postinstall/ocs4registry-pvc.yml"
tags:
- "12"
- name: POSTINSTALL 13.0 | Change registry Operator to "Managed"
command: "oc patch configs.imageregistry.operator.openshift.io/cluster --type merge -p '{\"spec\":{\"storage\": {\"pvc\": {\"claim\": \"image-registry-storage\"}}}}' -n openshift-image-registry"
register: result
tags:
- "13"
- name: POSTINSTALL 14.0 | Create App Cert Configmap
command: "oc create configmap custom-ca --from-file=ca-bundle.crt=certs/{{ oc_app_domain }}.pem -n openshift-config"
register: result
tags:
- "14"
- name: POSTINSTALL 15.0 | Update the CA Cert with the Custom CA
command: "oc patch proxy/cluster --type=merge --patch='{\"spec\":{\"trustedCA\":{\"name\":\"custom-ca\"}}}'"
register: result
tags:
- "15"
- name: POSTINSTALL 16.0 | Create the Certificate Secret
command: "oc patch proxy/cluster --type=merge --patch='{\"spec\":{\"trustedCA\":{\"name\":\"custom-ca\"}}}'"
register: result
tags:
- "16"
- name: POSTINSTALL 17.0 | Create the Certificate Secret
command: "oc create secret tls {{ oc_app_domain }}.com --cert=certs/{{ oc_app_domain }}.pem --key=certs/{{ oc_app_domain }}.key -n openshift-ingress"
register: result
tags:
- "17"
- name: POSTINSTALL 18.0 | Enable the Certificate on Ingresscontroller
command: "oc patch ingresscontroller.operator default --type=merge -p '{\"spec\":{\"defaultCertificate\": {\"name\": \"{{ oc_app_domain }}\"}}}' -n openshift-ingress-operator"
register: result
tags:
- "18"
- name: POSTINSTALL 19.0 | Create the API Certificate
command: "oc create secret tls {{ oc_api_domain }} --cert=certs/{{ oc_api_domain }}.pem --key=certs/{{ oc_api_domain }}.key -n openshift-config"
register: result
tags:
- "19"
- name: POSTINSTALL 20.0 | Enable the API Certificate
command: "oc patch apiserver cluster --type=merge -p '{\"spec\":{\"servingCerts\": {\"namedCertificates\": [{\"names\": [\"{{ oc_api_domain }}\"], \"servingCertificate\": {\"name\": \"{{ oc_api_domain }}\"}}]}}}'"
register: result
tags:
- "20"
- name: POSTINSTALL 21.0 | Enable Monitoring Persistent Storage
k8s:
state: present
apply: "yes"
src: "./postinstall/cluster-monitoring-config.yml"
tags:
- "21"
- name: POSTINSTALL 22.0 | Enable Cluster Logging
command: "{{ item }}"
register: result
loop:
- "oc create -f ./postinstall/logging/eo-namespace.yml"
- "oc create -f ./postinstall/logging/clo-namespace.yml"
- "oc create -f ./postinstall/logging/eo-og.yml"
- "oc create -f ./postinstall/logging/eo-sub.yml"
- "oc create -f ./postinstall/logging/eo-rbac.yml -n openshift-operators-redhat"
- "oc create -f ./postinstall/logging/cluster-logging-og.yml -n openshift-logging"
- "oc create -f ./postinstall/logging/cluster-logging-olm.yml -n openshift-logging"
tags:
- "22"
- name: POSTINSTALL 23.0 | Wait for Cluster CR to appear
command: "sleep 30"
register: result
tags:
- "23"
- name: POSTINSTALL 24.0 | Create the CRD Logging
command: "oc create -f ./postinstall/logging/cluster-logging-crd.yml"
register: result
tags:
- "24"