From 5dd85197afe390036f8e54a04bb7dfdbfbae3b1d Mon Sep 17 00:00:00 2001 From: Lovro Seder Date: Fri, 5 Jun 2020 14:55:44 +0200 Subject: [PATCH] Manage containerd.io package with docker CRI. (#6218) * Manage containerd.io package with docker CRI. * Refactor common containerd stuff to separate role * Fix check mode and unnecessary shell. --- .../containerd-common/defaults/main.yml | 3 +++ .../containerd-common/tasks/main.yml | 19 +++++++++++++++++++ .../containerd-common/vars/debian.yml | 11 +++++++++++ .../containerd-common/vars/fedora.yml | 8 ++++++++ .../containerd-common/vars/redhat.yml | 11 +++++++++++ .../containerd-common/vars/ubuntu-amd64.yml | 11 +++++++++++ .../containerd-common/vars/ubuntu-arm64.yml | 8 ++++++++ .../containerd/defaults/main.yml | 3 --- .../container-engine/containerd/meta/main.yml | 3 +++ .../containerd/tasks/crictl.yml | 5 +++-- .../containerd/vars/debian.yml | 12 ------------ .../containerd/vars/fedora.yml | 9 --------- .../containerd/vars/redhat.yml | 12 ------------ .../containerd/vars/ubuntu-amd64.yml | 12 ------------ roles/container-engine/docker/meta/main.yml | 1 + roles/container-engine/docker/tasks/main.yml | 2 ++ .../container-engine/docker/tasks/systemd.yml | 1 + roles/container-engine/docker/vars/debian.yml | 2 ++ roles/container-engine/docker/vars/fedora.yml | 1 + roles/container-engine/docker/vars/redhat.yml | 2 ++ .../docker/vars/ubuntu-amd64.yml | 2 ++ .../docker/vars/ubuntu-arm64.yml | 2 ++ 22 files changed, 90 insertions(+), 50 deletions(-) create mode 100644 roles/container-engine/containerd-common/defaults/main.yml create mode 100644 roles/container-engine/containerd-common/tasks/main.yml create mode 100644 roles/container-engine/containerd-common/vars/debian.yml create mode 100644 roles/container-engine/containerd-common/vars/fedora.yml create mode 100644 roles/container-engine/containerd-common/vars/redhat.yml create mode 100644 roles/container-engine/containerd-common/vars/ubuntu-amd64.yml create mode 100644 roles/container-engine/containerd-common/vars/ubuntu-arm64.yml create mode 100644 roles/container-engine/containerd/meta/main.yml diff --git a/roles/container-engine/containerd-common/defaults/main.yml b/roles/container-engine/containerd-common/defaults/main.yml new file mode 100644 index 000000000..d502f195d --- /dev/null +++ b/roles/container-engine/containerd-common/defaults/main.yml @@ -0,0 +1,3 @@ +--- +containerd_version: '1.2.13' +containerd_package: 'containerd.io' diff --git a/roles/container-engine/containerd-common/tasks/main.yml b/roles/container-engine/containerd-common/tasks/main.yml new file mode 100644 index 000000000..59eee3270 --- /dev/null +++ b/roles/container-engine/containerd-common/tasks/main.yml @@ -0,0 +1,19 @@ +--- +- name: gather os specific variables + include_vars: "{{ item }}" + with_first_found: + - files: + - "{{ ansible_distribution|lower }}-{{ ansible_distribution_version|lower|replace('/', '_') }}.yml" + - "{{ ansible_distribution|lower }}-{{ ansible_distribution_release|lower }}-{{ host_architecture }}.yml" + - "{{ ansible_distribution|lower }}-{{ ansible_distribution_release|lower }}.yml" + - "{{ ansible_distribution|lower }}-{{ ansible_distribution_major_version|lower|replace('/', '_') }}.yml" + - "{{ ansible_distribution|lower }}-{{ host_architecture }}.yml" + - "{{ ansible_distribution|lower }}.yml" + - "{{ ansible_os_family|lower }}-{{ host_architecture }}.yml" + - "{{ ansible_os_family|lower }}.yml" + - defaults.yml + paths: + - ../vars + skip: true + tags: + - facts diff --git a/roles/container-engine/containerd-common/vars/debian.yml b/roles/container-engine/containerd-common/vars/debian.yml new file mode 100644 index 000000000..ff2caf5be --- /dev/null +++ b/roles/container-engine/containerd-common/vars/debian.yml @@ -0,0 +1,11 @@ +--- +containerd_versioned_pkg: + 'latest': "{{ containerd_package }}" + '1.2.4': "{{ containerd_package }}=1.2.4-1" + '1.2.5': "{{ containerd_package }}=1.2.5-1" + '1.2.6': "{{ containerd_package }}=1.2.6-3" + '1.2.10': "{{ containerd_package }}=1.2.10-3" + '1.2.12': "{{ containerd_package }}=1.2.12-1" + '1.2.13': "{{ containerd_package }}=1.2.13-2" + 'stable': "{{ containerd_package }}=1.2.13-2" + 'edge': "{{ containerd_package }}=1.2.13-2" diff --git a/roles/container-engine/containerd-common/vars/fedora.yml b/roles/container-engine/containerd-common/vars/fedora.yml new file mode 100644 index 000000000..f68b8743e --- /dev/null +++ b/roles/container-engine/containerd-common/vars/fedora.yml @@ -0,0 +1,8 @@ +--- +containerd_versioned_pkg: + 'latest': "{{ containerd_package }}" + '1.2.10': "{{ containerd_package }}-1.2.10-3.2.fc{{ ansible_distribution_major_version }}" + '1.2.12': "{{ containerd_package }}-1.2.12-3.1.fc{{ ansible_distribution_major_version }}" + '1.2.13': "{{ containerd_package }}-1.2.13-3.2.fc{{ ansible_distribution_major_version }}" + 'stable': "{{ containerd_package }}-1.2.13-3.2.fc{{ ansible_distribution_major_version }}" + 'edge': "{{ containerd_package }}-1.2.13-3.2.fc{{ ansible_distribution_major_version }}" diff --git a/roles/container-engine/containerd-common/vars/redhat.yml b/roles/container-engine/containerd-common/vars/redhat.yml new file mode 100644 index 000000000..b77038e59 --- /dev/null +++ b/roles/container-engine/containerd-common/vars/redhat.yml @@ -0,0 +1,11 @@ +--- +containerd_versioned_pkg: + 'latest': "{{ containerd_package }}" + '1.2.4': "{{ containerd_package }}-1.2.4-3.1.el7" + '1.2.5': "{{ containerd_package }}-1.2.5-3.1.el7" + '1.2.6': "{{ containerd_package }}-1.2.6-3.3.el7" + '1.2.10': "{{ containerd_package }}-1.2.10-3.2.el7" + '1.2.12': "{{ containerd_package }}-1.2.12-3.1.el7" + '1.2.13': "{{ containerd_package }}-1.2.13-3.2.el7" + 'stable': "{{ containerd_package }}-1.2.13-3.2.el7" + 'edge': "{{ containerd_package }}-1.2.13-3.2.el7" diff --git a/roles/container-engine/containerd-common/vars/ubuntu-amd64.yml b/roles/container-engine/containerd-common/vars/ubuntu-amd64.yml new file mode 100644 index 000000000..ff2caf5be --- /dev/null +++ b/roles/container-engine/containerd-common/vars/ubuntu-amd64.yml @@ -0,0 +1,11 @@ +--- +containerd_versioned_pkg: + 'latest': "{{ containerd_package }}" + '1.2.4': "{{ containerd_package }}=1.2.4-1" + '1.2.5': "{{ containerd_package }}=1.2.5-1" + '1.2.6': "{{ containerd_package }}=1.2.6-3" + '1.2.10': "{{ containerd_package }}=1.2.10-3" + '1.2.12': "{{ containerd_package }}=1.2.12-1" + '1.2.13': "{{ containerd_package }}=1.2.13-2" + 'stable': "{{ containerd_package }}=1.2.13-2" + 'edge': "{{ containerd_package }}=1.2.13-2" diff --git a/roles/container-engine/containerd-common/vars/ubuntu-arm64.yml b/roles/container-engine/containerd-common/vars/ubuntu-arm64.yml new file mode 100644 index 000000000..08ec3dd68 --- /dev/null +++ b/roles/container-engine/containerd-common/vars/ubuntu-arm64.yml @@ -0,0 +1,8 @@ +--- +containerd_versioned_pkg: + 'latest': "{{ containerd_package }}" + '1.2.10': "{{ containerd_package }}=1.2.10-3" + '1.2.12': "{{ containerd_package }}=1.2.12-1" + '1.2.13': "{{ containerd_package }}=1.2.13-2" + 'stable': "{{ containerd_package }}=1.2.13-2" + 'edge': "{{ containerd_package }}=1.2.13-2" diff --git a/roles/container-engine/containerd/defaults/main.yml b/roles/container-engine/containerd/defaults/main.yml index bf6484081..ee833bb19 100644 --- a/roles/container-engine/containerd/defaults/main.yml +++ b/roles/container-engine/containerd/defaults/main.yml @@ -11,9 +11,6 @@ containerd_config: # containerd: # snapshotter: native -containerd_version: '1.2.13' -containerd_package: 'containerd.io' - containerd_cfg_dir: /etc/containerd # Path to runc binary diff --git a/roles/container-engine/containerd/meta/main.yml b/roles/container-engine/containerd/meta/main.yml new file mode 100644 index 000000000..1a53ba7d6 --- /dev/null +++ b/roles/container-engine/containerd/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - role: container-engine/containerd-common diff --git a/roles/container-engine/containerd/tasks/crictl.yml b/roles/container-engine/containerd/tasks/crictl.yml index 0e0459508..eaa94efa3 100644 --- a/roles/container-engine/containerd/tasks/crictl.yml +++ b/roles/container-engine/containerd/tasks/crictl.yml @@ -22,12 +22,13 @@ delegate_to: "{{ inventory_hostname }}" - name: Get crictl completion - shell: "{{ bin_dir }}/crictl completion" + command: "{{ bin_dir }}/crictl completion" changed_when: False register: cri_completion + check_mode: False - name: Install crictl completion copy: dest: /etc/bash_completion.d/crictl content: "{{ cri_completion.stdout }}" - become: True \ No newline at end of file + become: True diff --git a/roles/container-engine/containerd/vars/debian.yml b/roles/container-engine/containerd/vars/debian.yml index 6365a938b..66aa5f08c 100644 --- a/roles/container-engine/containerd/vars/debian.yml +++ b/roles/container-engine/containerd/vars/debian.yml @@ -1,16 +1,4 @@ --- - -containerd_versioned_pkg: - 'latest': "{{ containerd_package }}" - '1.2.4': "{{ containerd_package }}=1.2.4-1" - '1.2.5': "{{ containerd_package }}=1.2.5-1" - '1.2.6': "{{ containerd_package }}=1.2.6-3" - '1.2.10': "{{ containerd_package }}=1.2.10-3" - '1.2.12': "{{ containerd_package }}=1.2.12-1" - '1.2.13': "{{ containerd_package }}=1.2.13-2" - 'stable': "{{ containerd_package }}=1.2.13-2" - 'edge': "{{ containerd_package }}=1.2.13-2" - containerd_package_info: pkg_mgr: apt pkgs: diff --git a/roles/container-engine/containerd/vars/fedora.yml b/roles/container-engine/containerd/vars/fedora.yml index ca06bef6b..dbbbee722 100644 --- a/roles/container-engine/containerd/vars/fedora.yml +++ b/roles/container-engine/containerd/vars/fedora.yml @@ -1,13 +1,4 @@ --- - -containerd_versioned_pkg: - 'latest': "{{ containerd_package }}" - '1.2.10': "{{ containerd_package }}-1.2.10-3.2.fc{{ ansible_distribution_major_version }}" - '1.2.12': "{{ containerd_package }}-1.2.12-3.2.fc{{ ansible_distribution_major_version }}" - '1.2.13': "{{ containerd_package }}-1.2.13-3.2.fc{{ ansible_distribution_major_version }}" - 'stable': "{{ containerd_package }}-1.2.13-3.2.fc{{ ansible_distribution_major_version }}" - 'edge': "{{ containerd_package }}-1.2.13-3.2.fc{{ ansible_distribution_major_version }}" - containerd_package_info: pkg_mgr: dnf pkgs: diff --git a/roles/container-engine/containerd/vars/redhat.yml b/roles/container-engine/containerd/vars/redhat.yml index 58bdfae02..d375d1493 100644 --- a/roles/container-engine/containerd/vars/redhat.yml +++ b/roles/container-engine/containerd/vars/redhat.yml @@ -1,16 +1,4 @@ --- - -containerd_versioned_pkg: - 'latest': "{{ containerd_package }}" - '1.2.4': "{{ containerd_package }}-1.2.4-3.1.el7" - '1.2.5': "{{ containerd_package }}-1.2.5-3.1.el7" - '1.2.6': "{{ containerd_package }}-1.2.6-3.3.el7" - '1.2.10': "{{ containerd_package }}-1.2.10-3.2.el7" - '1.2.12': "{{ containerd_package }}-1.2.12-3.1.el7" - '1.2.13': "{{ containerd_package }}-1.2.13-3.2.el7" - 'stable': "{{ containerd_package }}-1.2.13-3.2.el7" - 'edge': "{{ containerd_package }}-1.2.13-3.2.el7" - containerd_package_info: pkg_mgr: yum pkgs: diff --git a/roles/container-engine/containerd/vars/ubuntu-amd64.yml b/roles/container-engine/containerd/vars/ubuntu-amd64.yml index d0d495d0b..a57cf5030 100644 --- a/roles/container-engine/containerd/vars/ubuntu-amd64.yml +++ b/roles/container-engine/containerd/vars/ubuntu-amd64.yml @@ -1,16 +1,4 @@ --- - -containerd_versioned_pkg: - 'latest': "{{ containerd_package }}" - '1.2.4': "{{ containerd_package }}=1.2.4-1" - '1.2.5': "{{ containerd_package }}=1.2.5-1" - '1.2.6': "{{ containerd_package }}=1.2.6-3" - '1.2.10': "{{ containerd_package }}=1.2.10-3" - '1.2.12': "{{ containerd_package }}=1.2.12-1" - '1.2.13': "{{ containerd_package }}=1.2.13-2" - 'stable': "{{ containerd_package }}=1.2.13-2" - 'edge': "{{ containerd_package }}=1.2.13-2" - containerd_package_info: pkg_mgr: apt pkgs: diff --git a/roles/container-engine/docker/meta/main.yml b/roles/container-engine/docker/meta/main.yml index 55974071c..d7e47517a 100644 --- a/roles/container-engine/docker/meta/main.yml +++ b/roles/container-engine/docker/meta/main.yml @@ -1,4 +1,5 @@ --- dependencies: + - role: container-engine/containerd-common - role: container-engine/docker-storage when: docker_container_storage_setup and ansible_os_family == "RedHat" diff --git a/roles/container-engine/docker/tasks/main.yml b/roles/container-engine/docker/tasks/main.yml index bd6ac06e0..9369186bb 100644 --- a/roles/container-engine/docker/tasks/main.yml +++ b/roles/container-engine/docker/tasks/main.yml @@ -196,6 +196,7 @@ - docker_task_result is failed - ansible_distribution == 'Ubuntu' register: available_packages + check_mode: false - name: show available packages on ubuntu fail: @@ -239,6 +240,7 @@ command: "docker version -f '{{ '{{' }}.Client.Version{{ '}}' }}'" register: installed_docker_version changed_when: false + check_mode: false - name: check minimum docker version for docker_dns mode. You need at least docker version >= 1.12 for resolvconf_mode=docker_dns fail: diff --git a/roles/container-engine/docker/tasks/systemd.yml b/roles/container-engine/docker/tasks/systemd.yml index a2e1d9d70..0a232ea9e 100644 --- a/roles/container-engine/docker/tasks/systemd.yml +++ b/roles/container-engine/docker/tasks/systemd.yml @@ -17,6 +17,7 @@ register: systemd_version when: not is_ostree changed_when: false + check_mode: false - name: Write docker.service systemd file template: diff --git a/roles/container-engine/docker/vars/debian.yml b/roles/container-engine/docker/vars/debian.yml index d0677bf68..55dbec5db 100644 --- a/roles/container-engine/docker/vars/debian.yml +++ b/roles/container-engine/docker/vars/debian.yml @@ -24,6 +24,8 @@ docker_cli_versioned_pkg: docker_package_info: pkg_mgr: apt pkgs: + - name: "{{ containerd_versioned_pkg[containerd_version | string] }}" + force: yes - name: "{{ docker_cli_versioned_pkg[docker_cli_version | string] }}" force: yes - name: "{{ docker_versioned_pkg[docker_version | string] }}" diff --git a/roles/container-engine/docker/vars/fedora.yml b/roles/container-engine/docker/vars/fedora.yml index 6501d778b..44b38bb55 100644 --- a/roles/container-engine/docker/vars/fedora.yml +++ b/roles/container-engine/docker/vars/fedora.yml @@ -21,5 +21,6 @@ docker_cli_versioned_pkg: docker_package_info: pkg_mgr: dnf pkgs: + - name: "{{ containerd_versioned_pkg[containerd_version | string] }}" - name: "{{ docker_cli_versioned_pkg[docker_cli_version | string] }}" - name: "{{ docker_versioned_pkg[docker_version | string] }}" diff --git a/roles/container-engine/docker/vars/redhat.yml b/roles/container-engine/docker/vars/redhat.yml index a30ab00f6..b3008db3d 100644 --- a/roles/container-engine/docker/vars/redhat.yml +++ b/roles/container-engine/docker/vars/redhat.yml @@ -35,6 +35,8 @@ docker_pkgs_use_docker_ce: yum_conf: "{{ docker_yum_conf }}" docker_pkgs: + - name: "{{ containerd_versioned_pkg[containerd_version | string] }}" + yum_conf: "{{ docker_yum_conf }}" - name: "{{ docker_cli_versioned_pkg[docker_cli_version | string] }}" yum_conf: "{{ docker_yum_conf }}" - name: "{{ docker_versioned_pkg[docker_version | string] }}" diff --git a/roles/container-engine/docker/vars/ubuntu-amd64.yml b/roles/container-engine/docker/vars/ubuntu-amd64.yml index 7f3030032..329400596 100644 --- a/roles/container-engine/docker/vars/ubuntu-amd64.yml +++ b/roles/container-engine/docker/vars/ubuntu-amd64.yml @@ -24,6 +24,8 @@ docker_cli_versioned_pkg: docker_package_info: pkg_mgr: apt pkgs: + - name: "{{ containerd_versioned_pkg[containerd_version | string] }}" + force: yes - name: "{{ docker_cli_versioned_pkg[docker_cli_version | string] }}" force: yes - name: "{{ docker_versioned_pkg[docker_version | string] }}" diff --git a/roles/container-engine/docker/vars/ubuntu-arm64.yml b/roles/container-engine/docker/vars/ubuntu-arm64.yml index 69baada1c..3d4de5f9f 100644 --- a/roles/container-engine/docker/vars/ubuntu-arm64.yml +++ b/roles/container-engine/docker/vars/ubuntu-arm64.yml @@ -20,6 +20,8 @@ docker_cli_versioned_pkg: docker_package_info: pkg_mgr: apt pkgs: + - name: "{{ containerd_versioned_pkg[containerd_version | string] }}" + force: yes - name: "{{ docker_cli_versioned_pkg[docker_cli_version | string] }}" force: yes - name: "{{ docker_versioned_pkg[docker_version | string] }}"