58 lines
1.3 KiB
YAML
58 lines
1.3 KiB
YAML
---
|
|
- name: Disable services
|
|
service:
|
|
name: "{{ item }}"
|
|
state: stopped
|
|
enabled: False
|
|
failed_when: False
|
|
loop:
|
|
- k3s
|
|
- k3s-init
|
|
|
|
- name: Kill containerd-shim-runc"
|
|
register: __k3s_pkill_containerd_shim_runc
|
|
command: pkill -9 -f "k3s/data/[^/]+/bin/containerd-shim-runc"
|
|
changed_when: __k3s_pkill_containerd_shim_runc.rc == 0
|
|
failed_when: False
|
|
|
|
- name: Get the list of mounted filesystems
|
|
shell: set -o pipefail && cat /proc/mounts | awk '{ print $2}' | grep -E "^{{ item }}"
|
|
loop:
|
|
- /run/k3s
|
|
- /var/lib/kubelet
|
|
- /run/netns
|
|
- /var/lib/kubelet/pods
|
|
- /var/lib/kubelet/plugins
|
|
- /run/netns/cni-
|
|
- "{{ k3s_data_dir }}"
|
|
register: __k3s_mounted_fs
|
|
args:
|
|
executable: /bin/bash
|
|
failed_when: False
|
|
changed_when: False
|
|
|
|
- name: Umount filesystem
|
|
mount:
|
|
path: "{{ item }}"
|
|
state: unmounted
|
|
loop: "{{ __k3s_mounted_fs.results | map(attribute='stdout_lines') | list | flatten | reverse }}"
|
|
|
|
- name: Remove service files, binaries and data
|
|
file:
|
|
name: "{{ item }}"
|
|
state: absent
|
|
loop:
|
|
- /usr/local/bin/k3s
|
|
- "{{ __k3s_service_file }}"
|
|
- "{{ k3s_config_dir }}"
|
|
- "{{ k3s_data_dir }}"
|
|
- "{{ k3s_log_dir }}"
|
|
- /run/k3s
|
|
- /run/flannel
|
|
- /var/lib/kubelet
|
|
- /var/lib/cni/
|
|
|
|
- name: Reload systemd daemon
|
|
systemd:
|
|
daemon_reload: True
|