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.

95 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. check_mode: no
  35. register: mounted_dirs
  36. - name: reset | unmount kubelet dirs
  37. command: umount {{item}}
  38. with_items: '{{ mounted_dirs.stdout_lines }}'
  39. - name: reset | delete some files and directories
  40. file: path={{ item }} state=absent
  41. with_items:
  42. - "{{kube_config_dir}}"
  43. - /var/lib/kubelet
  44. - /var/lib/etcd
  45. - /etc/ssl/etcd
  46. - /var/log/calico
  47. - /etc/cni
  48. - /etc/nginx
  49. - /etc/dnsmasq.d
  50. - /etc/dnsmasq.conf
  51. - /etc/dnsmasq.d-available
  52. - /etc/etcd.env
  53. - /etc/calico
  54. - /opt/cni
  55. - /etc/dhcp/dhclient.d/zdnsupdate.sh
  56. - /etc/dhcp/dhclient-exit-hooks.d/zdnsupdate
  57. - "{{ bin_dir }}/kubelet"
  58. - name: reset | remove dns settings from dhclient.conf
  59. blockinfile:
  60. dest: "{{ item }}"
  61. state: absent
  62. follow: yes
  63. marker: "# Ansible entries {mark}"
  64. failed_when: false
  65. with_items:
  66. - /etc/dhclient.conf
  67. - /etc/dhcp/dhclient.conf
  68. - name: reset | remove host entries from /etc/hosts
  69. blockinfile:
  70. dest: "/etc/hosts"
  71. state: absent
  72. follow: yes
  73. marker: "# Ansible inventory hosts {mark}"
  74. - name: reset | Restart network
  75. service:
  76. name: >-
  77. {% if ansible_os_family == "RedHat" -%}
  78. network
  79. {%- elif ansible_os_family == "Debian" -%}
  80. networking
  81. {%- endif %}
  82. state: restarted
  83. when: ansible_os_family not in ["CoreOS", "Container Linux by CoreOS"]