From ed1640e9dc56ffee6cc399c4f7de4630d01bd812 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Wed, 24 Apr 2019 04:27:16 +0200 Subject: [PATCH] [2.7] docker_container: fix support for docker-py 1.7.0 (#55496) * In theory, some 2.7 modules support docker-py 1.7.0. * Add changelog. --- .../fragments/55496-docker_container-docker-py-1.7.0.yml | 2 ++ lib/ansible/modules/cloud/docker/docker_container.py | 6 ++++-- test/integration/targets/docker_container/tasks/main.yml | 2 +- test/integration/targets/docker_image/tasks/main.yml | 4 ++-- test/integration/targets/docker_image_facts/tasks/main.yml | 4 ++-- test/integration/targets/docker_network/tasks/main.yml | 4 ++-- 6 files changed, 13 insertions(+), 9 deletions(-) create mode 100644 changelogs/fragments/55496-docker_container-docker-py-1.7.0.yml diff --git a/changelogs/fragments/55496-docker_container-docker-py-1.7.0.yml b/changelogs/fragments/55496-docker_container-docker-py-1.7.0.yml new file mode 100644 index 00000000000..c1bf3202827 --- /dev/null +++ b/changelogs/fragments/55496-docker_container-docker-py-1.7.0.yml @@ -0,0 +1,2 @@ +bugfixes: +- "docker_container - make again compatible with docker-py 1.7.0." diff --git a/lib/ansible/modules/cloud/docker/docker_container.py b/lib/ansible/modules/cloud/docker/docker_container.py index 11bbef2cf49..519609a540e 100644 --- a/lib/ansible/modules/cloud/docker/docker_container.py +++ b/lib/ansible/modules/cloud/docker/docker_container.py @@ -991,12 +991,14 @@ class TaskParameters(DockerBaseClass): group_add='groups', devices='devices', pid_mode='pid_mode', - tmpfs='tmpfs', init='init', uts_mode='uts', auto_remove='auto_remove', ) + if self.client.docker_py_version >= LooseVersion('1.8'): + host_config_params['tmpfs'] = 'tmpfs' + if self.client.docker_py_version >= LooseVersion('1.9') and self.client.docker_api_version >= LooseVersion('1.22'): # blkio_weight can always be updated, but can only be set on creation # when docker-py and docker API are new enough @@ -2267,7 +2269,7 @@ class AnsibleDockerClientContainer(AnsibleDockerClient): oom_score_adj=dict(docker_api_version='1.22', docker_py_version='2.0.0'), shm_size=dict(docker_api_version='1.22'), stop_signal=dict(docker_api_version='1.21'), - tmpfs=dict(docker_api_version='1.22'), + tmpfs=dict(docker_api_version='1.22', docker_py_version='1.8.0'), volume_driver=dict(docker_api_version='1.21'), memory_reservation=dict(docker_api_version='1.21'), kernel_memory=dict(docker_api_version='1.21'), diff --git a/test/integration/targets/docker_container/tasks/main.yml b/test/integration/targets/docker_container/tasks/main.yml index 7e4ba70fd47..efa528744a9 100644 --- a/test/integration/targets/docker_container/tasks/main.yml +++ b/test/integration/targets/docker_container/tasks/main.yml @@ -30,7 +30,7 @@ with_items: "{{ dnetworks }}" when: docker_py_version is version('1.10.0', '>=') - when: docker_py_version is version('1.8.0', '>=') and docker_api_version is version('1.20', '>=') + when: docker_py_version is version('1.7.0', '>=') and docker_api_version is version('1.20', '>=') - fail: msg="Too old docker / docker-py version to run all docker_container tests!" when: not(docker_py_version is version('3.5.0', '>=') and docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6) diff --git a/test/integration/targets/docker_image/tasks/main.yml b/test/integration/targets/docker_image/tasks/main.yml index 8760413ccd1..df8c4fc8017 100644 --- a/test/integration/targets/docker_image/tasks/main.yml +++ b/test/integration/targets/docker_image/tasks/main.yml @@ -47,7 +47,7 @@ stop_timeout: 1 with_items: "{{ cnames }}" - when: docker_py_version is version('1.8.0', '>=') and docker_api_version is version('1.20', '>=') + when: docker_py_version is version('1.7.0', '>=') and docker_api_version is version('1.20', '>=') - fail: msg="Too old docker / docker-py version to run docker_image tests!" - when: not(docker_py_version is version('1.8.0', '>=') and docker_api_version is version('1.20', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6) + when: not(docker_py_version is version('1.7.0', '>=') and docker_api_version is version('1.20', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6) diff --git a/test/integration/targets/docker_image_facts/tasks/main.yml b/test/integration/targets/docker_image_facts/tasks/main.yml index 5eb25004aa6..4d857b64188 100644 --- a/test/integration/targets/docker_image_facts/tasks/main.yml +++ b/test/integration/targets/docker_image_facts/tasks/main.yml @@ -48,7 +48,7 @@ - "'hello-world:latest' in result.images[0].RepoTags" - "'alpine:3.8' in result.images[1].RepoTags" - when: docker_py_version is version('1.8.0', '>=') and docker_api_version is version('1.20', '>=') + when: docker_py_version is version('1.7.0', '>=') and docker_api_version is version('1.20', '>=') - fail: msg="Too old docker / docker-py version to run docker_image_facts tests!" - when: not(docker_py_version is version('1.8.0', '>=') and docker_api_version is version('1.20', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6) + when: not(docker_py_version is version('1.7.0', '>=') and docker_api_version is version('1.20', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6) diff --git a/test/integration/targets/docker_network/tasks/main.yml b/test/integration/targets/docker_network/tasks/main.yml index 19e9facbf78..a25692d365a 100644 --- a/test/integration/targets/docker_network/tasks/main.yml +++ b/test/integration/targets/docker_network/tasks/main.yml @@ -27,7 +27,7 @@ force: yes loop: "{{ dnetworks }}" - when: docker_py_version is version('1.10.0', '>=') and docker_api_version is version('1.20', '>=') # FIXME: find out API version! + when: docker_py_version is version('1.7.0', '>=') and docker_api_version is version('1.20', '>=') # FIXME: find out API version! - fail: msg="Too old docker / docker-py version to run docker_network tests!" - when: not(docker_py_version is version('1.10.0', '>=') and docker_api_version is version('1.20', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6) + when: not(docker_py_version is version('1.7.0', '>=') and docker_api_version is version('1.20', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)