From c94291558d93ebf5106a85157fde827edbe0c09c Mon Sep 17 00:00:00 2001 From: Marcus Fenner Date: Fri, 5 Nov 2021 15:53:53 +0100 Subject: [PATCH] Fix containerd install for fcos (#8107) * Fix containerd install for fcos * rm orphaned runc and containerd binaries --- roles/container-engine/containerd/tasks/main.yml | 13 +++++++++++++ roles/container-engine/runc/defaults/main.yml | 2 +- roles/container-engine/runc/tasks/main.yml | 13 +++++++++++++ roles/kubespray-defaults/defaults/main.yaml | 2 +- 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/roles/container-engine/containerd/tasks/main.yml b/roles/container-engine/containerd/tasks/main.yml index 4a76a192a..7088f340d 100644 --- a/roles/container-engine/containerd/tasks/main.yml +++ b/roles/container-engine/containerd/tasks/main.yml @@ -57,6 +57,19 @@ - --strip-components=1 notify: restart containerd +- name: containerd | Remove orphaned binary + file: + path: "/usr/bin/{{ item }}" + state: absent + when: containerd_bin_dir != "/usr/bin" + ignore_errors: true # noqa ignore-errors + with_items: + - containerd + - containerd-shim + - containerd-shim-runc-v1 + - containerd-shim-runc-v2 + - ctr + - name: containerd | Generate systemd service for containerd template: src: containerd.service.j2 diff --git a/roles/container-engine/runc/defaults/main.yml b/roles/container-engine/runc/defaults/main.yml index 9c2fafffd..af8aa0837 100644 --- a/roles/container-engine/runc/defaults/main.yml +++ b/roles/container-engine/runc/defaults/main.yml @@ -1,5 +1,5 @@ --- -runc_bin_dir: /usr/bin/ +runc_bin_dir: "{{ bin_dir }}" runc_package_name: runc diff --git a/roles/container-engine/runc/tasks/main.yml b/roles/container-engine/runc/tasks/main.yml index be1014d79..94f97c0ba 100644 --- a/roles/container-engine/runc/tasks/main.yml +++ b/roles/container-engine/runc/tasks/main.yml @@ -1,8 +1,14 @@ --- +- name: runc | set is_ostree + set_fact: + is_ostree: "{{ ostree.stat.exists }}" + - name: runc | Uninstall runc package managed by package manager package: name: "{{ runc_package_name }}" state: absent + when: + - not (is_ostree or (ansible_distribution == "Flatcar Container Linux by Kinvolk") or (ansible_distribution == "Flatcar")) - name: runc | Download runc binary include_tasks: "../../../download/tasks/download_file.yml" @@ -15,3 +21,10 @@ dest: "{{ runc_bin_dir }}/runc" mode: 0755 remote_src: true + +- name: runc | Remove orphaned binary + file: + path: /usr/bin/runc + state: absent + when: runc_bin_dir != "/usr/bin" + ignore_errors: true # noqa ignore-errors diff --git a/roles/kubespray-defaults/defaults/main.yaml b/roles/kubespray-defaults/defaults/main.yaml index bb0067284..282cc6507 100644 --- a/roles/kubespray-defaults/defaults/main.yaml +++ b/roles/kubespray-defaults/defaults/main.yaml @@ -67,7 +67,7 @@ haproxy_config_dir: "/etc/haproxy" # Directory where the binaries will be installed bin_dir: /usr/local/bin docker_bin_dir: /usr/bin -containerd_bin_dir: /usr/bin +containerd_bin_dir: "{{ bin_dir }}" etcd_data_dir: /var/lib/etcd # Where the binaries will be downloaded. # Note: ensure that you've enough disk space (about 1G)