docker: use package instead of action, cleanup

Signed-off-by: Etienne Champetier <champetier.etienne@gmail.com>
This commit is contained in:
Etienne Champetier 2021-01-07 17:13:14 -05:00 committed by Kubernetes Prow Robot
parent 19a61d838f
commit 0e96852159
8 changed files with 35 additions and 49 deletions

View file

@ -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) }}"
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 }}"
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) }}"
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

View file

@ -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] }}"

View file

@ -1,5 +1,4 @@
---
docker_package_info:
pkg_mgr: swupd
pkgs:
- name: "containers-basic"
- "containers-basic"

View file

@ -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

View file

@ -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] }}"

View file

@ -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: ''

View file

@ -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: ''

View file

@ -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