From 2f523ad08e08be59f233d2d45fb1b541c7f2369f Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sun, 26 May 2019 14:15:25 +0200 Subject: [PATCH] docker conncetion plugin: accept 'dev' as 'newest version' (#56947) * Accept 'dev' as 'newest version'. * Add changelog. * Fix YAML. --- changelogs/fragments/56947-docker-dev.yml | 2 ++ lib/ansible/plugins/connection/docker.py | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/56947-docker-dev.yml diff --git a/changelogs/fragments/56947-docker-dev.yml b/changelogs/fragments/56947-docker-dev.yml new file mode 100644 index 00000000000..a600ff58f26 --- /dev/null +++ b/changelogs/fragments/56947-docker-dev.yml @@ -0,0 +1,2 @@ +bugfixes: +- "docker connection plugin - accept version ``dev`` as 'newest version' and print warning." diff --git a/lib/ansible/plugins/connection/docker.py b/lib/ansible/plugins/connection/docker.py index d6d3518630a..f393bba8570 100644 --- a/lib/ansible/plugins/connection/docker.py +++ b/lib/ansible/plugins/connection/docker.py @@ -84,7 +84,9 @@ class Connection(ConnectionBase): raise AnsibleError("docker command not found in PATH") docker_version = self._get_docker_version() - if LooseVersion(docker_version) < LooseVersion(u'1.3'): + if docker_version == u'dev': + display.warning(u'Docker version number is "dev". Will assume latest version.') + if docker_version != u'dev' and LooseVersion(docker_version) < LooseVersion(u'1.3'): raise AnsibleError('docker connection type requires docker 1.3 or higher') # The remote user we will request from docker (if supported) @@ -93,7 +95,7 @@ class Connection(ConnectionBase): self.actual_user = None if self._play_context.remote_user is not None: - if LooseVersion(docker_version) >= LooseVersion(u'1.7'): + if docker_version == u'dev' or LooseVersion(docker_version) >= LooseVersion(u'1.7'): # Support for specifying the exec user was added in docker 1.7 self.remote_user = self._play_context.remote_user self.actual_user = self.remote_user