k3s-ansible/roles/reset/tasks/main.yml
Julien DOCHE 54629a46bd Change reset deletion order to avoid racecondition
If the k3s binary is launched after the deletion of `/var/lib/rancher/k3s`, k3s
will automatically create this directory. This change deletes the k3s binary
first so that it cannot be called after `/var/lib/rancher/k3s` is deleted

Signed-off-by: Julien DOCHE <julien.doche@gmail.com>
2021-02-19 00:12:51 +01:00

43 lines
958 B
YAML

---
- name: Disable services
systemd:
name: "{{ item }}"
state: stopped
enabled: no
failed_when: false
with_items:
- k3s
- k3s-node
- name: pkill -9 -f "k3s/data/[^/]+/bin/containerd-shim-runc"
register: pkill_containerd_shim_runc
command: pkill -9 -f "k3s/data/[^/]+/bin/containerd-shim-runc"
changed_when: "pkill_containerd_shim_runc.rc == 0"
failed_when: false
- name: Umount k3s filesystems
include_tasks: umount_with_children.yml
with_items:
- /run/k3s
- /var/lib/kubelet
- /run/netns
- /var/lib/rancher/k3s
loop_control:
loop_var: mounted_fs
- name: Remove service files, binaries and data
file:
name: "{{ item }}"
state: absent
with_items:
- /usr/local/bin/k3s
- "{{ systemd_dir }}/k3s.service"
- "{{ systemd_dir }}/k3s-node.service"
- /etc/rancher/k3s
- /var/lib/kubelet
- /var/lib/rancher/k3s
- name: daemon_reload
systemd:
daemon_reload: yes