-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuninstall.yml
170 lines (153 loc) · 5.93 KB
/
uninstall.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
---
- hosts: localhost
connection: local
gather_facts: false
vars:
k8s_api_endpoint: https://api.ocp.ltsai.com:6443
k8s_admin_username: kubeadmin
k8s_validate_certs: false
operators:
- elasticsearch-operator
- cluster-logging
vars_files:
- vault.yml
tasks:
- name: Clean up
block:
- name: Login to OpenShift
k8s_auth:
username: "{{ k8s_admin_username }}"
password: "{{ k8s_admin_password }}"
host: "{{ k8s_api_endpoint }}"
validate_certs: "{{ k8s_validate_certs | default(false) }} "
register: k8s_auth_results
- name: Delete the CatalogSource resource
k8s:
definition:
apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
name: "{{item}}-catalog"
namespace: openshift-marketplace
validate_certs: "{{ k8s_validate_certs | default(true) }} "
api_key: "{{ k8s_auth_results.k8s_auth.api_key }}"
host: "{{ k8s_api_endpoint }}"
state: absent
with_items: "{{ operators }}"
- name: Delete ImageContentSourcePolicy
k8s:
definition:
apiVersion: operator.openshift.io/v1alpha1
kind: ImageContentSourcePolicy
metadata:
name: "{{item}}"
validate_certs: "{{ k8s_validate_certs | default(true) }} "
api_key: "{{ k8s_auth_results.k8s_auth.api_key }}"
host: "{{ k8s_api_endpoint }}"
state: absent
with_items: "{{ operators }}"
- name: Find cluster logging instance
k8s_info:
api_version: logging.openshift.io/v1
kind: ClusterLogging
name: instance
namespace: openshift-logging
validate_certs: "{{ k8s_validate_certs | default(true) }} "
api_key: "{{ k8s_auth_results.k8s_auth.api_key }}"
host: "{{ k8s_api_endpoint }}"
register: logging_instance
- name: Delete cluster logging instance
k8s:
definition:
apiVersion: logging.openshift.io/v1
kind: ClusterLogging
metadata:
name: instance
namespace: openshift-logging
validate_certs: "{{ k8s_validate_certs | default(true) }} "
api_key: "{{ k8s_auth_results.k8s_auth.api_key }}"
host: "{{ k8s_api_endpoint }}"
state: absent
when: logging_instance.resources
- name: Delete cluster logging operator group
k8s:
definition:
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
name: openshift-logging
namespace: openshift-logging
validate_certs: "{{ k8s_validate_certs | default(true) }} "
api_key: "{{ k8s_auth_results.k8s_auth.api_key }}"
host: "{{ k8s_api_endpoint }}"
state: absent
- name: Delete Cluster Logging Subscription object
k8s:
definition:
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: "cluster-logging"
namespace: "openshift-logging"
validate_certs: "{{ k8s_validate_certs | default(true) }} "
api_key: "{{ k8s_auth_results.k8s_auth.api_key }}"
host: "{{ k8s_api_endpoint }}"
state: absent
- name: Delete openshift-logging namespace
k8s:
definition:
apiVersion: v1
kind: Namespace
metadata:
name: openshift-logging
validate_certs: "{{ k8s_validate_certs | default(true) }} "
api_key: "{{ k8s_auth_results.k8s_auth.api_key }}"
host: "{{ k8s_api_endpoint }}"
state: absent
- name: Delete Elasticsearch Subscription object
k8s:
definition:
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: "elasticsearch-operator"
namespace: "openshift-operators"
validate_certs: "{{ k8s_validate_certs | default(true) }} "
api_key: "{{ k8s_auth_results.k8s_auth.api_key }}"
host: "{{ k8s_api_endpoint }}"
state: absent
- name: Enable auto rebooting for MCO
k8s:
definition:
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfigPool
metadata:
name: master
spec:
paused: false
api_key: "{{ k8s_auth_results.k8s_auth.api_key }}"
host: "{{ k8s_api_endpoint }}"
validate_certs: "{{ k8s_validate_certs | default(true) }} "
state: present
always:
- name: If login succeeded, try to log out (revoke access token)
k8s_auth:
state: absent
host: "{{ k8s_api_endpoint }}"
api_key: "{{ k8s_auth_results.k8s_auth.api_key }}"
validate_certs: "{{ k8s_validate_certs | default(false) }}"
when: k8s_auth_results.failed == false
- hosts: workers
gather_facts: false
become: yes
remote_user: core
vars:
ocp_local_registry: ocp4-registry.ocp.ltsai.com:5000
tasks:
- name: Delete operator registry image
podman_image:
name: "{{ocp_local_registry}}/operator-registry/{{item}}:latest"
state: absent
with_items:
- cluster-logging
- elasticsearch-operator