diff --git a/roles/install-docker/README.rst b/roles/install-docker/README.rst index 384af9f36..a1151ccee 100644 --- a/roles/install-docker/README.rst +++ b/roles/install-docker/README.rst @@ -68,6 +68,14 @@ An ansible role to install docker and configure it to use mirrors if available. installed prior to installing docker-ce. If the package set needs to be changed this option can be overridden as needed. +.. zuul:rolevar:: docker_upstream_distro_remove_packages + :default: list + + List of packages to be removed before installing new ones. It is used + for avoiding potential conflicts. For example it can remove `docker` + package before trying to install `docker-ce`. The default value is + distro specific. + .. zuul:rolevar:: docker_upstream_distro_packages :default: list diff --git a/roles/install-docker/defaults/main.yaml b/roles/install-docker/defaults/main.yaml index ed387d08e..be126ada7 100644 --- a/roles/install-docker/defaults/main.yaml +++ b/roles/install-docker/defaults/main.yaml @@ -8,6 +8,7 @@ docker_distro_packages: "{{ _docker_distro_packages | default([]) }}" docker_compose_install: false docker_upstream_distro_packages: "{{ _docker_upstream_distro_packages | default([]) }}" docker_upstream_distro_required_packages: "{{ _docker_upstream_distro_required_packages | default([]) }}" +docker_upstream_distro_remove_packages: "{{ _docker_upstream_distro_remove_packages | default([]) }}" docker_update_channel: stable docker_download_fqdn: download.docker.com docker_mirror_base_url: "{{ _docker_mirror_base_url | default('') }}" diff --git a/roles/install-docker/tasks/upstream-package-installation.yaml b/roles/install-docker/tasks/upstream-package-installation.yaml index 0f22d1e10..be645e2ac 100644 --- a/roles/install-docker/tasks/upstream-package-installation.yaml +++ b/roles/install-docker/tasks/upstream-package-installation.yaml @@ -1,4 +1,10 @@ --- +- name: Remove packages + package: + name: "{{ docker_upstream_distro_remove_packages }}" + state: absent + when: docker_upstream_distro_remove_packages + # package/dnf module do not support `--nobest` option which is needed for # installing docker-ce on centos-8 - name: Install upstream docker using package diff --git a/roles/install-docker/vars/debian.yaml b/roles/install-docker/vars/debian.yaml index 8ee1078bd..925774013 100644 --- a/roles/install-docker/vars/debian.yaml +++ b/roles/install-docker/vars/debian.yaml @@ -14,6 +14,9 @@ _docker_upstream_distro_packages: - docker-ce-cli - containerd.io +_docker_upstream_distro_remove_packages: + - docker.io + docker_distro_vars_loaded: true _docker_mirror_base_url: "https://{{ docker_download_fqdn }}/linux/debian" diff --git a/roles/install-docker/vars/fedora.yaml b/roles/install-docker/vars/fedora.yaml index efdd1644c..a6c9a9fd7 100644 --- a/roles/install-docker/vars/fedora.yaml +++ b/roles/install-docker/vars/fedora.yaml @@ -11,6 +11,9 @@ _docker_upstream_distro_packages: - docker-ce-cli - containerd.io +_docker_upstream_distro_remove_packages: + - docker + docker_repo_template: docker-ce-fedora.repo.j2 docker_distro_vars_loaded: true