diff options
author | Sam Doran <sdoran@redhat.com> | 2019-11-18 15:08:58 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-18 15:08:58 -0500 |
commit | 6b2b876d438ce65f5d6536c940eb6ee917295430 (patch) | |
tree | ea33dd43188e9aaaceebbc16b6bcc41952c37159 | |
parent | 163904fe37808a29b0e9af42e9efef8b7cb3c71f (diff) | |
download | ansible-6b2b876d438ce65f5d6536c940eb6ee917295430.tar.gz |
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.
13 files changed, 60 insertions, 6 deletions
diff --git a/test/integration/targets/inventory_docker_swarm/playbooks/swarm_cleanup.yml b/test/integration/targets/inventory_docker_swarm/playbooks/swarm_cleanup.yml index 85835b4f9d..9cf87159c6 100644 --- a/test/integration/targets/inventory_docker_swarm/playbooks/swarm_cleanup.yml +++ b/test/integration/targets/inventory_docker_swarm/playbooks/swarm_cleanup.yml @@ -1,9 +1,18 @@ --- - hosts: 127.0.0.1 connection: local - gather_facts: no + gather_facts: yes tasks: - name: Make sure swarm is removed docker_swarm: state: absent force: yes + + - name: remove docker pagkages + action: "{{ ansible_facts.pkg_mgr }}" + args: + name: + - docker + - docker-ce + - docker-ce-cli + state: absent diff --git a/test/integration/targets/inventory_docker_swarm/playbooks/swarm_setup.yml b/test/integration/targets/inventory_docker_swarm/playbooks/swarm_setup.yml index 2d026a233a..5b59c51a4f 100644 --- a/test/integration/targets/inventory_docker_swarm/playbooks/swarm_setup.yml +++ b/test/integration/targets/inventory_docker_swarm/playbooks/swarm_setup.yml @@ -1,10 +1,14 @@ --- - hosts: 127.0.0.1 connection: local + vars: + docker_skip_cleanup: yes + tasks: - name: Setup docker - include_role: + import_role: name: setup_docker + - name: Create a Swarm cluster docker_swarm: state: present diff --git a/test/integration/targets/setup_docker/defaults/main.yml b/test/integration/targets/setup_docker/defaults/main.yml index 9eeed89e38..f7be73dc0e 100644 --- a/test/integration/targets/setup_docker/defaults/main.yml +++ b/test/integration/targets/setup_docker/defaults/main.yml @@ -1,6 +1,7 @@ docker_cli_version: '0.0' docker_api_version: '0.0' docker_py_version: '0.0' +docker_skip_cleanup: no docker_prereq_packages: [] docker_packages: - docker-ce @@ -8,3 +9,8 @@ docker_packages: docker_pip_extra_packages: [] docker_pip_packages: - docker + +docker_cleanup_packages: + - docker + - docker-ce + - docker-ce-cli diff --git a/test/integration/targets/setup_docker/handlers/main.yml b/test/integration/targets/setup_docker/handlers/main.yml new file mode 100644 index 0000000000..93d9657cbb --- /dev/null +++ b/test/integration/targets/setup_docker/handlers/main.yml @@ -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 diff --git a/test/integration/targets/setup_docker/tasks/Debian.yml b/test/integration/targets/setup_docker/tasks/Debian.yml index da81ac77b3..0ea2cb4be2 100644 --- a/test/integration/targets/setup_docker/tasks/Debian.yml +++ b/test/integration/targets/setup_docker/tasks/Debian.yml @@ -7,6 +7,7 @@ name: "{{ docker_prereq_packages }}" state: present update_cache: yes + notify: cleanup docker - name: Add gpg key shell: curl -fsSL https://download.docker.com/linux/ubuntu/gpg >key && apt-key add key diff --git a/test/integration/targets/setup_docker/tasks/Fedora.yml b/test/integration/targets/setup_docker/tasks/Fedora.yml index aefc79ec4b..a2fd45ef76 100644 --- a/test/integration/targets/setup_docker/tasks/Fedora.yml +++ b/test/integration/targets/setup_docker/tasks/Fedora.yml @@ -18,3 +18,4 @@ name: "{{ docker_packages }}" state: present enablerepo: docker-ce-test + notify: cleanup docker diff --git a/test/integration/targets/setup_docker/tasks/RedHat-7.yml b/test/integration/targets/setup_docker/tasks/RedHat-7.yml index 813c014380..cacc708dc8 100644 --- a/test/integration/targets/setup_docker/tasks/RedHat-7.yml +++ b/test/integration/targets/setup_docker/tasks/RedHat-7.yml @@ -5,6 +5,7 @@ yum: name: "{{ docker_prereq_packages }}" 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) include_role: @@ -29,6 +30,7 @@ yum: name: "{{ docker_packages }}" state: present + notify: cleanup docker - name: Make sure the docker daemon is running (failure expected inside docker container) service: diff --git a/test/integration/targets/setup_docker/tasks/RedHat-8.yml b/test/integration/targets/setup_docker/tasks/RedHat-8.yml index d6a775c197..bc88051c58 100644 --- a/test/integration/targets/setup_docker/tasks/RedHat-8.yml +++ b/test/integration/targets/setup_docker/tasks/RedHat-8.yml @@ -5,6 +5,7 @@ dnf: name: "{{ docker_prereq_packages }}" state: present + notify: cleanup docker - name: Set-up repository command: dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo @@ -15,6 +16,7 @@ dnf: name: "{{ docker_packages }}" state: present + notify: cleanup docker - name: Make sure the docker daemon is running (failure expected inside docker container) service: diff --git a/test/integration/targets/setup_docker/tasks/Suse.yml b/test/integration/targets/setup_docker/tasks/Suse.yml index bc4bd4f187..8183194149 100644 --- a/test/integration/targets/setup_docker/tasks/Suse.yml +++ b/test/integration/targets/setup_docker/tasks/Suse.yml @@ -4,3 +4,4 @@ force: yes disable_gpg_check: yes update_cache: yes + notify: cleanup docker diff --git a/test/integration/targets/setup_docker/tasks/main.yml b/test/integration/targets/setup_docker/tasks/main.yml index 16f1f24675..ca8ed38f41 100644 --- a/test/integration/targets/setup_docker/tasks/main.yml +++ b/test/integration/targets/setup_docker/tasks/main.yml @@ -12,7 +12,7 @@ - "{{ ansible_facts.os_family }}.yml" - default.yml paths: - - vars + - "{{ role_path }}/vars" - name: Include distribution specific tasks include_tasks: "{{ lookup('first_found', params) }}" @@ -24,13 +24,14 @@ - "{{ ansible_facts.distribution }}.yml" - "{{ ansible_facts.os_family }}.yml" paths: - - tasks + - "{{ role_path }}/tasks" - name: Install Python requirements pip: state: present name: "{{ docker_pip_packages | union(docker_pip_extra_packages) }}" extra_args: "-c {{ remote_constraints }}" + notify: cleanup docker # Detect docker CLI, API and docker-py versions - name: Check Docker CLI version diff --git a/test/integration/targets/setup_podman/handlers/main.yml b/test/integration/targets/setup_podman/handlers/main.yml new file mode 100644 index 0000000000..93f11e5e84 --- /dev/null +++ b/test/integration/targets/setup_podman/handlers/main.yml @@ -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 diff --git a/test/integration/targets/setup_podman/tasks/main.yml b/test/integration/targets/setup_podman/tasks/main.yml index 0cd9ca20c9..ab7b66f7d9 100644 --- a/test/integration/targets/setup_podman/tasks/main.yml +++ b/test/integration/targets/setup_podman/tasks/main.yml @@ -1,12 +1,14 @@ - block: - 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 yum: name: "{{ podman_package }}" state: present when: ansible_facts.pkg_mgr in ['yum', 'dnf'] + notify: cleanup podman - name: Get podman version command: podman --version diff --git a/test/integration/targets/setup_podman/vars/main.yml b/test/integration/targets/setup_podman/vars/main.yml index b42f8e0ad9..a79922f9fb 100644 --- a/test/integration/targets/setup_podman/vars/main.yml +++ b/test/integration/targets/setup_podman/vars/main.yml @@ -1,2 +1,4 @@ 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 |