--- - name: Playbook to rollback an automated manual k8s installation hosts: workers become: true tasks: - name: Stop k8s services prior to deleting them service: name: "{{ item }}" state: stopped enabled: false with_items: - "kube-proxy" - "containerd" - "kubelet" - name: Delete the binaries file: path: /usr/local/bin/{{ item }} state: absent with_items: - kubectl - kube-proxy - kubelet - runc - runsc - crictl - name: Remove the dependencies apt: name: "{{ item }}" state: absent with_items: - "socat" - "ipset" - "conntrack" - name: Delete service files file: path: /etc/systemd/system/{{ item }} state: absent with_items: - kubelet.service - kube-proxy.service - containerd.service - name: Delete k8s directories and files file: path: "{{ item }}" state: absent with_items: - "/var/lib/kube-proxy" - "/var/lib/kubernetes" - "/var/lib/kubelet" - "/etc/containerd" - "/etc/cni" - "/etc/kubernetes" - "/bin/containerd" - "/bin/ctr" - "/bin/containerd-shim-runc-v1" - "/bin/containerd-shim" - "/bin/containerd-release" - "/bin/containerd-stress" - "/opt/cni" - name: Playbook to rollback an automated manual k8s installation hosts: masters become: true tasks: - name: Stop k8s services prior to deleting them service: name: "{{ item }}" state: stopped enabled: false with_items: - "kube-scheduler" - "kube-controller-manager" - "kube-apiserver" - "etcd" - name: Delete the binaries file: path: /usr/local/bin/{{ item }} state: absent with_items: - kube-scheduler - kube-controller-manager - kube-apiserver - etcd - etcdctl - name: Delete the systemd service files file: path: /etc/systemd/system/{{ item }} state: absent with_items: - etcd.service - kube-apiserver.service - kube-controller-manager.service - kube-scheduler.service - name: Delete the config and TLS files file: path: "{{ item }}" state: absent with_items: - "/var/lib/kubernetes" - "/var/lib/kubelet" - "/etc/etcd" - "/etc/kubernetes" - "/home/ansible/admin.kubeconfig" - name: Remove the cryptographic files from this host hosts: localhost become: true tasks: - name: Remove kubernetes directory file: path: /var/tmp/kubernetes state: absent - name: Remove cfssl and cfssljson files file: path: /usr/local/bin/{{ item }} state: absent with_items: - cfssl - cfssljson