-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathuninstall.yaml
45 lines (38 loc) · 1.82 KB
/
uninstall.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
---
- hosts: localhost
vars:
config: "{{ lookup('file', config_file) }}"
ns: "{{ config | json_query('cp4i_namespace') }}"
operator_scope: "{{ config | json_query('operator_scope') }}"
tasks:
# Show the stating message
- name: Info
debug:
msg: "Uninstallation of CP4I"
# Delete the exisiting resources (CP4I component instances)
- name: Delete exisiting resources
shell: "./scripts/delete_resource.sh {{ns}}"
# Delete the subscriptions
- name: Delete subscription (global)
shell: for i in $(oc get subscription -n openshift-operators -o custom-columns=name:metadata.name);do oc delete subscription -n openshift-operators $i; done
when: operator_scope == "cluster"
- name: Delete subscription (namespace)
shell: for i in $(oc get subscription -n {{ns}} -o custom-columns=name:metadata.name);do oc delete subscription -n {{ns}} $i; done
when: operator_scope == "namespace"
# Delete the Operator CSV
- name: Delete csv (global)
shell: for i in $(oc get csv -n openshift-operators -o custom-columns=name:metadata.name);do oc delete csv -n openshift-operators $i; done
when: operator_scope == "cluster"
- name: Delete csv (namespace)
shell: for i in $(oc get csv -n {{ns}} -o custom-columns=name:metadata.name);do oc delete csv -n {{ns}} $i; done
when: operator_scope == "namespace"
# Delete the configmaps
- name: Delete DB configmap (global)
shell: oc delete ConfigMap couchdb-release redis-release -n openshift-operators
when: operator_scope == "cluster"
- name: Delete DB configmap (global)
shell: oc delete ConfigMap couchdb-release redis-release -n {{ns}}
when: operator_scope == "namespace"
# Delete the namespace
- name: Delete target namespace
shell: oc delete ns {{ns}}