From 2ea9cfcd52ebf2c2c25e581c197141d125d6acad Mon Sep 17 00:00:00 2001 From: William Date: Tue, 11 Sep 2018 12:45:42 -0700 Subject: [PATCH] Fix python 3 compatibility for network id lookup (#45467) Due to a change in python 3 filters return filter instead of list. This breaks the network name to id lookup for the docker_swarm_module. By wrapping it in list it ensures it is a list when returned and the id is extracted. --- lib/ansible/modules/cloud/docker/docker_swarm_service.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/modules/cloud/docker/docker_swarm_service.py b/lib/ansible/modules/cloud/docker/docker_swarm_service.py index 319e5cdb070..034c7ab3656 100644 --- a/lib/ansible/modules/cloud/docker/docker_swarm_service.py +++ b/lib/ansible/modules/cloud/docker/docker_swarm_service.py @@ -838,7 +838,7 @@ class DockerService(DockerBaseClass): for network_name in self.networks: network_id = None try: - network_id = filter(lambda n: n['name'] == network_name, docker_networks)[0]['id'] + network_id = list(filter(lambda n: n['name'] == network_name, docker_networks))[0]['id'] except: pass if network_id: