diff --git a/roles/container-engine/docker/tasks/main.yml b/roles/container-engine/docker/tasks/main.yml index 04bbd3bd0..6fc9995f8 100644 --- a/roles/container-engine/docker/tasks/main.yml +++ b/roles/container-engine/docker/tasks/main.yml @@ -120,33 +120,27 @@ - docker-ce-cli - name: ensure docker packages are installed - action: "{{ docker_package_info.pkg_mgr }}" - args: - pkg: "{{ item.name }}" - force: "{{ item.force|default(omit) }}" - state: "{{ item.state | default('present') }}" - update_cache: "{{ omit if ansible_distribution == 'Fedora' else True }}" - enablerepo: "{{ item.repo | default(omit) }}" + package: + name: "{{ docker_package_info.pkgs }}" + state: "{{ docker_package_info.state | default('present') }}" + module_defaults: + apt: + update_cache: true + dnf: + enablerepo: "{{ docker_package_info.enablerepo | default(omit) }}" + yum: + enablerepo: "{{ docker_package_info.enablerepo | default(omit) }}" + zypper: + update_cache: true register: docker_task_result until: docker_task_result is succeeded retries: 4 delay: "{{ retry_stagger | d(3) }}" - with_items: "{{ docker_package_info.pkgs }}" notify: restart docker - when: not (ansible_os_family in ["Flatcar Container Linux by Kinvolk", "ClearLinux"] or is_ostree) and (docker_package_info.pkgs|length > 0) - -- name: Ensure docker packages are installed - action: "{{ docker_package_info.pkg_mgr }}" - args: - name: "{{ item.name }}" - state: "{{ item.state | default('present') }}" - with_items: "{{ docker_package_info.pkgs }}" - register: docker_task_result - until: docker_task_result is succeeded - retries: 4 - delay: "{{ retry_stagger | d(3) }}" - notify: restart docker - when: ansible_os_family in ["ClearLinux"] + when: + - not ansible_os_family in ["Flatcar Container Linux by Kinvolk"] + - not is_ostree + - docker_package_info.pkgs|length > 0 # This is required to ensure any apt upgrade will not break kubernetes - name: Tell Debian hosts not to change the docker version with apt upgrade diff --git a/roles/container-engine/docker/vars/amazon.yml b/roles/container-engine/docker/vars/amazon.yml index 09cc4fcd6..f3556439b 100644 --- a/roles/container-engine/docker/vars/amazon.yml +++ b/roles/container-engine/docker/vars/amazon.yml @@ -9,6 +9,5 @@ docker_versioned_pkg: docker_version: "latest" docker_package_info: - pkg_mgr: yum pkgs: - - name: "{{ docker_versioned_pkg[docker_version | string] }}" + - "{{ docker_versioned_pkg[docker_version | string] }}" diff --git a/roles/container-engine/docker/vars/clearlinux.yml b/roles/container-engine/docker/vars/clearlinux.yml index c0306f1ed..fbb7a2271 100644 --- a/roles/container-engine/docker/vars/clearlinux.yml +++ b/roles/container-engine/docker/vars/clearlinux.yml @@ -1,5 +1,4 @@ --- docker_package_info: - pkg_mgr: swupd pkgs: - - name: "containers-basic" + - "containers-basic" diff --git a/roles/container-engine/docker/vars/debian.yml b/roles/container-engine/docker/vars/debian.yml index ce4605a8e..e0e8359c7 100644 --- a/roles/container-engine/docker/vars/debian.yml +++ b/roles/container-engine/docker/vars/debian.yml @@ -15,11 +15,10 @@ docker_cli_versioned_pkg: '20.10': docker-ce-cli=5:20.10.2~3-0~debian-{{ ansible_distribution_release|lower }} docker_package_info: - pkg_mgr: apt pkgs: - - name: "{{ containerd_versioned_pkg[containerd_version | string] }}" - - name: "{{ docker_cli_versioned_pkg[docker_cli_version | string] }}" - - name: "{{ docker_versioned_pkg[docker_version | string] }}" + - "{{ containerd_versioned_pkg[containerd_version | string] }}" + - "{{ docker_cli_versioned_pkg[docker_cli_version | string] }}" + - "{{ docker_versioned_pkg[docker_version | string] }}" docker_repo_key_info: pkg_key: apt_key diff --git a/roles/container-engine/docker/vars/fedora.yml b/roles/container-engine/docker/vars/fedora.yml index f2a130132..c416ef9a8 100644 --- a/roles/container-engine/docker/vars/fedora.yml +++ b/roles/container-engine/docker/vars/fedora.yml @@ -14,8 +14,8 @@ docker_cli_versioned_pkg: '20.10': docker-ce-cli-20.10.2-3.fc{{ ansible_distribution_major_version }} docker_package_info: - pkg_mgr: dnf + enablerepo: "docker-ce" pkgs: - - name: "{{ containerd_versioned_pkg[containerd_version | string] }}" - - name: "{{ docker_cli_versioned_pkg[docker_cli_version | string] }}" - - name: "{{ docker_versioned_pkg[docker_version | string] }}" + - "{{ containerd_versioned_pkg[containerd_version | string] }}" + - "{{ docker_cli_versioned_pkg[docker_cli_version | string] }}" + - "{{ 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 2e5c47375..011858d1a 100644 --- a/roles/container-engine/docker/vars/redhat.yml +++ b/roles/container-engine/docker/vars/redhat.yml @@ -17,14 +17,11 @@ docker_cli_versioned_pkg: '20.10': docker-ce-cli-20.10.2-3.el{{ ansible_distribution_major_version }} docker_package_info: - pkg_mgr: yum + enablerepo: "docker-ce" pkgs: - - name: "{{ containerd_versioned_pkg[containerd_version | string] }}" - repo: "docker-ce" - - name: "{{ docker_cli_versioned_pkg[docker_cli_version | string] }}" - repo: "docker-ce" - - name: "{{ docker_versioned_pkg[docker_version | string] }}" - repo: "docker-ce" + - "{{ containerd_versioned_pkg[containerd_version | string] }}" + - "{{ docker_cli_versioned_pkg[docker_cli_version | string] }}" + - "{{ docker_versioned_pkg[docker_version | string] }}" docker_repo_key_info: pkg_key: '' diff --git a/roles/container-engine/docker/vars/suse.yml b/roles/container-engine/docker/vars/suse.yml index 75458fcd0..b326275a5 100644 --- a/roles/container-engine/docker/vars/suse.yml +++ b/roles/container-engine/docker/vars/suse.yml @@ -1,10 +1,9 @@ --- docker_package_info: - pkg_mgr: zypper + state: latest pkgs: - - name: docker - - name: containerd - state: latest + - docker + - containerd docker_repo_key_info: pkg_key: '' diff --git a/roles/container-engine/docker/vars/ubuntu.yml b/roles/container-engine/docker/vars/ubuntu.yml index 0143695a3..d1609b63f 100644 --- a/roles/container-engine/docker/vars/ubuntu.yml +++ b/roles/container-engine/docker/vars/ubuntu.yml @@ -15,11 +15,10 @@ docker_cli_versioned_pkg: '20.10': docker-ce-cli=5:20.10.2~3-0~ubuntu-{{ ansible_distribution_release|lower }} docker_package_info: - pkg_mgr: apt pkgs: - - name: "{{ containerd_versioned_pkg[containerd_version | string] }}" - - name: "{{ docker_cli_versioned_pkg[docker_cli_version | string] }}" - - name: "{{ docker_versioned_pkg[docker_version | string] }}" + - "{{ containerd_versioned_pkg[containerd_version | string] }}" + - "{{ docker_cli_versioned_pkg[docker_cli_version | string] }}" + - "{{ docker_versioned_pkg[docker_version | string] }}" docker_repo_key_info: pkg_key: apt_key