From 463fb5a058d6d60288df3e6263c91e1be4d3310b Mon Sep 17 00:00:00 2001 From: Sam Yaple Date: Tue, 13 Oct 2015 10:24:36 +0000 Subject: [PATCH] Don't assume ExposedPorts exists (bug #2257) A recent change [1] in docker between v1.8.2 and v1.8.3 changed what is returned in the json when inspecting an image. Five variables which could have been expected before will now be omited when empty. Only one of those variables is being addressed in the docker, ExposedPorts. Unfortunately there was also no API version change on this so this can't be easily corrected with pinning the API to the older version. This does a get() which will return None if the variable is not in the dict formed from the json that was returned. Everything else works the same way. [1] https://github.com/docker/docker/commit/9098628b2901ae8585ba4c66ee6e14759d2119da --- lib/ansible/modules/cloud/docker/docker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/modules/cloud/docker/docker.py b/lib/ansible/modules/cloud/docker/docker.py index 261ab68cbb9..029f913ff29 100644 --- a/lib/ansible/modules/cloud/docker/docker.py +++ b/lib/ansible/modules/cloud/docker/docker.py @@ -1067,7 +1067,7 @@ class DockerManager(object): continue # EXPOSED PORTS - expected_exposed_ports = set((image['ContainerConfig']['ExposedPorts'] or {}).keys()) + expected_exposed_ports = set((image['ContainerConfig'].get('ExposedPorts') or {}).keys()) for p in (self.exposed_ports or []): expected_exposed_ports.add("/".join(p))