-
Notifications
You must be signed in to change notification settings - Fork 0
/
k3s-reset.yml
44 lines (44 loc) · 1.38 KB
/
k3s-reset.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
---
- name: Undo cluster setup
hosts: belt
become: true
vars_files:
- "env_vars/k3s.yml"
tasks:
- name: Run K3s Uninstall script [server]
when: "'server' in group_names"
ansible.builtin.command:
cmd: k3s-uninstall.sh
removes: /var/lib/rancher/k3s/*
- name: Run K3s Uninstall script [agent]
when: "'agent' in group_names"
ansible.builtin.command:
cmd: k3s-agent-uninstall.sh
removes: /var/lib/rancher/k3s/*
- name: Remove user kubeconfig
ansible.builtin.file:
path: ~{{ ansible_user }}/.kube/config
state: absent
- name: Remove root kubeconfig
ansible.builtin.file:
path: /root/.kube/config
state: absent
- name: Remove k3s install script
ansible.builtin.file:
path: /usr/local/bin/k3s-install.sh
state: absent
- 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 }}/*"
- name: Remove K3s config
when: server_config_yaml is defined
ansible.builtin.file:
path: /etc/rancher/k3s/config.yaml
state: absent
- name: Remove K3s kubeconfig
when: server_config_yaml is defined
ansible.builtin.file:
path: /etc/rancher/k3s/k3s.yaml
state: absent