2022-03-01 02:59:46 +08:00
|
|
|
---
|
2022-03-17 21:49:20 +08:00
|
|
|
- name: validate-container-engine | check if fedora coreos
|
|
|
|
stat:
|
|
|
|
path: /run/ostree-booted
|
|
|
|
get_attributes: no
|
|
|
|
get_checksum: no
|
|
|
|
get_mime: no
|
|
|
|
register: ostree
|
2022-04-04 15:32:11 +08:00
|
|
|
tags:
|
|
|
|
- facts
|
2022-03-17 21:49:20 +08:00
|
|
|
|
|
|
|
- name: validate-container-engine | set is_ostree
|
|
|
|
set_fact:
|
|
|
|
is_ostree: "{{ ostree.stat.exists }}"
|
2022-04-04 15:32:11 +08:00
|
|
|
tags:
|
|
|
|
- facts
|
2022-03-17 21:49:20 +08:00
|
|
|
|
2022-03-01 02:59:46 +08:00
|
|
|
- name: Ensure kubelet systemd unit exists
|
|
|
|
stat:
|
|
|
|
path: "/etc/systemd/system/kubelet.service"
|
|
|
|
register: kubelet_systemd_unit_exists
|
2022-04-04 15:32:11 +08:00
|
|
|
tags:
|
|
|
|
- facts
|
2022-03-01 02:59:46 +08:00
|
|
|
|
2022-04-02 00:20:46 +08:00
|
|
|
- name: Populate service facts
|
|
|
|
service_facts:
|
2022-04-04 15:32:11 +08:00
|
|
|
tags:
|
|
|
|
- facts
|
2022-04-02 00:20:46 +08:00
|
|
|
|
2022-03-01 02:59:46 +08:00
|
|
|
- name: Check if containerd is installed
|
|
|
|
find:
|
|
|
|
file_type: file
|
|
|
|
recurse: yes
|
|
|
|
use_regex: yes
|
|
|
|
patterns:
|
|
|
|
- containerd.service$
|
|
|
|
paths:
|
|
|
|
- /lib/systemd
|
|
|
|
- /etc/systemd
|
|
|
|
- /run/systemd
|
|
|
|
register: containerd_installed
|
2022-04-04 15:32:11 +08:00
|
|
|
tags:
|
|
|
|
- facts
|
2022-03-01 02:59:46 +08:00
|
|
|
|
|
|
|
- name: Check if docker is installed
|
|
|
|
find:
|
|
|
|
file_type: file
|
|
|
|
recurse: yes
|
|
|
|
use_regex: yes
|
|
|
|
patterns:
|
|
|
|
- docker.service$
|
|
|
|
paths:
|
|
|
|
- /lib/systemd
|
|
|
|
- /etc/systemd
|
|
|
|
- /run/systemd
|
|
|
|
register: docker_installed
|
2022-04-04 15:32:11 +08:00
|
|
|
tags:
|
|
|
|
- facts
|
2022-03-01 02:59:46 +08:00
|
|
|
|
|
|
|
- name: Check if crio is installed
|
|
|
|
find:
|
|
|
|
file_type: file
|
|
|
|
recurse: yes
|
|
|
|
use_regex: yes
|
|
|
|
patterns:
|
|
|
|
- crio.service$
|
|
|
|
paths:
|
|
|
|
- /lib/systemd
|
|
|
|
- /etc/systemd
|
|
|
|
- /run/systemd
|
|
|
|
register: crio_installed
|
2022-04-04 15:32:11 +08:00
|
|
|
tags:
|
|
|
|
- facts
|
2022-03-01 02:59:46 +08:00
|
|
|
|
|
|
|
- name: Uninstall containerd
|
|
|
|
block:
|
|
|
|
- name: Drain node
|
|
|
|
include_role:
|
|
|
|
name: remove-node/pre-remove
|
|
|
|
apply:
|
|
|
|
tags:
|
|
|
|
- pre-remove
|
2022-04-05 00:34:12 +08:00
|
|
|
when: kubelet_systemd_unit_exists.stat.exists
|
2022-03-01 02:59:46 +08:00
|
|
|
- name: Stop kubelet
|
|
|
|
service:
|
|
|
|
name: kubelet
|
|
|
|
state: stopped
|
2022-04-05 00:34:12 +08:00
|
|
|
when: kubelet_systemd_unit_exists.stat.exists
|
2022-03-01 02:59:46 +08:00
|
|
|
- name: Remove Containerd
|
2022-04-02 00:20:46 +08:00
|
|
|
import_role:
|
2022-03-01 02:59:46 +08:00
|
|
|
name: container-engine/containerd
|
2022-04-02 00:20:46 +08:00
|
|
|
tasks_from: reset
|
|
|
|
vars:
|
|
|
|
service_name: containerd.service
|
2022-03-01 02:59:46 +08:00
|
|
|
when:
|
2022-03-17 21:49:20 +08:00
|
|
|
- not (is_ostree or (ansible_distribution == "Flatcar Container Linux by Kinvolk") or (ansible_distribution == "Flatcar"))
|
2022-03-01 02:59:46 +08:00
|
|
|
- container_manager != "containerd"
|
|
|
|
- docker_installed.matched == 0
|
|
|
|
- containerd_installed.matched > 0
|
2022-04-02 00:20:46 +08:00
|
|
|
- ansible_facts.services[service_name]['state'] == 'running'
|
2022-03-01 02:59:46 +08:00
|
|
|
|
|
|
|
- name: Uninstall docker
|
|
|
|
block:
|
|
|
|
- name: Drain node
|
|
|
|
include_role:
|
|
|
|
name: remove-node/pre-remove
|
|
|
|
apply:
|
|
|
|
tags:
|
|
|
|
- pre-remove
|
2022-04-05 00:34:12 +08:00
|
|
|
when: kubelet_systemd_unit_exists.stat.exists
|
2022-03-01 02:59:46 +08:00
|
|
|
- name: Stop kubelet
|
|
|
|
service:
|
|
|
|
name: kubelet
|
|
|
|
state: stopped
|
2022-04-05 00:34:12 +08:00
|
|
|
when: kubelet_systemd_unit_exists.stat.exists
|
2022-03-01 02:59:46 +08:00
|
|
|
- name: Remove Docker
|
2022-04-02 00:20:46 +08:00
|
|
|
import_role:
|
2022-03-01 02:59:46 +08:00
|
|
|
name: container-engine/docker
|
2022-04-02 00:20:46 +08:00
|
|
|
tasks_from: reset
|
|
|
|
vars:
|
|
|
|
service_name: docker.service
|
2022-03-01 02:59:46 +08:00
|
|
|
when:
|
2022-03-17 21:49:20 +08:00
|
|
|
- not (is_ostree or (ansible_distribution == "Flatcar Container Linux by Kinvolk") or (ansible_distribution == "Flatcar"))
|
2022-03-01 02:59:46 +08:00
|
|
|
- container_manager != "docker"
|
|
|
|
- docker_installed.matched > 0
|
2022-04-02 00:20:46 +08:00
|
|
|
- ansible_facts.services[service_name]['state'] == 'running'
|
2022-03-01 02:59:46 +08:00
|
|
|
|
|
|
|
- name: Uninstall crio
|
|
|
|
block:
|
|
|
|
- name: Drain node
|
|
|
|
include_role:
|
|
|
|
name: remove-node/pre-remove
|
|
|
|
apply:
|
|
|
|
tags:
|
|
|
|
- pre-remove
|
2022-04-05 00:34:12 +08:00
|
|
|
when: kubelet_systemd_unit_exists.stat.exists
|
2022-03-01 02:59:46 +08:00
|
|
|
- name: Stop kubelet
|
|
|
|
service:
|
|
|
|
name: kubelet
|
|
|
|
state: stopped
|
2022-04-05 00:34:12 +08:00
|
|
|
when: kubelet_systemd_unit_exists.stat.exists
|
2022-03-01 02:59:46 +08:00
|
|
|
- name: Remove CRI-O
|
2022-04-02 00:20:46 +08:00
|
|
|
import_role:
|
|
|
|
name: container-engine/cri-o
|
|
|
|
tasks_from: reset
|
|
|
|
vars:
|
|
|
|
service_name: crio.service
|
2022-03-01 02:59:46 +08:00
|
|
|
when:
|
2022-03-17 21:49:20 +08:00
|
|
|
- not (is_ostree or (ansible_distribution == "Flatcar Container Linux by Kinvolk") or (ansible_distribution == "Flatcar"))
|
2022-03-01 02:59:46 +08:00
|
|
|
- container_manager != "crio"
|
|
|
|
- crio_installed.matched > 0
|
2022-04-02 00:20:46 +08:00
|
|
|
- ansible_facts.services[service_name]['state'] == 'running'
|