45 lines
1.3 KiB
YAML
45 lines
1.3 KiB
YAML
---
|
|
- hosts:
|
|
- master
|
|
- worker
|
|
become: true
|
|
gather_facts: true
|
|
any_errors_fatal: true
|
|
vars_prompt:
|
|
- name: nuke
|
|
prompt: |-
|
|
Are you sure you want to nuke this cluster?
|
|
Type YES I WANT TO DESTROY THIS CLUSTER to proceed
|
|
default: "n"
|
|
private: false
|
|
pre_tasks:
|
|
- name: Check for confirmation
|
|
ansible.builtin.fail:
|
|
msg: Aborted nuking the cluster
|
|
when: nuke != 'YES I WANT TO DESTROY THIS CLUSTER'
|
|
|
|
- name: Pausing for 5 seconds...
|
|
ansible.builtin.pause:
|
|
seconds: 5
|
|
tasks:
|
|
- name: Kill k3s
|
|
ansible.builtin.command: /usr/local/bin/k3s-killall.sh
|
|
- name: Uninstall k3s
|
|
ansible.builtin.command:
|
|
cmd: /usr/local/bin/k3s-uninstall.sh
|
|
removes: /usr/local/bin/k3s-uninstall.sh
|
|
- name: Uninstall k3s agent
|
|
ansible.builtin.command:
|
|
cmd: /usr/local/bin/k3s-agent-uninstall.sh
|
|
removes: /usr/local/bin/k3s-agent-uninstall.sh
|
|
- name: Gather list of CNI files to delete
|
|
ansible.builtin.find:
|
|
paths: /etc/cni/net.d
|
|
patterns: "*"
|
|
register: files_to_delete
|
|
- name: Delete CNI files
|
|
ansible.builtin.file:
|
|
path: "{{ item.path }}"
|
|
state: absent
|
|
loop: "{{ files_to_delete.files }}"
|