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.

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