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.

153 lines
3.7 KiB

  1. ---
  2. - name: Validate-container-engine | check if fedora coreos
  3. stat:
  4. path: /run/ostree-booted
  5. get_attributes: false
  6. get_checksum: false
  7. get_mime: false
  8. register: ostree
  9. tags:
  10. - facts
  11. - name: Validate-container-engine | set is_ostree
  12. set_fact:
  13. is_ostree: "{{ ostree.stat.exists }}"
  14. tags:
  15. - facts
  16. - name: Ensure kubelet systemd unit exists
  17. stat:
  18. path: "/etc/systemd/system/kubelet.service"
  19. register: kubelet_systemd_unit_exists
  20. tags:
  21. - facts
  22. - name: Populate service facts
  23. service_facts:
  24. tags:
  25. - facts
  26. - name: Check if containerd is installed
  27. find:
  28. file_type: file
  29. recurse: true
  30. use_regex: true
  31. patterns:
  32. - containerd.service$
  33. paths:
  34. - /lib/systemd
  35. - /etc/systemd
  36. - /run/systemd
  37. register: containerd_installed
  38. tags:
  39. - facts
  40. - name: Check if docker is installed
  41. find:
  42. file_type: file
  43. recurse: true
  44. use_regex: true
  45. patterns:
  46. - docker.service$
  47. paths:
  48. - /lib/systemd
  49. - /etc/systemd
  50. - /run/systemd
  51. register: docker_installed
  52. tags:
  53. - facts
  54. - name: Check if crio is installed
  55. find:
  56. file_type: file
  57. recurse: true
  58. use_regex: true
  59. patterns:
  60. - crio.service$
  61. paths:
  62. - /lib/systemd
  63. - /etc/systemd
  64. - /run/systemd
  65. register: crio_installed
  66. tags:
  67. - facts
  68. - name: Uninstall containerd
  69. vars:
  70. service_name: containerd.service
  71. when:
  72. - not (is_ostree or (ansible_distribution == "Flatcar Container Linux by Kinvolk") or (ansible_distribution == "Flatcar"))
  73. - container_manager != "containerd"
  74. - docker_installed.matched == 0
  75. - containerd_installed.matched > 0
  76. - ansible_facts.services[service_name]['state'] == 'running'
  77. block:
  78. - name: Drain node
  79. include_role:
  80. name: remove-node/pre-remove
  81. apply:
  82. tags:
  83. - pre-remove
  84. when: kubelet_systemd_unit_exists.stat.exists
  85. - name: Stop kubelet
  86. service:
  87. name: kubelet
  88. state: stopped
  89. when: kubelet_systemd_unit_exists.stat.exists
  90. - name: Remove Containerd
  91. import_role:
  92. name: container-engine/containerd
  93. tasks_from: reset
  94. handlers_from: reset
  95. - name: Uninstall docker
  96. vars:
  97. service_name: docker.service
  98. when:
  99. - not (is_ostree or (ansible_distribution == "Flatcar Container Linux by Kinvolk") or (ansible_distribution == "Flatcar"))
  100. - container_manager != "docker"
  101. - docker_installed.matched > 0
  102. - ansible_facts.services[service_name]['state'] == 'running'
  103. block:
  104. - name: Drain node
  105. include_role:
  106. name: remove-node/pre-remove
  107. apply:
  108. tags:
  109. - pre-remove
  110. when: kubelet_systemd_unit_exists.stat.exists
  111. - name: Stop kubelet
  112. service:
  113. name: kubelet
  114. state: stopped
  115. when: kubelet_systemd_unit_exists.stat.exists
  116. - name: Remove Docker
  117. import_role:
  118. name: container-engine/docker
  119. tasks_from: reset
  120. - name: Uninstall crio
  121. vars:
  122. service_name: crio.service
  123. when:
  124. - not (is_ostree or (ansible_distribution == "Flatcar Container Linux by Kinvolk") or (ansible_distribution == "Flatcar"))
  125. - container_manager != "crio"
  126. - crio_installed.matched > 0
  127. - ansible_facts.services[service_name]['state'] == 'running'
  128. block:
  129. - name: Drain node
  130. include_role:
  131. name: remove-node/pre-remove
  132. apply:
  133. tags:
  134. - pre-remove
  135. when: kubelet_systemd_unit_exists.stat.exists
  136. - name: Stop kubelet
  137. service:
  138. name: kubelet
  139. state: stopped
  140. when: kubelet_systemd_unit_exists.stat.exists
  141. - name: Remove CRI-O
  142. import_role:
  143. name: container-engine/cri-o
  144. tasks_from: reset