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.

94 lines
2.3 KiB

  1. ---
  2. - name: reset | stop services
  3. service: name={{ item }} state=stopped
  4. with_items:
  5. - kubelet
  6. - etcd
  7. failed_when: false
  8. - name: reset | remove services
  9. file:
  10. path: "/etc/systemd/system/{{ item }}.service"
  11. state: absent
  12. with_items:
  13. - kubelet
  14. - etcd
  15. register: services_removed
  16. - name: reset | remove docker dropins
  17. file:
  18. path: "/etc/systemd/system/docker.service.d/{{ item }}"
  19. state: absent
  20. with_items:
  21. - docker-dns.conf
  22. - docker-options.conf
  23. register: docker_dropins_removed
  24. - name: reset | systemctl daemon-reload
  25. command: systemctl daemon-reload
  26. when: services_removed.changed or docker_dropins_removed.changed
  27. - name: reset | remove all containers
  28. shell: "{{ docker_bin_dir }}/docker ps -aq | xargs -r docker rm -fv"
  29. - name: reset | restart docker if needed
  30. service: name=docker state=restarted
  31. when: docker_dropins_removed.changed
  32. - name: reset | gather mounted kubelet dirs
  33. shell: mount | grep /var/lib/kubelet | awk '{print $3}' | tac
  34. register: mounted_dirs
  35. - name: reset | unmount kubelet dirs
  36. command: umount {{item}}
  37. with_items: '{{ mounted_dirs.stdout_lines }}'
  38. - name: reset | delete some files and directories
  39. file: path={{ item }} state=absent
  40. with_items:
  41. - "{{kube_config_dir}}"
  42. - /var/lib/kubelet
  43. - /var/lib/etcd
  44. - /etc/ssl/etcd
  45. - /var/log/calico
  46. - /etc/cni
  47. - /etc/nginx
  48. - /etc/dnsmasq.d
  49. - /etc/dnsmasq.conf
  50. - /etc/dnsmasq.d-available
  51. - /etc/etcd.env
  52. - /etc/calico
  53. - /opt/cni
  54. - /etc/dhcp/dhclient.d/zdnsupdate.sh
  55. - /etc/dhcp/dhclient-exit-hooks.d/zdnsupdate
  56. - "{{ bin_dir }}/kubelet"
  57. - name: reset | remove dns settings from dhclient.conf
  58. blockinfile:
  59. dest: "{{ item }}"
  60. state: absent
  61. follow: yes
  62. marker: "# Ansible entries {mark}"
  63. failed_when: false
  64. with_items:
  65. - /etc/dhclient.conf
  66. - /etc/dhcp/dhclient.conf
  67. - name: reset | remove host entries from /etc/hosts
  68. blockinfile:
  69. dest: "/etc/hosts"
  70. state: absent
  71. follow: yes
  72. marker: "# Ansible inventory hosts {mark}"
  73. - name: reset | Restart network
  74. service:
  75. name: >-
  76. {% if ansible_os_family == "RedHat" -%}
  77. network
  78. {%- elif ansible_os_family == "Debian" -%}
  79. networking
  80. {%- endif %}
  81. state: restarted
  82. when: ansible_os_family != "CoreOS"