-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: check & uninstall container engine
Signed-off-by: Cyril Corbon <[email protected]>
- Loading branch information
1 parent
2bbe573
commit 6b56ffb
Showing
6 changed files
with
256 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
- name: containerd | Remove containerd repository for RedHat os family | ||
file: | ||
path: "{{ yum_repo_dir }}/containerd.repo" | ||
state: absent | ||
when: | ||
- ansible_os_family in ['RedHat'] | ||
tags: | ||
- reset_containerd | ||
|
||
- name: containerd | Remove containerd repository for Debian os family | ||
apt_repository: | ||
repo: "{{ item }}" | ||
state: absent | ||
with_items: "{{ containerd_repo_info.repos }}" | ||
when: ansible_pkg_mgr == 'apt' | ||
tags: | ||
- reset_containerd | ||
|
||
- name: containerd | Stop containerd service | ||
service: | ||
name: containerd | ||
daemon_reload: true | ||
enabled: false | ||
masked: true | ||
state: stopped | ||
tags: | ||
- reset_containerd | ||
|
||
- name: containerd | Remove configuration files | ||
file: | ||
path: "{{ item }}" | ||
state: absent | ||
loop: | ||
- /etc/systemd/system/containerd.service | ||
- "{{ containerd_systemd_dir }}" | ||
- "{{ containerd_cfg_dir }}" | ||
- "{{ containerd_storage_dir }}" | ||
- "{{ containerd_state_dir }}" | ||
tags: | ||
- reset_containerd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
--- | ||
- name: CRI-O | Kubic repo name for debian os family | ||
set_fact: | ||
crio_kubic_debian_repo_name: "{{ ((ansible_distribution == 'Ubuntu') | ternary('x','')) ~ ansible_distribution ~ '_' ~ ansible_distribution_version }}" | ||
when: ansible_os_family == "Debian" | ||
tags: | ||
- reset_crio | ||
|
||
- name: CRI-O | Remove kubic apt repo | ||
apt_repository: | ||
repo: "deb http://{{ crio_download_base }}/{{ crio_kubic_debian_repo_name }}/ /" | ||
state: absent | ||
when: crio_kubic_debian_repo_name is defined | ||
tags: | ||
- reset_crio | ||
|
||
- name: CRI-O | Remove cri-o apt repo | ||
apt_repository: | ||
repo: "deb {{ crio_download_crio }}{{ crio_version }}/{{ crio_kubic_debian_repo_name }}/ /" | ||
state: present | ||
filename: devel-kubic-libcontainers-stable-cri-o | ||
when: crio_kubic_debian_repo_name is defined | ||
tags: | ||
- reset_crio | ||
|
||
- name: CRI-O | Remove CRI-O kubic yum repo | ||
yum_repository: | ||
name: devel_kubic_libcontainers_stable | ||
state: absent | ||
when: ansible_distribution in ["Amazon"] | ||
tags: | ||
- reset_crio | ||
|
||
- name: CRI-O | Remove CRI-O kubic yum repo | ||
yum_repository: | ||
name: "devel_kubic_libcontainers_stable_cri-o_{{ crio_version }}" | ||
state: absent | ||
when: | ||
- ansible_os_family == "RedHat" | ||
- ansible_distribution not in ["Amazon", "Fedora"] | ||
tags: | ||
- reset_crio | ||
|
||
- name: CRI-O | Run yum-clean-metadata | ||
command: yum clean metadata | ||
args: | ||
warn: no | ||
when: | ||
- ansible_os_family == "RedHat" | ||
tags: | ||
- reset_crio | ||
|
||
- name: CRI-O | Remove crictl | ||
file: | ||
name: "{{ item }}" | ||
state: absent | ||
loop: | ||
- /etc/crictl.yaml | ||
- "{{ bin_dir }}/crictl" | ||
tags: | ||
- reset_crio | ||
|
||
- name: CRI-O | Stop crio service | ||
service: | ||
name: crio | ||
daemon_reload: true | ||
enabled: false | ||
masked: true | ||
state: stopped | ||
tags: | ||
- reset_crio | ||
|
||
- name: CRI-O | Remove CRI-O configuration files | ||
file: | ||
name: "{{ item }}" | ||
state: absent | ||
loop: | ||
- /etc/crio | ||
- /etc/containers | ||
- /etc/systemd/system/crio.service.d | ||
tags: | ||
- reset_crio | ||
|
||
- name: CRI-O | Uninstall CRI-O package | ||
package: | ||
name: "{{ item }}" | ||
state: absent | ||
when: not is_ostree | ||
with_items: "{{ crio_packages }}" | ||
tags: | ||
- reset_crio |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
--- | ||
- name: Docker | ensure docker-ce repository is removed | ||
apt_repository: | ||
repo: "{{ item }}" | ||
state: absent | ||
with_items: "{{ docker_repo_info.repos }}" | ||
when: ansible_pkg_mgr == 'apt' | ||
tags: | ||
- reset_docker | ||
|
||
- name: Docker | Remove docker repository on Fedora | ||
file: | ||
name: "{{ yum_repo_dir }}/docker.repo" | ||
state: absent | ||
when: ansible_distribution == "Fedora" and not is_ostree | ||
tags: | ||
- reset_docker | ||
|
||
- name: Docker | Remove docker repository on RedHat/CentOS/Oracle/AlmaLinux Linux | ||
template: | ||
name: "{{ yum_repo_dir }}/docker-ce.repo" | ||
state: absent | ||
when: | ||
- ansible_os_family == "RedHat" | ||
- ansible_distribution != "Fedora" | ||
- not is_ostree | ||
tags: | ||
- reset_docker | ||
|
||
- name: Docker | Stop docker service | ||
service: | ||
name: docker | ||
daemon_reload: true | ||
enabled: false | ||
masked: true | ||
state: stopped | ||
tags: | ||
- reset_docker | ||
|
||
- name: Docker | Remove docker configuration files | ||
file: | ||
name: "{{ item }}" | ||
state: absent | ||
loop: | ||
- /etc/systemd/system/docker.service.d/ | ||
- /var/lib/docker | ||
- /etc/docker | ||
tags: | ||
- reset_docker | ||
|
||
- name: Docker | Remove docker package | ||
package: | ||
name: "{{ docker_package_info.pkgs }}" | ||
state: absent | ||
changed_when: false | ||
when: | ||
- not ansible_os_family in ["Flatcar", "Flatcar Container Linux by Kinvolk"] | ||
- not is_ostree | ||
- docker_package_info.pkgs|length > 0 | ||
tags: | ||
- reset_docker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
roles/container-engine/validate-container-engine/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--- | ||
- name: Check if containerd is installed | ||
find: | ||
file_type: file | ||
recurse: yes | ||
patterns: | ||
- containerd* | ||
paths: /usr | ||
register: containerd_installed | ||
|
||
- name: Check if docker is installed | ||
find: | ||
file_type: file | ||
recurse: yes | ||
patterns: | ||
- docker* | ||
paths: /usr | ||
register: docker_installed | ||
|
||
- name: Check if crio is installed | ||
find: | ||
file_type: file | ||
recurse: yes | ||
patterns: | ||
- crio* | ||
paths: /usr | ||
register: crio_installed | ||
|
||
- name: Uninstall containerd | ||
include_role: | ||
name: container-engine/containerd | ||
apply: | ||
tags: | ||
- reset_containerd | ||
when: | ||
- container_manager != "containerd" | ||
- not docker_installed.files|length | ||
- containerd_installed|length | ||
|
||
- name: Uninstall docker | ||
include_role: | ||
name: container-engine/docker | ||
apply: | ||
tags: | ||
- reset_docker | ||
when: | ||
- container_manager != "docker" | ||
- docker_installed.files|length | ||
|
||
- name: Uninstall crio | ||
include_role: | ||
name: container-engine/crio | ||
apply: | ||
tags: | ||
- reset_crio | ||
when: container_manager != "crio" and crio_installed.files|length |