2022-10-03 20:58:05 +00:00
|
|
|
---
|
2024-02-18 20:09:43 +00:00
|
|
|
- name: Disable services
|
|
|
|
ansible.builtin.service:
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: stopped
|
|
|
|
enabled: False
|
|
|
|
failed_when: False
|
|
|
|
loop:
|
|
|
|
- k3s
|
|
|
|
- k3s-init
|
|
|
|
- kubepods
|
2022-10-03 20:58:05 +00:00
|
|
|
|
2024-02-18 20:09:43 +00:00
|
|
|
- name: Kill containerd-shim-runc
|
|
|
|
register: __k3s_pkill_containerd_shim_runc
|
|
|
|
ansible.builtin.command: pkill -9 -f "k3s/data/[^/]+/bin/containerd-shim-runc"
|
|
|
|
changed_when: __k3s_pkill_containerd_shim_runc.rc == 0
|
|
|
|
failed_when: False
|
2022-10-03 20:58:05 +00:00
|
|
|
|
2024-02-18 20:09:43 +00:00
|
|
|
- name: Get the list of mounted filesystems
|
|
|
|
ansible.builtin.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
|
2022-10-03 20:58:05 +00:00
|
|
|
|
2024-02-18 20:09:43 +00:00
|
|
|
- name: Umount filesystem
|
|
|
|
ansible.posix.mount:
|
|
|
|
path: "{{ item }}"
|
|
|
|
state: unmounted
|
|
|
|
loop: "{{ __k3s_mounted_fs.results | map(attribute='stdout_lines') | list | flatten | reverse }}"
|
2022-10-03 20:58:05 +00:00
|
|
|
|
2024-02-18 20:09:43 +00:00
|
|
|
- name: Remove service files, binaries and data
|
|
|
|
ansible.builtin.file:
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: absent
|
|
|
|
loop:
|
|
|
|
- /usr/local/bin/k3s
|
|
|
|
- "{{ __k3s_service_file }}"
|
|
|
|
- "{{ __k3s_config_dir }}"
|
|
|
|
- "{{ __k3s_data_dir }}"
|
|
|
|
- "{{ __k3s_log_dir }}"
|
|
|
|
- /etc/cni
|
|
|
|
- /run/k3s
|
|
|
|
- /run/flannel
|
|
|
|
- /var/lib/kubelet
|
|
|
|
- /var/lib/cni
|
|
|
|
- /var/run/netns
|
2022-10-03 20:58:05 +00:00
|
|
|
|
2024-02-18 20:09:43 +00:00
|
|
|
- name: Reload systemd daemon
|
|
|
|
ansible.builtin.service:
|
|
|
|
daemon_reload: True
|