From af5e402b878ae65022c211379bbd1a759eb0ae26 Mon Sep 17 00:00:00 2001 From: Micheal Waltz Date: Thu, 23 Jul 2015 11:34:33 -0700 Subject: [PATCH] Set the API version when checking differences in containers and use this to determine the location of the Memory value depending on the version used. In v1.18 and earlier it was ['Config']['Memory'], but in v1.19 it changed to ['HostConfig']['Memory']. --- lib/ansible/modules/cloud/docker/docker.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/ansible/modules/cloud/docker/docker.py b/lib/ansible/modules/cloud/docker/docker.py index 492d3e951ab..ddc6ff38bcf 100644 --- a/lib/ansible/modules/cloud/docker/docker.py +++ b/lib/ansible/modules/cloud/docker/docker.py @@ -970,6 +970,9 @@ class DockerManager(object): running = self.get_running_containers() current = self.get_inspect_containers(running) + #Get API version + api_version = self.client.version()['ApiVersion'] + image = self.get_inspect_image() if image is None: # The image isn't present. Assume that we're about to pull a new @@ -1038,6 +1041,10 @@ class DockerManager(object): actual_mem = container['HostConfig']['Memory'] + #Use v1.18 API and earlier Memory element location + if docker_api_version <= 1.18: + actual_mem = container['Config']['Memory'] + if expected_mem and actual_mem != expected_mem: self.reload_reasons.append('memory ({0} => {1})'.format(actual_mem, expected_mem)) differing.append(container)