2022-02-28 18:59:46 +00:00
|
|
|
---
|
2022-03-17 13:49:20 +00: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
|
|
|
|
|
|
|
|
- name: validate-container-engine | set is_ostree
|
|
|
|
set_fact:
|
|
|
|
is_ostree: "{{ ostree.stat.exists }}"
|
|
|
|
|
2022-02-28 18:59:46 +00:00
|
|
|
- name: Ensure kubelet systemd unit exists
|
|
|
|
stat:
|
|
|
|
path: "/etc/systemd/system/kubelet.service"
|
|
|
|
register: kubelet_systemd_unit_exists
|
|
|
|
|
|
|
|
- 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
|
|
|
|
|
|
|
|
- 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
|
|
|
|
|
|
|
|
- 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
|
|
|
|
|
|
|
|
- name: Uninstall containerd
|
|
|
|
block:
|
|
|
|
- name: Drain node
|
|
|
|
include_role:
|
|
|
|
name: remove-node/pre-remove
|
|
|
|
apply:
|
|
|
|
tags:
|
|
|
|
- pre-remove
|
Fix the condition of drain on pre-remove task (#8634)
When running cluster.yml for new machines what containerd is already
install but Kubernetes cluster were not installed before, the task
"remove-node | List nodes" is failed like
"changed": false,
"cmd": [
"/usr/local/bin/kubectl", "--kubeconfig",
"/etc/kubernetes/admin.conf", "get", "nodes", "-o",
"go-template={{ range .items }}{{ .metadata.name }}
{{ "\n" }}{{ end }}"
],
..
"stderr": "error: stat /etc/kubernetes/admin.conf: no such file or directory",
That was due to lack to check the existing Kubernetes cluster exists
or not before running "kubectl drain" command.
This adds the check to avoid the issue.
2022-03-21 08:39:10 +00:00
|
|
|
when:
|
|
|
|
- kubelet_systemd_unit_exists
|
2022-02-28 18:59:46 +00:00
|
|
|
- name: Stop kubelet
|
|
|
|
service:
|
|
|
|
name: kubelet
|
|
|
|
state: stopped
|
|
|
|
when:
|
|
|
|
- kubelet_systemd_unit_exists
|
|
|
|
- name: Remove Containerd
|
|
|
|
include_role:
|
|
|
|
name: container-engine/containerd
|
|
|
|
apply:
|
|
|
|
tags:
|
|
|
|
- reset_containerd
|
|
|
|
when:
|
2022-03-17 13:49:20 +00:00
|
|
|
- not (is_ostree or (ansible_distribution == "Flatcar Container Linux by Kinvolk") or (ansible_distribution == "Flatcar"))
|
2022-02-28 18:59:46 +00:00
|
|
|
- container_manager != "containerd"
|
|
|
|
- docker_installed.matched == 0
|
|
|
|
- containerd_installed.matched > 0
|
|
|
|
|
|
|
|
- name: Uninstall docker
|
|
|
|
block:
|
|
|
|
- name: Drain node
|
|
|
|
include_role:
|
|
|
|
name: remove-node/pre-remove
|
|
|
|
apply:
|
|
|
|
tags:
|
|
|
|
- pre-remove
|
Fix the condition of drain on pre-remove task (#8634)
When running cluster.yml for new machines what containerd is already
install but Kubernetes cluster were not installed before, the task
"remove-node | List nodes" is failed like
"changed": false,
"cmd": [
"/usr/local/bin/kubectl", "--kubeconfig",
"/etc/kubernetes/admin.conf", "get", "nodes", "-o",
"go-template={{ range .items }}{{ .metadata.name }}
{{ "\n" }}{{ end }}"
],
..
"stderr": "error: stat /etc/kubernetes/admin.conf: no such file or directory",
That was due to lack to check the existing Kubernetes cluster exists
or not before running "kubectl drain" command.
This adds the check to avoid the issue.
2022-03-21 08:39:10 +00:00
|
|
|
when:
|
|
|
|
- kubelet_systemd_unit_exists
|
2022-02-28 18:59:46 +00:00
|
|
|
- name: Stop kubelet
|
|
|
|
service:
|
|
|
|
name: kubelet
|
|
|
|
state: stopped
|
|
|
|
when:
|
|
|
|
- kubelet_systemd_unit_exists
|
|
|
|
- name: Remove Docker
|
|
|
|
include_role:
|
|
|
|
name: container-engine/docker
|
|
|
|
apply:
|
|
|
|
tags:
|
|
|
|
- reset_docker
|
|
|
|
when:
|
2022-03-17 13:49:20 +00:00
|
|
|
- not (is_ostree or (ansible_distribution == "Flatcar Container Linux by Kinvolk") or (ansible_distribution == "Flatcar"))
|
2022-02-28 18:59:46 +00:00
|
|
|
- container_manager != "docker"
|
|
|
|
- docker_installed.matched > 0
|
|
|
|
|
|
|
|
- name: Uninstall crio
|
|
|
|
block:
|
|
|
|
- name: Drain node
|
|
|
|
include_role:
|
|
|
|
name: remove-node/pre-remove
|
|
|
|
apply:
|
|
|
|
tags:
|
|
|
|
- pre-remove
|
Fix the condition of drain on pre-remove task (#8634)
When running cluster.yml for new machines what containerd is already
install but Kubernetes cluster were not installed before, the task
"remove-node | List nodes" is failed like
"changed": false,
"cmd": [
"/usr/local/bin/kubectl", "--kubeconfig",
"/etc/kubernetes/admin.conf", "get", "nodes", "-o",
"go-template={{ range .items }}{{ .metadata.name }}
{{ "\n" }}{{ end }}"
],
..
"stderr": "error: stat /etc/kubernetes/admin.conf: no such file or directory",
That was due to lack to check the existing Kubernetes cluster exists
or not before running "kubectl drain" command.
This adds the check to avoid the issue.
2022-03-21 08:39:10 +00:00
|
|
|
when:
|
|
|
|
- kubelet_systemd_unit_exists
|
2022-02-28 18:59:46 +00:00
|
|
|
- name: Stop kubelet
|
|
|
|
service:
|
|
|
|
name: kubelet
|
|
|
|
state: stopped
|
|
|
|
when:
|
|
|
|
- kubelet_systemd_unit_exists
|
|
|
|
- name: Remove CRI-O
|
|
|
|
include_role:
|
|
|
|
name: container-engine/crio
|
|
|
|
apply:
|
|
|
|
tags:
|
|
|
|
- reset_crio
|
|
|
|
when:
|
2022-03-17 13:49:20 +00:00
|
|
|
- not (is_ostree or (ansible_distribution == "Flatcar Container Linux by Kinvolk") or (ansible_distribution == "Flatcar"))
|
2022-02-28 18:59:46 +00:00
|
|
|
- container_manager != "crio"
|
|
|
|
- crio_installed.matched > 0
|