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.

105 lines
2.4 KiB

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