From bc665fca9c580b3600832a48b66f2ab3b429b845 Mon Sep 17 00:00:00 2001 From: chouseknecht Date: Sun, 29 May 2016 09:19:54 -0400 Subject: [PATCH] Fix for issue #3775 - env config comparison --- lib/ansible/modules/cloud/docker/docker_container.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/cloud/docker/docker_container.py b/lib/ansible/modules/cloud/docker/docker_container.py index 5fac1ceb478..a999a388bbb 100644 --- a/lib/ansible/modules/cloud/docker/docker_container.py +++ b/lib/ansible/modules/cloud/docker/docker_container.py @@ -1273,10 +1273,15 @@ class Container(DockerBaseClass): def _get_expected_env(self, image): self.log('_get_expected_env') - param_env = (self._convert_simple_dict_to_list('env', '=') or []) + expected_env = dict() if image and image['ContainerConfig'].get('Env'): - image_env = image['ContainerConfig'].get('Env') - param_env = list(set(param_env + image_env)) + for env_var in image['ContainerConfig']['Env']: + parts = env_var.split('=') + expected_env[parts[0]] = parts[1] + expected_env.update(self.parameters.env) + param_env = [] + for key, value in expected_env.items(): + param_env.append("%s=%s" % (key, value)) return param_env def _get_expected_exposed(self, image):