blob: 340a475d55009a9b158a258cb9f565dce9f2c6cb [file] [log] [blame]
Fatemeh Rouzbehb4b55072022-03-02 10:03:15 -08001---
2# rkecleanup tasks/main.yml
3#
4# SPDX-FileCopyrightText: © 2022 Open Networking Foundation <support@opennetworking.org>
5# SPDX-License-Identifier: Apache-2.0
6- name: Stop Docker Container
7 shell:
8 cmd: "docker rm -f $(docker ps -qa)"
9 register: result
10 failed_when: >
11 ("docker: not found" not in result.stderr) and
12 ("requires at least 1 argument" not in result.stderr) and
13 (result.stderr | length > 0)
14 changed_when: >
15 ("docker: not found" not in result.stderr)
16
17- name: Remove Docker Images
18 shell:
19 cmd: "docker rmi -f $(docker images -q)"
20 register: result
21 failed_when: >
22 ("docker: not found" not in result.stderr) and
23 ("requires at least 1 argument" not in result.stderr) and
24 (result.stderr | length > 0)
25 changed_when: >
26 ("docker: not found" not in result.stderr)
27
28- name: Remove Docker Volumes
29 shell:
30 cmd: "docker volume rm $(docker volume ls -q)"
31 register: result
32 failed_when: >
33 ("docker: not found" not in result.stderr) and
34 ("requires at least 1 argument" not in result.stderr) and
35 (result.stderr | length > 0)
36 changed_when: >
37 ("docker: not found" not in result.stderr)
38 notify: Uninstall Docker
39
40- name: Unmount kubelet mounts
41 shell:
42 cmd: >
43 for mount in $(mount | grep tmpfs |
44 grep '/var/lib/kubelet' |
45 awk '{ print $3 }') /var/lib/kubelet /var/lib/rancher;
46 do umount $mount; done
47 register: result
48 failed_when: >
49 ("no mount point specified" not in result.stderr) and
50 ("not mounted" not in result.stderr) and
51 (result.stderr | length > 0)
52 changed_when: >
53 ("no mount point specified" not in result.stderr) and
54 ("not mounted" not in result.stderr)
55
56- name: Remove Directories and Files
57 file:
58 path: "{{ item }}"
59 state: absent
60 with_items:
61 - /etc/ceph
62 - /etc/cni
63 - /etc/kubernetes
64 - /opt/cni
65 - /opt/rke
66 - /run/secrets/kubernetes.io
67 - /run/calico
68 - /run/flannel
69 - /var/lib/calico
70 - /var/lib/etcd
71 - /var/lib/cni
72 - /var/lib/kubelet
73 - /var/lib/rancher/rke/log
74 - /var/log/containers
75 - /var/log/pods
76 - /var/run/calico