From 4099eb41b91d29f0be059288651c326d239b36ed Mon Sep 17 00:00:00 2001 From: Chris Houseknecht Date: Wed, 29 Mar 2017 22:48:21 +0200 Subject: [PATCH] Treats both [] and {} as equal to None (#23088) --- lib/ansible/modules/cloud/docker/docker_container.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/cloud/docker/docker_container.py b/lib/ansible/modules/cloud/docker/docker_container.py index 878294a43db..7081d3c5a13 100644 --- a/lib/ansible/modules/cloud/docker/docker_container.py +++ b/lib/ansible/modules/cloud/docker/docker_container.py @@ -1288,10 +1288,19 @@ class Container(DockerBaseClass): set_a = set(getattr(self.parameters, key)) set_b = set(value) match = (set_a <= set_b) + elif isinstance(getattr(self.parameters, key), list) and not len(getattr(self.parameters, key)) \ + and value is None: + # an empty list and None are == + continue elif isinstance(getattr(self.parameters, key), dict) and isinstance(value, dict): # compare two dicts self.log("comparing two dicts: %s" % key) match = self._compare_dicts(getattr(self.parameters, key), value) + + elif isinstance(getattr(self.parameters, key), dict) and \ + not len(list(getattr(self.parameters, key).keys())) and value is None: + # an empty dict and None are == + continue else: # primitive compare self.log("primitive compare: %s" % key) @@ -1689,7 +1698,7 @@ class ContainerManager(DockerBaseClass): def present(self, state): container = self._get_container(self.parameters.name) image = self._get_image() - + self.log(image, pretty_print=True) if not container.exists: # New container self.log('No container found')