Make Docker and Podman play nice (#65009)

podman 1.4 now installs docker man pages. Add handler to remove docker packages to avoid test failure due to this conflict.

Adjust inventory_docker_swarm integration test
Add conditional to cleanup handlers to allow use of the setup_docker role without removing packages at the end of the play. The inventory_docker_swarm integration tests does its own cleanup.
This commit is contained in:
Sam Doran 2019-11-18 15:08:58 -05:00 committed by GitHub
parent 163904fe37
commit 6b2b876d43
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 60 additions and 6 deletions

View file

@ -1,9 +1,18 @@
--- ---
- hosts: 127.0.0.1 - hosts: 127.0.0.1
connection: local connection: local
gather_facts: no gather_facts: yes
tasks: tasks:
- name: Make sure swarm is removed - name: Make sure swarm is removed
docker_swarm: docker_swarm:
state: absent state: absent
force: yes force: yes
- name: remove docker pagkages
action: "{{ ansible_facts.pkg_mgr }}"
args:
name:
- docker
- docker-ce
- docker-ce-cli
state: absent

View file

@ -1,10 +1,14 @@
--- ---
- hosts: 127.0.0.1 - hosts: 127.0.0.1
connection: local connection: local
vars:
docker_skip_cleanup: yes
tasks: tasks:
- name: Setup docker - name: Setup docker
include_role: import_role:
name: setup_docker name: setup_docker
- name: Create a Swarm cluster - name: Create a Swarm cluster
docker_swarm: docker_swarm:
state: present state: present

View file

@ -1,6 +1,7 @@
docker_cli_version: '0.0' docker_cli_version: '0.0'
docker_api_version: '0.0' docker_api_version: '0.0'
docker_py_version: '0.0' docker_py_version: '0.0'
docker_skip_cleanup: no
docker_prereq_packages: [] docker_prereq_packages: []
docker_packages: docker_packages:
- docker-ce - docker-ce
@ -8,3 +9,8 @@ docker_packages:
docker_pip_extra_packages: [] docker_pip_extra_packages: []
docker_pip_packages: docker_pip_packages:
- docker - docker
docker_cleanup_packages:
- docker
- docker-ce
- docker-ce-cli

View file

@ -0,0 +1,14 @@
- name: remove pip packages
pip:
state: present
name: "{{ docker_pip_packages | union(docker_pip_extra_packages) }}"
listen: cleanup docker
when: not docker_skip_cleanup | bool
- name: remove docker pagkages
action: "{{ ansible_facts.pkg_mgr }}"
args:
name: "{{ docker_cleanup_packages }}"
state: absent
listen: cleanup docker
when: not docker_skip_cleanup | bool

View file

@ -7,6 +7,7 @@
name: "{{ docker_prereq_packages }}" name: "{{ docker_prereq_packages }}"
state: present state: present
update_cache: yes update_cache: yes
notify: cleanup docker
- name: Add gpg key - name: Add gpg key
shell: curl -fsSL https://download.docker.com/linux/ubuntu/gpg >key && apt-key add key shell: curl -fsSL https://download.docker.com/linux/ubuntu/gpg >key && apt-key add key

View file

@ -18,3 +18,4 @@
name: "{{ docker_packages }}" name: "{{ docker_packages }}"
state: present state: present
enablerepo: docker-ce-test enablerepo: docker-ce-test
notify: cleanup docker

View file

@ -5,6 +5,7 @@
yum: yum:
name: "{{ docker_prereq_packages }}" name: "{{ docker_prereq_packages }}"
state: present state: present
notify: cleanup docker
- name: Install epel repo which is missing on rhel-7 and is needed for pigz (needed for docker-ce 18) - name: Install epel repo which is missing on rhel-7 and is needed for pigz (needed for docker-ce 18)
include_role: include_role:
@ -29,6 +30,7 @@
yum: yum:
name: "{{ docker_packages }}" name: "{{ docker_packages }}"
state: present state: present
notify: cleanup docker
- name: Make sure the docker daemon is running (failure expected inside docker container) - name: Make sure the docker daemon is running (failure expected inside docker container)
service: service:

View file

@ -5,6 +5,7 @@
dnf: dnf:
name: "{{ docker_prereq_packages }}" name: "{{ docker_prereq_packages }}"
state: present state: present
notify: cleanup docker
- name: Set-up repository - name: Set-up repository
command: dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo command: dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
@ -15,6 +16,7 @@
dnf: dnf:
name: "{{ docker_packages }}" name: "{{ docker_packages }}"
state: present state: present
notify: cleanup docker
- name: Make sure the docker daemon is running (failure expected inside docker container) - name: Make sure the docker daemon is running (failure expected inside docker container)
service: service:

View file

@ -4,3 +4,4 @@
force: yes force: yes
disable_gpg_check: yes disable_gpg_check: yes
update_cache: yes update_cache: yes
notify: cleanup docker

View file

@ -12,7 +12,7 @@
- "{{ ansible_facts.os_family }}.yml" - "{{ ansible_facts.os_family }}.yml"
- default.yml - default.yml
paths: paths:
- vars - "{{ role_path }}/vars"
- name: Include distribution specific tasks - name: Include distribution specific tasks
include_tasks: "{{ lookup('first_found', params) }}" include_tasks: "{{ lookup('first_found', params) }}"
@ -24,13 +24,14 @@
- "{{ ansible_facts.distribution }}.yml" - "{{ ansible_facts.distribution }}.yml"
- "{{ ansible_facts.os_family }}.yml" - "{{ ansible_facts.os_family }}.yml"
paths: paths:
- tasks - "{{ role_path }}/tasks"
- name: Install Python requirements - name: Install Python requirements
pip: pip:
state: present state: present
name: "{{ docker_pip_packages | union(docker_pip_extra_packages) }}" name: "{{ docker_pip_packages | union(docker_pip_extra_packages) }}"
extra_args: "-c {{ remote_constraints }}" extra_args: "-c {{ remote_constraints }}"
notify: cleanup docker
# Detect docker CLI, API and docker-py versions # Detect docker CLI, API and docker-py versions
- name: Check Docker CLI version - name: Check Docker CLI version

View file

@ -0,0 +1,9 @@
- name: remove podman packages
yum:
name: 'podman*'
state: absent
listen: cleanup podman
- name: remove extras repo
command: "{{ repo_command[ansible_facts.distribution ~ ansible_facts.distribution_major_version]['disable'] | default('echo') }}"
listen: cleanup podman

View file

@ -1,12 +1,14 @@
- block: - block:
- name: Enable extras repo - name: Enable extras repo
command: "{{ repo_command[ansible_facts.distribution ~ ansible_facts.distribution_major_version] | default('echo') }}" command: "{{ repo_command[ansible_facts.distribution ~ ansible_facts.distribution_major_version]['enable'] | default('echo') }}"
notify: cleanup podman
- name: Install podman - name: Install podman
yum: yum:
name: "{{ podman_package }}" name: "{{ podman_package }}"
state: present state: present
when: ansible_facts.pkg_mgr in ['yum', 'dnf'] when: ansible_facts.pkg_mgr in ['yum', 'dnf']
notify: cleanup podman
- name: Get podman version - name: Get podman version
command: podman --version command: podman --version

View file

@ -1,2 +1,4 @@
repo_command: repo_command:
RedHat7: yum-config-manager --enable rhui-REGION-rhel-server-extras RedHat7:
enable: yum-config-manager --enable rhui-REGION-rhel-server-extras
disable: yum-config-manager --disable rhui-REGION-rhel-server-extras