You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

149 lines
3.6 KiB

7 years ago
7 years ago
7 years ago
  1. ---
  2. - name: reset | stop services
  3. service:
  4. name: "{{ item }}"
  5. state: stopped
  6. with_items:
  7. - kubelet
  8. - etcd
  9. failed_when: false
  10. tags: ['services']
  11. - name: reset | remove services
  12. file:
  13. path: "/etc/systemd/system/{{ item }}.service"
  14. state: absent
  15. with_items:
  16. - kubelet
  17. - etcd
  18. - vault
  19. - calico-node
  20. register: services_removed
  21. tags: ['services']
  22. - name: reset | remove docker dropins
  23. file:
  24. path: "/etc/systemd/system/docker.service.d/{{ item }}"
  25. state: absent
  26. with_items:
  27. - docker-dns.conf
  28. - docker-options.conf
  29. register: docker_dropins_removed
  30. tags: ['docker']
  31. - name: reset | systemctl daemon-reload
  32. command: systemctl daemon-reload
  33. when: services_removed.changed or docker_dropins_removed.changed
  34. - name: reset | remove all containers
  35. shell: "{{ docker_bin_dir }}/docker ps -aq | xargs -r docker rm -fv"
  36. register: remove_all_containers
  37. retries: 4
  38. until: remove_all_containers.rc == 0
  39. delay: 5
  40. tags: ['docker']
  41. - name: reset | restart docker if needed
  42. service:
  43. name: docker
  44. state: restarted
  45. when: docker_dropins_removed.changed
  46. tags: ['docker']
  47. - name: reset | gather mounted kubelet dirs
  48. shell: mount | grep /var/lib/kubelet | awk '{print $3}' | tac
  49. check_mode: no
  50. register: mounted_dirs
  51. tags: ['mounts']
  52. - name: reset | unmount kubelet dirs
  53. command: umount {{item}}
  54. with_items: '{{ mounted_dirs.stdout_lines }}'
  55. tags: ['mounts']
  56. - name: flush iptables
  57. iptables:
  58. flush: yes
  59. when: flush_iptables|bool
  60. tags: ['iptables']
  61. - name: reset | delete some files and directories
  62. file:
  63. path: "{{ item }}"
  64. state: absent
  65. with_items:
  66. - "{{kube_config_dir}}"
  67. - /var/lib/kubelet
  68. - /root/.kube
  69. - "{{ etcd_data_dir }}"
  70. - /etc/ssl/etcd
  71. - /var/log/calico
  72. - /etc/cni
  73. - /etc/nginx
  74. - /etc/dnsmasq.d
  75. - /etc/dnsmasq.conf
  76. - /etc/dnsmasq.d-available
  77. - /etc/etcd.env
  78. - /etc/calico
  79. - /etc/weave.env
  80. - /opt/cni
  81. - /etc/dhcp/dhclient.d/zdnsupdate.sh
  82. - /etc/dhcp/dhclient-exit-hooks.d/zdnsupdate
  83. - /run/flannel
  84. - /etc/flannel
  85. - /run/kubernetes
  86. - /usr/local/share/ca-certificates/etcd-ca.crt
  87. - /usr/local/share/ca-certificates/kube-ca.crt
  88. - /usr/local/share/ca-certificates/vault-ca.crt
  89. - /etc/ssl/certs/etcd-ca.pem
  90. - /etc/ssl/certs/kube-ca.pem
  91. - /etc/ssl/certs/vault-ca.crt
  92. - /etc/pki/ca-trust/source/anchors/etcd-ca.crt
  93. - /etc/pki/ca-trust/source/anchors/kube-ca.crt
  94. - /etc/pki/ca-trust/source/anchors/vault-ca.crt
  95. - /etc/vault
  96. - /var/log/pods/
  97. - "{{ bin_dir }}/kubelet"
  98. - "{{ bin_dir }}/etcd-scripts"
  99. - "{{ bin_dir }}/etcd"
  100. - "{{ bin_dir }}/etcdctl"
  101. - "{{ bin_dir }}/kubernetes-scripts"
  102. - "{{ bin_dir }}/kubectl"
  103. - "{{ bin_dir }}/kubeadm"
  104. - "{{ bin_dir }}/helm"
  105. - "{{ bin_dir }}/calicoctl"
  106. - "{{ bin_dir }}/weave"
  107. tags: ['files']
  108. - name: reset | remove dns settings from dhclient.conf
  109. blockinfile:
  110. dest: "{{ item }}"
  111. state: absent
  112. follow: yes
  113. marker: "# Ansible entries {mark}"
  114. failed_when: false
  115. with_items:
  116. - /etc/dhclient.conf
  117. - /etc/dhcp/dhclient.conf
  118. tags: ['files', 'dns']
  119. - name: reset | remove host entries from /etc/hosts
  120. blockinfile:
  121. dest: "/etc/hosts"
  122. state: absent
  123. follow: yes
  124. marker: "# Ansible inventory hosts {mark}"
  125. tags: ['files', 'dns']
  126. - name: reset | Restart network
  127. service:
  128. name: >-
  129. {% if ansible_os_family == "RedHat" -%}
  130. network
  131. {%- elif ansible_os_family == "Debian" -%}
  132. networking
  133. {%- endif %}
  134. state: restarted
  135. when: ansible_os_family not in ["CoreOS", "Container Linux by CoreOS"]
  136. tags: ['services', 'network']