From 55130b960bb565a20f5b54987cb0964164b32d8c Mon Sep 17 00:00:00 2001 From: Christophe Biocca Date: Wed, 9 Nov 2016 16:42:27 -0500 Subject: [PATCH] haproxy: Fix compatibility when map is actually imap. (#3350) While I still have no idea why or how the `map` call is being swapped out while still running in python 2.7, this change will fix the following error, as well as improve py3 compatibility. --- lib/ansible/modules/extras/network/haproxy.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/extras/network/haproxy.py b/lib/ansible/modules/extras/network/haproxy.py index 2fc11987d5..0d1db0397e 100644 --- a/lib/ansible/modules/extras/network/haproxy.py +++ b/lib/ansible/modules/extras/network/haproxy.py @@ -211,7 +211,7 @@ class HAProxy(object): """ data = self.execute('show stat', 200, False).lstrip('# ') r = csv.DictReader(data.splitlines()) - return map(lambda d: d['pxname'], filter(lambda d: d['svname'] == 'BACKEND', r)) + return tuple(map(lambda d: d['pxname'], filter(lambda d: d['svname'] == 'BACKEND', r))) def execute_for_backends(self, cmd, pxname, svname, wait_for_status = None): @@ -244,7 +244,7 @@ class HAProxy(object): """ data = self.execute('show stat', 200, False).lstrip('# ') r = csv.DictReader(data.splitlines()) - state = map(lambda d: { 'status': d['status'], 'weight': d['weight'] }, filter(lambda d: (pxname is None or d['pxname'] == pxname) and d['svname'] == svname, r)) + state = tuple(map(lambda d: { 'status': d['status'], 'weight': d['weight'] }, filter(lambda d: (pxname is None or d['pxname'] == pxname) and d['svname'] == svname, r))) return state or None