| --- |
| # rkecleanup tasks/main.yml |
| # |
| # SPDX-FileCopyrightText: © 2022 Open Networking Foundation <support@opennetworking.org> |
| # SPDX-License-Identifier: Apache-2.0 |
| - name: Stop Docker Container |
| shell: |
| cmd: "docker rm -f $(docker ps -qa)" |
| register: result |
| failed_when: > |
| ("docker: not found" not in result.stderr) and |
| ("requires at least 1 argument" not in result.stderr) and |
| (result.stderr | length > 0) |
| changed_when: > |
| ("docker: not found" not in result.stderr) |
| |
| - name: Remove Docker Images |
| shell: |
| cmd: "docker rmi -f $(docker images -q)" |
| register: result |
| failed_when: > |
| ("docker: not found" not in result.stderr) and |
| ("requires at least 1 argument" not in result.stderr) and |
| (result.stderr | length > 0) |
| changed_when: > |
| ("docker: not found" not in result.stderr) |
| |
| - name: Remove Docker Volumes |
| shell: |
| cmd: "docker volume rm $(docker volume ls -q)" |
| register: result |
| failed_when: > |
| ("docker: not found" not in result.stderr) and |
| ("requires at least 1 argument" not in result.stderr) and |
| (result.stderr | length > 0) |
| changed_when: > |
| ("docker: not found" not in result.stderr) |
| notify: Uninstall Docker |
| |
| - name: Unmount kubelet mounts |
| shell: |
| cmd: > |
| for mount in $(mount | grep tmpfs | |
| grep '/var/lib/kubelet' | |
| awk '{ print $3 }') /var/lib/kubelet /var/lib/rancher; |
| do umount $mount; done |
| register: result |
| failed_when: > |
| ("no mount point specified" not in result.stderr) and |
| ("not mounted" not in result.stderr) and |
| (result.stderr | length > 0) |
| changed_when: > |
| ("no mount point specified" not in result.stderr) and |
| ("not mounted" not in result.stderr) |
| |
| - name: Remove Directories and Files |
| file: |
| path: "{{ item }}" |
| state: absent |
| with_items: |
| - /etc/ceph |
| - /etc/cni |
| - /etc/kubernetes |
| - /opt/cni |
| - /opt/rke |
| - /run/secrets/kubernetes.io |
| - /run/calico |
| - /run/flannel |
| - /var/lib/calico |
| - /var/lib/etcd |
| - /var/lib/cni |
| - /var/lib/kubelet |
| - /var/lib/rancher/rke/log |
| - /var/log/containers |
| - /var/log/pods |
| - /var/run/calico |