74 lines
2.8 KiB
YAML
74 lines
2.8 KiB
YAML
---
|
|
- name: Cleanup Rook Ceph Resources (K8s)
|
|
hosts: k3s_masters[0]
|
|
become: yes
|
|
tasks:
|
|
- name: Delete ArgoCD Applications if they exist
|
|
shell: kubectl delete application -n argocd rook-ceph-cluster rook-ceph-operator --ignore-not-found
|
|
ignore_errors: yes
|
|
|
|
- name: Delete Rook Ceph Cluster CR
|
|
shell: kubectl -n rook-ceph delete cephcluster rook-ceph --wait=false --ignore-not-found
|
|
|
|
- name: Patch CephCluster finalizer (to force deletion if stuck)
|
|
shell: |
|
|
kubectl -n rook-ceph patch cephcluster rook-ceph --type merge -p '{"metadata":{"finalizers": []}}'
|
|
ignore_errors: yes
|
|
|
|
- name: Patch CephBlockPool finalizers
|
|
shell: |
|
|
kubectl -n rook-ceph get cephblockpool -o name | xargs -I {} kubectl -n rook-ceph patch {} --type merge -p '{"metadata":{"finalizers": []}}'
|
|
ignore_errors: yes
|
|
|
|
- name: Patch CephObjectStore finalizers
|
|
shell: |
|
|
kubectl -n rook-ceph get cephobjectstore -o name | xargs -I {} kubectl -n rook-ceph patch {} --type merge -p '{"metadata":{"finalizers": []}}'
|
|
ignore_errors: yes
|
|
|
|
- name: Patch CephFilesystem finalizers
|
|
shell: |
|
|
kubectl -n rook-ceph get cephfilesystem -o name | xargs -I {} kubectl -n rook-ceph patch {} --type merge -p '{"metadata":{"finalizers": []}}'
|
|
ignore_errors: yes
|
|
|
|
- name: Patch all remaining Rook resources finalizers
|
|
shell: |
|
|
kubectl api-resources --verbs=list --namespaced -o name | grep ceph.rook.io | xargs -n 1 kubectl get --show-kind --ignore-not-found -n rook-ceph -o name | xargs -r -n 1 kubectl -n rook-ceph patch --type merge -p '{"metadata":{"finalizers": []}}'
|
|
ignore_errors: yes
|
|
|
|
- name: Force delete Namespace rook-ceph (remove finalizers from NS)
|
|
shell: |
|
|
kubectl get namespace rook-ceph -o json | jq '.spec.finalizers=[]' | kubectl replace --raw "/api/v1/namespaces/rook-ceph/finalize" -f -
|
|
ignore_errors: yes
|
|
|
|
- name: Delete Rook Ceph Namespace
|
|
shell: kubectl delete namespace rook-ceph --wait=false --ignore-not-found
|
|
ignore_errors: yes
|
|
|
|
- name: Delete Rook Ceph CRDs (Global cleanup)
|
|
shell: kubectl delete crd $(kubectl get crd | grep ceph.rook.io | awk '{print $1}')
|
|
ignore_errors: yes
|
|
|
|
- name: Cleanup Rook Ceph Data on Nodes
|
|
hosts: k3s_masters
|
|
become: yes
|
|
tasks:
|
|
- name: Remove /var/lib/rook directory
|
|
file:
|
|
path: /var/lib/rook
|
|
state: absent
|
|
force: yes
|
|
|
|
# WARNING: These commands will WIPE DATA on /dev/sdb
|
|
- name: Zap Disk sdb
|
|
shell: sgdisk --zap-all /dev/sdb || true
|
|
ignore_errors: yes
|
|
|
|
- name: WipeFS sdb
|
|
shell: wipefs -a /dev/sdb || true
|
|
ignore_errors: yes
|
|
|
|
- name: Mapper clean
|
|
shell: ls /dev/mapper/ceph-* | xargs -I% -- dmsetup remove %
|
|
ignore_errors: yes
|
|
failed_when: false
|