From dc496ffeb494a28a867de91b468b111ff3d4b67f Mon Sep 17 00:00:00 2001 From: Chris Houseknecht Date: Mon, 11 Jul 2016 00:23:58 -0400 Subject: [PATCH] Fix purge_networks --- lib/ansible/modules/cloud/docker/docker_container.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/cloud/docker/docker_container.py b/lib/ansible/modules/cloud/docker/docker_container.py index 6fbe9bfa0fc..0d0d22f1be0 100644 --- a/lib/ansible/modules/cloud/docker/docker_container.py +++ b/lib/ansible/modules/cloud/docker/docker_container.py @@ -1688,7 +1688,7 @@ class ContainerManager(DockerBaseClass): if self.diff.get('differences'): self.diff['differences'].append(dict(network_differences=network_differences)) else: - self.diff['differences'] = dict(network_differences=network_differences) + self.diff['differences'] = [dict(network_differences=network_differences)] self.results['changed'] = True updated_container = self._add_networks(container, network_differences) @@ -1698,7 +1698,7 @@ class ContainerManager(DockerBaseClass): if self.diff.get('differences'): self.diff['differences'].append(dict(purge_networks=extra_networks)) else: - self.diff['differences'] = dict(purge_networks=extra_networks) + self.diff['differences'] = [dict(purge_networks=extra_networks)] self.results['changed'] = True updated_container = self._purge_networks(container, extra_networks) return updated_container @@ -1734,7 +1734,7 @@ class ContainerManager(DockerBaseClass): def _purge_networks(self, container, networks): for network in networks: self.results['actions'].append(dict(removed_from_network=network['name'])) - if not self.check_mode: + if not self.check_mode and network.get('id'): try: self.client.disconnect_container_from_network(container.Id, network['id']) except Exception as exc: