fix: uninstall contailer engine if service is running (#8662)

This commit is contained in:
cyril-corbon 2022-04-01 18:20:46 +02:00 committed by GitHub
parent 78b05d0ffc
commit 1781eab21f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -16,6 +16,9 @@
path: "/etc/systemd/system/kubelet.service" path: "/etc/systemd/system/kubelet.service"
register: kubelet_systemd_unit_exists register: kubelet_systemd_unit_exists
- name: Populate service facts
service_facts:
- name: Check if containerd is installed - name: Check if containerd is installed
find: find:
file_type: file file_type: file
@ -72,16 +75,17 @@
when: when:
- kubelet_systemd_unit_exists - kubelet_systemd_unit_exists
- name: Remove Containerd - name: Remove Containerd
include_role: import_role:
name: container-engine/containerd name: container-engine/containerd
apply: tasks_from: reset
tags: vars:
- reset_containerd service_name: containerd.service
when: when:
- not (is_ostree or (ansible_distribution == "Flatcar Container Linux by Kinvolk") or (ansible_distribution == "Flatcar")) - not (is_ostree or (ansible_distribution == "Flatcar Container Linux by Kinvolk") or (ansible_distribution == "Flatcar"))
- container_manager != "containerd" - container_manager != "containerd"
- docker_installed.matched == 0 - docker_installed.matched == 0
- containerd_installed.matched > 0 - containerd_installed.matched > 0
- ansible_facts.services[service_name]['state'] == 'running'
- name: Uninstall docker - name: Uninstall docker
block: block:
@ -100,15 +104,16 @@
when: when:
- kubelet_systemd_unit_exists - kubelet_systemd_unit_exists
- name: Remove Docker - name: Remove Docker
include_role: import_role:
name: container-engine/docker name: container-engine/docker
apply: tasks_from: reset
tags: vars:
- reset_docker service_name: docker.service
when: when:
- not (is_ostree or (ansible_distribution == "Flatcar Container Linux by Kinvolk") or (ansible_distribution == "Flatcar")) - not (is_ostree or (ansible_distribution == "Flatcar Container Linux by Kinvolk") or (ansible_distribution == "Flatcar"))
- container_manager != "docker" - container_manager != "docker"
- docker_installed.matched > 0 - docker_installed.matched > 0
- ansible_facts.services[service_name]['state'] == 'running'
- name: Uninstall crio - name: Uninstall crio
block: block:
@ -127,12 +132,13 @@
when: when:
- kubelet_systemd_unit_exists - kubelet_systemd_unit_exists
- name: Remove CRI-O - name: Remove CRI-O
include_role: import_role:
name: container-engine/crio name: container-engine/cri-o
apply: tasks_from: reset
tags: vars:
- reset_crio service_name: crio.service
when: when:
- not (is_ostree or (ansible_distribution == "Flatcar Container Linux by Kinvolk") or (ansible_distribution == "Flatcar")) - not (is_ostree or (ansible_distribution == "Flatcar Container Linux by Kinvolk") or (ansible_distribution == "Flatcar"))
- container_manager != "crio" - container_manager != "crio"
- crio_installed.matched > 0 - crio_installed.matched > 0
- ansible_facts.services[service_name]['state'] == 'running'