-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuninstall.yml
More file actions
51 lines (43 loc) · 1.29 KB
/
Copy pathuninstall.yml
File metadata and controls
51 lines (43 loc) · 1.29 KB
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
45
46
47
48
49
50
51
---
- name: Run kubeadm reset
ansible.builtin.command: kubeadm reset -f --cri-socket=unix:///var/run/containerd/containerd.sock
args:
removes: /etc/kubernetes/admin.conf
- name: Remove kubeconfig
ansible.builtin.file:
path: /home/{{ kubeadm_user }}/.kube/config
state: absent
- name: Remove the CNI config
ansible.builtin.file:
path: /etc/cni/net.d
state: absent
- name: Unhold the versions to allow removal
ansible.builtin.dpkg_selections:
name: "{{ item }}"
selection: install
loop:
- kubelet
- kubeadm
- kubectl
- name: Remove kubelet kubeadm kubectl
ansible.builtin.apt:
name:
- kubelet
- kubeadm
- kubectl
state: absent
- name: Remove the Kubernetes apt repository
ansible.builtin.file:
path: /etc/apt/sources.list.d/kubernetes.list
state: absent
- name: Remove the Kubernetes apt key
ansible.builtin.file:
path: /etc/apt/keyrings/kubernetes-apt-keyring.gpg
state: absent
- name: Confirm the cluster config is removed
ansible.builtin.stat:
path: /etc/kubernetes/admin.conf
register: kubeadm_admin_conf
- name: Print the uninstall result
ansible.builtin.debug:
msg: "{{ 'kubeadm uninstalled successfully' if not kubeadm_admin_conf.stat.exists else 'kubeadm is still present, uninstall failed' }}"