From ff0d0ceb70033d2c95eb618acc349e857690ce74 Mon Sep 17 00:00:00 2001 From: Ash Wilson Date: Mon, 9 Mar 2015 12:17:39 -0400 Subject: [PATCH] Expect module env vars to override Dockerfile ones. --- lib/ansible/modules/cloud/docker/docker.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/cloud/docker/docker.py b/lib/ansible/modules/cloud/docker/docker.py index 6189ffdd51..23abf01b61 100644 --- a/lib/ansible/modules/cloud/docker/docker.py +++ b/lib/ansible/modules/cloud/docker/docker.py @@ -846,11 +846,20 @@ class DockerManager(object): # actual_env is likely to include environment variables injected by # the Dockerfile. - expected_env = set(image['ContainerConfig']['Env'] or []) + expected_env = {} + + for image_env in image['ContainerConfig']['Env'] or []: + name, value = image_env.split('=', 1) + expected_env[name] = value + if self.env: for name, value in self.env.iteritems(): - expected_env.add("{}={}".format(name, value)) - actual_env = set(container['Config']['Env'] or []) + expected_env[name] = value + + actual_env = {} + for container_env in container['Config']['Env'] or []: + name, value = container_env.split('=', 1) + actual_env[name] = value if actual_env != expected_env: # Don't include the environment difference in the output.