Files
k3s-ansible/roles/reset/tasks/main.yml
Nicholas Malcolm 8484c015d6 Fix k3s_server_location only working on default
- K3s has some absolute paths set in various places which cannot be
  changed. Using a symbolic link was the easiest fix. This is nice for
  running K3S on SBC that must boot to SD but K3S data should be stored
  on a faster drive.
- Other changes are for making the site playbook replayable without
  resetting the cluster. Ideally you can rerun it to check existing
  nodes or to add new ones.

Signed-off-by: Derek Nola <derek.nola@suse.com>
2023-11-08 10:23:56 -08:00

51 lines
1.3 KiB
YAML

---
- name: Clean previous failed runs of k3s-init
# systemd builtin does not support reset-failed
ansible.builtin.command: systemctl reset-failed k3s-init
failed_when: false
changed_when: false
- name: Disable services
ansible.builtin.systemd:
name: "{{ item }}"
state: stopped
enabled: false
failed_when: false
with_items:
- k3s-init
- k3s-server
- k3s-agent
- name: Kill container shim
ansible.builtin.command: pkill -9 -f "k3s/data/[^/]+/bin/containerd-shim-runc"
register: pkill_containerd_shim_runc
changed_when: "pkill_containerd_shim_runc.rc == 0"
failed_when: false
- name: Umount k3s filesystems
ansible.builtin.include_tasks: umount_with_children.yml
with_items:
- /run/k3s
- /var/lib/kubelet
- /run/netns
- "{{ k3s_server_location }}"
loop_control:
loop_var: mounted_fs
- name: Remove service files, binaries, and data
ansible.builtin.file:
name: "{{ item }}"
state: absent
with_items:
- /usr/local/bin/k3s
- "{{ systemd_dir }}/k3s-server.service"
- "{{ systemd_dir }}/k3s-agent.service"
- /etc/rancher/k3s
- /var/lib/kubelet
- /var/lib/rancher/k3s
- "{{ k3s_server_location }}"
- name: Systemd daemon reload
ansible.builtin.systemd:
daemon_reload: true