From 39aa740531f171a557e8604babd493793d63323e Mon Sep 17 00:00:00 2001 From: Chris Houseknecht Date: Sat, 10 Sep 2016 03:02:50 -0400 Subject: [PATCH] Use LooseVersion comparison. Default docker_api_version to 'auto'. --- lib/ansible/module_utils/docker_common.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/ansible/module_utils/docker_common.py b/lib/ansible/module_utils/docker_common.py index e5651bac4a7..9a54be64d50 100644 --- a/lib/ansible/module_utils/docker_common.py +++ b/lib/ansible/module_utils/docker_common.py @@ -22,6 +22,7 @@ import json import sys import copy +from distutils.version import LooseVersion from urlparse import urlparse from ansible.module_utils.basic import * @@ -151,7 +152,7 @@ class AnsibleDockerClient(Client): if not HAS_DOCKER_PY: self.fail("Failed to import docker-py - %s. Try `pip install docker-py`" % HAS_DOCKER_ERROR) - if docker_version < MIN_DOCKER_VERSION: + if LooseVersion(docker_version) < LooseVersion(MIN_DOCKER_VERSION): self.fail("Error: docker-py version is %s. Minimum version required is %s." % (docker_version, MIN_DOCKER_VERSION)) @@ -233,7 +234,7 @@ class AnsibleDockerClient(Client): tls_hostname=self._get_value('tls_hostname', params['tls_hostname'], 'DOCKER_TLS_HOSTNAME', 'localhost'), api_version=self._get_value('api_version', params['api_version'], 'DOCKER_API_VERSION', - DEFAULT_DOCKER_API_VERSION), + 'auto'), cacert_path=self._get_value('cacert_path', params['cacert_path'], 'DOCKER_CERT_PATH', None), cert_path=self._get_value('cert_path', params['cert_path'], 'DOCKER_CERT_PATH', None), key_path=self._get_value('key_path', params['key_path'], 'DOCKER_CERT_PATH', None),