From 964b7ecffa1056d0d2da8afb2938b625107328ee Mon Sep 17 00:00:00 2001 From: chouseknecht Date: Sat, 27 Aug 2016 08:00:13 -0400 Subject: [PATCH] Fix container labels expected vs actual comparison. --- lib/ansible/modules/cloud/docker/_docker.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/ansible/modules/cloud/docker/_docker.py b/lib/ansible/modules/cloud/docker/_docker.py index 439f537a6dd..a966fd0c849 100644 --- a/lib/ansible/modules/cloud/docker/_docker.py +++ b/lib/ansible/modules/cloud/docker/_docker.py @@ -1307,10 +1307,12 @@ class DockerManager(object): for name, value in self.module.params.get('labels').iteritems(): expected_labels[name] = str(value) - actual_labels = {} - for container_label in container['Config']['Labels'] or []: - name, value = container_label.split('=', 1) - actual_labels[name] = value + if type(container['Config']['Labels']) is dict: + actual_labels = container['Config']['Labels'] + else: + for container_label in container['Config']['Labels'] or []: + name, value = container_label.split('=', 1) + actual_labels[name] = value if actual_labels != expected_labels: self.reload_reasons.append('labels {0} => {1}'.format(actual_labels, expected_labels))