xoxys.k3s/tasks/reset.yml

64 lines
1.6 KiB
YAML
Raw Normal View History

2022-10-03 20:58:05 +00:00
---
2022-10-17 19:26:56 +00:00
- block:
- name: Disable services
service:
name: "{{ item }}"
state: stopped
enabled: False
failed_when: False
loop:
- k3s
- k3s-init
- kubepods
2022-10-03 20:58:05 +00:00
2022-10-17 19:26:56 +00:00
- 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
2022-10-03 20:58:05 +00:00
2022-10-17 19:26:56 +00:00
- 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
2022-10-03 20:58:05 +00:00
2022-10-17 19:26:56 +00:00
- name: Umount filesystem
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
2022-10-17 19:26:56 +00:00
- 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 }}"
- /etc/cni
- /run/k3s
- /run/flannel
- /var/lib/kubelet
- /var/lib/cni
- /var/run/netns
2022-10-03 20:58:05 +00:00
2022-10-17 19:26:56 +00:00
- name: Reload systemd daemon
systemd:
daemon_reload: True
become: True
become_user: root