docker: use package instead of action, cleanup
Signed-off-by: Etienne Champetier <champetier.etienne@gmail.com>
(cherry picked from commit 0e96852159
)
This commit is contained in:
parent
74e8f58c57
commit
b198cd23d0
8 changed files with 35 additions and 49 deletions
|
@ -120,33 +120,27 @@
|
||||||
- docker-ce-cli
|
- docker-ce-cli
|
||||||
|
|
||||||
- name: ensure docker packages are installed
|
- name: ensure docker packages are installed
|
||||||
action: "{{ docker_package_info.pkg_mgr }}"
|
package:
|
||||||
args:
|
name: "{{ docker_package_info.pkgs }}"
|
||||||
pkg: "{{ item.name }}"
|
state: "{{ docker_package_info.state | default('present') }}"
|
||||||
force: "{{ item.force|default(omit) }}"
|
module_defaults:
|
||||||
state: "{{ item.state | default('present') }}"
|
apt:
|
||||||
update_cache: "{{ omit if ansible_distribution == 'Fedora' else True }}"
|
update_cache: true
|
||||||
enablerepo: "{{ item.repo | default(omit) }}"
|
dnf:
|
||||||
register: docker_task_result
|
enablerepo: "{{ docker_package_info.enablerepo | default(omit) }}"
|
||||||
until: docker_task_result is succeeded
|
yum:
|
||||||
retries: 4
|
enablerepo: "{{ docker_package_info.enablerepo | default(omit) }}"
|
||||||
delay: "{{ retry_stagger | d(3) }}"
|
zypper:
|
||||||
with_items: "{{ docker_package_info.pkgs }}"
|
update_cache: true
|
||||||
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
|
register: docker_task_result
|
||||||
until: docker_task_result is succeeded
|
until: docker_task_result is succeeded
|
||||||
retries: 4
|
retries: 4
|
||||||
delay: "{{ retry_stagger | d(3) }}"
|
delay: "{{ retry_stagger | d(3) }}"
|
||||||
notify: restart docker
|
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
|
# 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
|
- name: Tell Debian hosts not to change the docker version with apt upgrade
|
||||||
|
|
|
@ -9,6 +9,5 @@ docker_versioned_pkg:
|
||||||
docker_version: "latest"
|
docker_version: "latest"
|
||||||
|
|
||||||
docker_package_info:
|
docker_package_info:
|
||||||
pkg_mgr: yum
|
|
||||||
pkgs:
|
pkgs:
|
||||||
- name: "{{ docker_versioned_pkg[docker_version | string] }}"
|
- "{{ docker_versioned_pkg[docker_version | string] }}"
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
---
|
---
|
||||||
docker_package_info:
|
docker_package_info:
|
||||||
pkg_mgr: swupd
|
|
||||||
pkgs:
|
pkgs:
|
||||||
- name: "containers-basic"
|
- "containers-basic"
|
||||||
|
|
|
@ -15,11 +15,10 @@ docker_cli_versioned_pkg:
|
||||||
'20.10': docker-ce-cli=5:20.10.2~3-0~debian-{{ ansible_distribution_release|lower }}
|
'20.10': docker-ce-cli=5:20.10.2~3-0~debian-{{ ansible_distribution_release|lower }}
|
||||||
|
|
||||||
docker_package_info:
|
docker_package_info:
|
||||||
pkg_mgr: apt
|
|
||||||
pkgs:
|
pkgs:
|
||||||
- name: "{{ containerd_versioned_pkg[containerd_version | string] }}"
|
- "{{ containerd_versioned_pkg[containerd_version | string] }}"
|
||||||
- name: "{{ docker_cli_versioned_pkg[docker_cli_version | string] }}"
|
- "{{ docker_cli_versioned_pkg[docker_cli_version | string] }}"
|
||||||
- name: "{{ docker_versioned_pkg[docker_version | string] }}"
|
- "{{ docker_versioned_pkg[docker_version | string] }}"
|
||||||
|
|
||||||
docker_repo_key_info:
|
docker_repo_key_info:
|
||||||
pkg_key: apt_key
|
pkg_key: apt_key
|
||||||
|
|
|
@ -14,8 +14,8 @@ docker_cli_versioned_pkg:
|
||||||
'20.10': docker-ce-cli-20.10.2-3.fc{{ ansible_distribution_major_version }}
|
'20.10': docker-ce-cli-20.10.2-3.fc{{ ansible_distribution_major_version }}
|
||||||
|
|
||||||
docker_package_info:
|
docker_package_info:
|
||||||
pkg_mgr: dnf
|
enablerepo: "docker-ce"
|
||||||
pkgs:
|
pkgs:
|
||||||
- name: "{{ containerd_versioned_pkg[containerd_version | string] }}"
|
- "{{ containerd_versioned_pkg[containerd_version | string] }}"
|
||||||
- name: "{{ docker_cli_versioned_pkg[docker_cli_version | string] }}"
|
- "{{ docker_cli_versioned_pkg[docker_cli_version | string] }}"
|
||||||
- name: "{{ docker_versioned_pkg[docker_version | string] }}"
|
- "{{ docker_versioned_pkg[docker_version | string] }}"
|
||||||
|
|
|
@ -17,14 +17,11 @@ docker_cli_versioned_pkg:
|
||||||
'20.10': docker-ce-cli-20.10.2-3.el{{ ansible_distribution_major_version }}
|
'20.10': docker-ce-cli-20.10.2-3.el{{ ansible_distribution_major_version }}
|
||||||
|
|
||||||
docker_package_info:
|
docker_package_info:
|
||||||
pkg_mgr: yum
|
enablerepo: "docker-ce"
|
||||||
pkgs:
|
pkgs:
|
||||||
- name: "{{ containerd_versioned_pkg[containerd_version | string] }}"
|
- "{{ containerd_versioned_pkg[containerd_version | string] }}"
|
||||||
repo: "docker-ce"
|
- "{{ docker_cli_versioned_pkg[docker_cli_version | string] }}"
|
||||||
- name: "{{ docker_cli_versioned_pkg[docker_cli_version | string] }}"
|
- "{{ docker_versioned_pkg[docker_version | string] }}"
|
||||||
repo: "docker-ce"
|
|
||||||
- name: "{{ docker_versioned_pkg[docker_version | string] }}"
|
|
||||||
repo: "docker-ce"
|
|
||||||
|
|
||||||
docker_repo_key_info:
|
docker_repo_key_info:
|
||||||
pkg_key: ''
|
pkg_key: ''
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
---
|
---
|
||||||
docker_package_info:
|
docker_package_info:
|
||||||
pkg_mgr: zypper
|
state: latest
|
||||||
pkgs:
|
pkgs:
|
||||||
- name: docker
|
- docker
|
||||||
- name: containerd
|
- containerd
|
||||||
state: latest
|
|
||||||
|
|
||||||
docker_repo_key_info:
|
docker_repo_key_info:
|
||||||
pkg_key: ''
|
pkg_key: ''
|
||||||
|
|
|
@ -15,11 +15,10 @@ docker_cli_versioned_pkg:
|
||||||
'20.10': docker-ce-cli=5:20.10.2~3-0~ubuntu-{{ ansible_distribution_release|lower }}
|
'20.10': docker-ce-cli=5:20.10.2~3-0~ubuntu-{{ ansible_distribution_release|lower }}
|
||||||
|
|
||||||
docker_package_info:
|
docker_package_info:
|
||||||
pkg_mgr: apt
|
|
||||||
pkgs:
|
pkgs:
|
||||||
- name: "{{ containerd_versioned_pkg[containerd_version | string] }}"
|
- "{{ containerd_versioned_pkg[containerd_version | string] }}"
|
||||||
- name: "{{ docker_cli_versioned_pkg[docker_cli_version | string] }}"
|
- "{{ docker_cli_versioned_pkg[docker_cli_version | string] }}"
|
||||||
- name: "{{ docker_versioned_pkg[docker_version | string] }}"
|
- "{{ docker_versioned_pkg[docker_version | string] }}"
|
||||||
|
|
||||||
docker_repo_key_info:
|
docker_repo_key_info:
|
||||||
pkg_key: apt_key
|
pkg_key: apt_key
|
||||||
|
|
Loading…
Reference in a new issue