From dc9cab36acd40ef76a7b6a7c0992cb28752e26c8 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Tue, 11 Aug 2020 10:04:14 +0200 Subject: [PATCH] Try to fix docker tests (#764) * Try to limit docker package version if API version is < 1.39. * Fix error. * Re-combine to one command. (cherry picked from commit a00d615d684f7c9b005c89bf1c38a48ade3680bc) --- .../targets/setup_docker/defaults/main.yml | 4 ++-- .../targets/setup_docker/handlers/main.yml | 2 +- .../integration/targets/setup_docker/tasks/main.yml | 13 ++++++++++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/tests/integration/targets/setup_docker/defaults/main.yml b/tests/integration/targets/setup_docker/defaults/main.yml index f7be73dc0e..10cc590327 100644 --- a/tests/integration/targets/setup_docker/defaults/main.yml +++ b/tests/integration/targets/setup_docker/defaults/main.yml @@ -7,8 +7,8 @@ docker_packages: - docker-ce docker_pip_extra_packages: [] -docker_pip_packages: - - docker +docker_pip_package: docker +docker_pip_package_limit: '' docker_cleanup_packages: - docker diff --git a/tests/integration/targets/setup_docker/handlers/main.yml b/tests/integration/targets/setup_docker/handlers/main.yml index 93d9657cbb..c10960ddc0 100644 --- a/tests/integration/targets/setup_docker/handlers/main.yml +++ b/tests/integration/targets/setup_docker/handlers/main.yml @@ -1,7 +1,7 @@ - name: remove pip packages pip: state: present - name: "{{ docker_pip_packages | union(docker_pip_extra_packages) }}" + name: "{{ [docker_pip_package] | union(docker_pip_extra_packages) }}" listen: cleanup docker when: not docker_skip_cleanup | bool diff --git a/tests/integration/targets/setup_docker/tasks/main.yml b/tests/integration/targets/setup_docker/tasks/main.yml index f7c41986ac..80c3f662f8 100644 --- a/tests/integration/targets/setup_docker/tasks/main.yml +++ b/tests/integration/targets/setup_docker/tasks/main.yml @@ -27,10 +27,21 @@ paths: - "{{ role_path }}/tasks" + # Detect docker API version + - name: Check Docker API version + command: "docker version -f {% raw %}'{{(index .Server.Components 0).Details.ApiVersion}}'{% endraw %}" + register: docker_api_version_stdout + ignore_errors: yes + + - name: Limit docker pypi package version to < 4.3.0 + set_fact: + docker_pip_package_limit: '<4.3.0' + when: (docker_api_version_stdout.stdout | default('0.0')) is version('1.39', '<') + - name: Install Python requirements pip: state: present - name: "{{ docker_pip_packages | union(docker_pip_extra_packages) }}" + name: "{{ [docker_pip_package ~ docker_pip_package_limit] + docker_pip_extra_packages }}" extra_args: "-c {{ remote_constraints }}" notify: cleanup docker