2016-12-08 00:36:24 +08:00
|
|
|
---
|
|
|
|
|
|
|
|
- name: reset | stop services
|
2017-02-18 05:22:34 +08:00
|
|
|
service:
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: stopped
|
2016-12-08 00:36:24 +08:00
|
|
|
with_items:
|
|
|
|
- kubelet
|
2017-10-03 15:30:28 +08:00
|
|
|
- vault
|
2016-12-08 00:36:24 +08:00
|
|
|
- etcd
|
|
|
|
failed_when: false
|
2017-10-05 15:43:04 +08:00
|
|
|
tags:
|
|
|
|
- services
|
2016-12-08 00:36:24 +08:00
|
|
|
|
|
|
|
- name: reset | remove services
|
2016-12-09 23:33:10 +08:00
|
|
|
file:
|
|
|
|
path: "/etc/systemd/system/{{ item }}.service"
|
|
|
|
state: absent
|
2016-12-08 00:36:24 +08:00
|
|
|
with_items:
|
|
|
|
- kubelet
|
|
|
|
- etcd
|
2017-08-30 21:03:22 +08:00
|
|
|
- vault
|
2017-08-31 17:00:05 +08:00
|
|
|
- calico-node
|
2016-12-08 00:36:24 +08:00
|
|
|
register: services_removed
|
2017-10-05 15:43:04 +08:00
|
|
|
tags:
|
|
|
|
- services
|
2016-12-08 00:36:24 +08:00
|
|
|
|
2016-12-22 00:18:11 +08:00
|
|
|
- name: reset | remove docker dropins
|
|
|
|
file:
|
|
|
|
path: "/etc/systemd/system/docker.service.d/{{ item }}"
|
|
|
|
state: absent
|
|
|
|
with_items:
|
|
|
|
- docker-dns.conf
|
|
|
|
- docker-options.conf
|
|
|
|
register: docker_dropins_removed
|
2017-10-05 15:43:04 +08:00
|
|
|
tags:
|
|
|
|
- docker
|
2016-12-22 00:18:11 +08:00
|
|
|
|
2016-12-08 00:36:24 +08:00
|
|
|
- name: reset | systemctl daemon-reload
|
|
|
|
command: systemctl daemon-reload
|
2016-12-22 00:18:11 +08:00
|
|
|
when: services_removed.changed or docker_dropins_removed.changed
|
2016-12-08 00:36:24 +08:00
|
|
|
|
|
|
|
- name: reset | remove all containers
|
2016-12-23 22:44:44 +08:00
|
|
|
shell: "{{ docker_bin_dir }}/docker ps -aq | xargs -r docker rm -fv"
|
2017-09-06 19:23:16 +08:00
|
|
|
register: remove_all_containers
|
|
|
|
retries: 4
|
|
|
|
until: remove_all_containers.rc == 0
|
|
|
|
delay: 5
|
2017-10-05 15:43:04 +08:00
|
|
|
tags:
|
|
|
|
- docker
|
2016-12-08 00:36:24 +08:00
|
|
|
|
2016-12-22 00:18:11 +08:00
|
|
|
- name: reset | restart docker if needed
|
2017-02-18 05:22:34 +08:00
|
|
|
service:
|
|
|
|
name: docker
|
|
|
|
state: restarted
|
2016-12-22 00:18:11 +08:00
|
|
|
when: docker_dropins_removed.changed
|
2017-10-05 15:43:04 +08:00
|
|
|
tags:
|
|
|
|
- docker
|
2016-12-22 00:18:11 +08:00
|
|
|
|
2016-12-08 00:36:24 +08:00
|
|
|
- name: reset | gather mounted kubelet dirs
|
2016-12-13 21:21:24 +08:00
|
|
|
shell: mount | grep /var/lib/kubelet | awk '{print $3}' | tac
|
2017-02-07 02:13:21 +08:00
|
|
|
check_mode: no
|
2016-12-08 00:36:24 +08:00
|
|
|
register: mounted_dirs
|
2017-10-05 15:43:04 +08:00
|
|
|
tags:
|
|
|
|
- mounts
|
2016-12-08 00:36:24 +08:00
|
|
|
|
|
|
|
- name: reset | unmount kubelet dirs
|
|
|
|
command: umount {{item}}
|
2016-12-13 21:21:24 +08:00
|
|
|
with_items: '{{ mounted_dirs.stdout_lines }}'
|
2017-10-05 15:43:04 +08:00
|
|
|
tags:
|
|
|
|
- mounts
|
2016-12-08 00:36:24 +08:00
|
|
|
|
2017-03-21 17:13:54 +08:00
|
|
|
- name: flush iptables
|
|
|
|
iptables:
|
|
|
|
flush: yes
|
2017-04-18 22:15:22 +08:00
|
|
|
when: flush_iptables|bool
|
2017-10-05 15:43:04 +08:00
|
|
|
tags:
|
|
|
|
- iptables
|
2017-03-21 17:13:54 +08:00
|
|
|
|
2016-12-08 00:36:24 +08:00
|
|
|
- name: reset | delete some files and directories
|
2017-02-18 05:22:34 +08:00
|
|
|
file:
|
|
|
|
path: "{{ item }}"
|
|
|
|
state: absent
|
2016-12-08 00:36:24 +08:00
|
|
|
with_items:
|
2016-12-13 18:43:06 +08:00
|
|
|
- "{{kube_config_dir}}"
|
2016-12-08 00:36:24 +08:00
|
|
|
- /var/lib/kubelet
|
2017-09-26 17:38:58 +08:00
|
|
|
- /root/.kube
|
2017-11-28 15:30:27 +08:00
|
|
|
- /root/.helm
|
2017-02-24 22:58:54 +08:00
|
|
|
- "{{ etcd_data_dir }}"
|
2016-12-09 23:33:10 +08:00
|
|
|
- /etc/ssl/etcd
|
|
|
|
- /var/log/calico
|
|
|
|
- /etc/cni
|
|
|
|
- /etc/nginx
|
|
|
|
- /etc/dnsmasq.d
|
2016-12-22 00:18:11 +08:00
|
|
|
- /etc/dnsmasq.conf
|
|
|
|
- /etc/dnsmasq.d-available
|
2016-12-09 23:33:10 +08:00
|
|
|
- /etc/etcd.env
|
|
|
|
- /etc/calico
|
2017-06-29 11:44:52 +08:00
|
|
|
- /etc/weave.env
|
2016-12-09 23:33:10 +08:00
|
|
|
- /opt/cni
|
2016-12-22 00:18:11 +08:00
|
|
|
- /etc/dhcp/dhclient.d/zdnsupdate.sh
|
|
|
|
- /etc/dhcp/dhclient-exit-hooks.d/zdnsupdate
|
2017-06-29 14:45:15 +08:00
|
|
|
- /run/flannel
|
|
|
|
- /etc/flannel
|
|
|
|
- /run/kubernetes
|
|
|
|
- /usr/local/share/ca-certificates/etcd-ca.crt
|
2017-08-30 21:03:22 +08:00
|
|
|
- /usr/local/share/ca-certificates/kube-ca.crt
|
|
|
|
- /usr/local/share/ca-certificates/vault-ca.crt
|
2017-06-29 14:45:15 +08:00
|
|
|
- /etc/ssl/certs/etcd-ca.pem
|
2017-08-30 21:03:22 +08:00
|
|
|
- /etc/ssl/certs/kube-ca.pem
|
|
|
|
- /etc/ssl/certs/vault-ca.crt
|
|
|
|
- /etc/pki/ca-trust/source/anchors/etcd-ca.crt
|
|
|
|
- /etc/pki/ca-trust/source/anchors/kube-ca.crt
|
|
|
|
- /etc/pki/ca-trust/source/anchors/vault-ca.crt
|
2017-08-20 18:53:58 +08:00
|
|
|
- /etc/vault
|
2017-06-29 14:45:15 +08:00
|
|
|
- /var/log/pods/
|
2017-06-29 11:44:52 +08:00
|
|
|
- "{{ bin_dir }}/kubelet"
|
|
|
|
- "{{ bin_dir }}/etcd-scripts"
|
|
|
|
- "{{ bin_dir }}/etcd"
|
|
|
|
- "{{ bin_dir }}/etcdctl"
|
|
|
|
- "{{ bin_dir }}/kubernetes-scripts"
|
|
|
|
- "{{ bin_dir }}/kubectl"
|
2017-09-16 05:28:15 +08:00
|
|
|
- "{{ bin_dir }}/kubeadm"
|
2017-06-29 11:44:52 +08:00
|
|
|
- "{{ bin_dir }}/helm"
|
|
|
|
- "{{ bin_dir }}/calicoctl"
|
|
|
|
- "{{ bin_dir }}/weave"
|
2017-12-11 20:49:21 +08:00
|
|
|
- /var/lib/rkt
|
|
|
|
- /etc/vault
|
|
|
|
ignore_errors: yes
|
2017-10-05 15:43:04 +08:00
|
|
|
tags:
|
|
|
|
- files
|
2017-04-18 22:15:22 +08:00
|
|
|
|
2016-12-22 00:18:11 +08:00
|
|
|
- name: reset | remove dns settings from dhclient.conf
|
|
|
|
blockinfile:
|
|
|
|
dest: "{{ item }}"
|
|
|
|
state: absent
|
|
|
|
follow: yes
|
|
|
|
marker: "# Ansible entries {mark}"
|
|
|
|
failed_when: false
|
|
|
|
with_items:
|
|
|
|
- /etc/dhclient.conf
|
|
|
|
- /etc/dhcp/dhclient.conf
|
2017-10-05 15:43:04 +08:00
|
|
|
tags:
|
|
|
|
- files
|
|
|
|
- dns
|
2016-12-22 00:18:11 +08:00
|
|
|
|
|
|
|
- name: reset | remove host entries from /etc/hosts
|
|
|
|
blockinfile:
|
|
|
|
dest: "/etc/hosts"
|
|
|
|
state: absent
|
|
|
|
follow: yes
|
|
|
|
marker: "# Ansible inventory hosts {mark}"
|
2017-10-05 15:43:04 +08:00
|
|
|
tags:
|
|
|
|
- files
|
|
|
|
- dns
|
2016-12-22 00:18:11 +08:00
|
|
|
|
2017-12-06 22:15:40 +08:00
|
|
|
- name: reset | check cni network device
|
|
|
|
stat:
|
|
|
|
path: /sys/class/net/cni0
|
|
|
|
register: cni
|
|
|
|
when: kube_network_plugin == 'flannel'
|
|
|
|
tags:
|
|
|
|
- flannel
|
|
|
|
|
|
|
|
- name: reset | remove the network device created by the flannel
|
|
|
|
command: ip link del cni0
|
|
|
|
when: kube_network_plugin == 'flannel' and cni.stat.exists
|
|
|
|
tags:
|
|
|
|
- flannel
|
|
|
|
|
|
|
|
- name: reset | check flannel network device
|
|
|
|
stat:
|
|
|
|
path: /sys/class/net/flannel.1
|
|
|
|
register: flannel
|
|
|
|
when: kube_network_plugin == 'flannel'
|
|
|
|
tags:
|
|
|
|
- flannel
|
|
|
|
|
|
|
|
- name: reset | remove the network device created by the flannel
|
|
|
|
command: ip link del flannel.1
|
|
|
|
when: kube_network_plugin == 'flannel' and flannel.stat.exists
|
|
|
|
tags:
|
|
|
|
- flannel
|
|
|
|
|
2016-12-22 00:18:11 +08:00
|
|
|
- name: reset | Restart network
|
|
|
|
service:
|
|
|
|
name: >-
|
|
|
|
{% if ansible_os_family == "RedHat" -%}
|
|
|
|
network
|
|
|
|
{%- elif ansible_os_family == "Debian" -%}
|
|
|
|
networking
|
|
|
|
{%- endif %}
|
|
|
|
state: restarted
|
2017-02-17 00:25:03 +08:00
|
|
|
when: ansible_os_family not in ["CoreOS", "Container Linux by CoreOS"]
|
2017-10-05 15:43:04 +08:00
|
|
|
tags:
|
|
|
|
- services
|
|
|
|
- network
|