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.

148 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. - "{{ etcd_data_dir }}"
  69. - /etc/ssl/etcd
  70. - /var/log/calico
  71. - /etc/cni
  72. - /etc/nginx
  73. - /etc/dnsmasq.d
  74. - /etc/dnsmasq.conf
  75. - /etc/dnsmasq.d-available
  76. - /etc/etcd.env
  77. - /etc/calico
  78. - /etc/weave.env
  79. - /opt/cni
  80. - /etc/dhcp/dhclient.d/zdnsupdate.sh
  81. - /etc/dhcp/dhclient-exit-hooks.d/zdnsupdate
  82. - /run/flannel
  83. - /etc/flannel
  84. - /run/kubernetes
  85. - /usr/local/share/ca-certificates/etcd-ca.crt
  86. - /usr/local/share/ca-certificates/kube-ca.crt
  87. - /usr/local/share/ca-certificates/vault-ca.crt
  88. - /etc/ssl/certs/etcd-ca.pem
  89. - /etc/ssl/certs/kube-ca.pem
  90. - /etc/ssl/certs/vault-ca.crt
  91. - /etc/pki/ca-trust/source/anchors/etcd-ca.crt
  92. - /etc/pki/ca-trust/source/anchors/kube-ca.crt
  93. - /etc/pki/ca-trust/source/anchors/vault-ca.crt
  94. - /etc/vault
  95. - /var/log/pods/
  96. - "{{ bin_dir }}/kubelet"
  97. - "{{ bin_dir }}/etcd-scripts"
  98. - "{{ bin_dir }}/etcd"
  99. - "{{ bin_dir }}/etcdctl"
  100. - "{{ bin_dir }}/kubernetes-scripts"
  101. - "{{ bin_dir }}/kubectl"
  102. - "{{ bin_dir }}/kubeadm"
  103. - "{{ bin_dir }}/helm"
  104. - "{{ bin_dir }}/calicoctl"
  105. - "{{ bin_dir }}/weave"
  106. tags: ['files']
  107. - name: reset | remove dns settings from dhclient.conf
  108. blockinfile:
  109. dest: "{{ item }}"
  110. state: absent
  111. follow: yes
  112. marker: "# Ansible entries {mark}"
  113. failed_when: false
  114. with_items:
  115. - /etc/dhclient.conf
  116. - /etc/dhcp/dhclient.conf
  117. tags: ['files', 'dns']
  118. - name: reset | remove host entries from /etc/hosts
  119. blockinfile:
  120. dest: "/etc/hosts"
  121. state: absent
  122. follow: yes
  123. marker: "# Ansible inventory hosts {mark}"
  124. tags: ['files', 'dns']
  125. - name: reset | Restart network
  126. service:
  127. name: >-
  128. {% if ansible_os_family == "RedHat" -%}
  129. network
  130. {%- elif ansible_os_family == "Debian" -%}
  131. networking
  132. {%- endif %}
  133. state: restarted
  134. when: ansible_os_family not in ["CoreOS", "Container Linux by CoreOS"]
  135. tags: ['services', 'network']