2023-01-30 19:46:09 +01:00
|
|
|
---
|
|
|
|
- name: Undo cluster setup
|
|
|
|
hosts: k3s_cluster
|
|
|
|
become: true
|
2023-11-09 01:26:26 +01:00
|
|
|
tasks:
|
2023-11-11 00:17:13 +01:00
|
|
|
- name: Run K3s Uninstall script [server]
|
|
|
|
when: "'server' in group_names"
|
2023-11-09 01:26:26 +01:00
|
|
|
ansible.builtin.command:
|
|
|
|
cmd: k3s-uninstall.sh
|
|
|
|
removes: /var/lib/rancher/k3s/*
|
2023-11-11 00:17:13 +01:00
|
|
|
- name: Run K3s Uninstall script [agent]
|
|
|
|
when: "'agent' in group_names"
|
|
|
|
ansible.builtin.command:
|
|
|
|
cmd: k3s-agent-uninstall.sh
|
|
|
|
removes: /var/lib/rancher/k3s/*
|
2023-11-09 01:26:26 +01:00
|
|
|
- name: Remove user kubeconfig
|
|
|
|
ansible.builtin.file:
|
2023-12-01 23:34:44 +01:00
|
|
|
path: ~{{ ansible_user }}/.kube/config
|
2023-11-09 01:26:26 +01:00
|
|
|
state: absent
|
2023-11-30 21:32:19 +01:00
|
|
|
- name: Remove k3s install script
|
|
|
|
ansible.builtin.file:
|
|
|
|
path: /usr/local/bin/k3s-install.sh
|
|
|
|
state: absent
|
2023-12-01 23:34:44 +01:00
|
|
|
- name: Remove contents of K3s server location
|
|
|
|
when: k3s_server_location is defined
|
|
|
|
ansible.builtin.shell:
|
|
|
|
cmd: "rm -rf {{ k3s_server_location }}/*"
|
|
|
|
removes: "{{ k3s_server_location }}/*"
|
2023-12-06 22:55:32 +01:00
|
|
|
- name: Remove K3s config
|
|
|
|
when: server_config_yaml is defined
|
|
|
|
ansible.builtin.file:
|
|
|
|
path: /etc/rancher/k3s/config.yaml
|
|
|
|
state: absent
|