From 0e7dd18650108397e0e9dc9b59350f6884c86fcb Mon Sep 17 00:00:00 2001 From: Robert Simmons Date: Thu, 26 Jan 2017 15:17:55 -0600 Subject: [PATCH] =?UTF-8?q?Fixed=20issue=20in=20gce=5Fnet=20with=20firewal?= =?UTF-8?q?l=20rules=20that=20have=20protocols=20that=20d=E2=80=A6=20(#205?= =?UTF-8?q?28)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fixed issue in gce_net with firewall rules that have protocols that do not have ports. * Fixed elif in gce_net to include check of the ports variable. --- lib/ansible/modules/cloud/google/gce_net.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/cloud/google/gce_net.py b/lib/ansible/modules/cloud/google/gce_net.py index 6e36ae3081..1dc1c33fb2 100644 --- a/lib/ansible/modules/cloud/google/gce_net.py +++ b/lib/ansible/modules/cloud/google/gce_net.py @@ -208,7 +208,7 @@ def format_allowed_section(allowed): return [] if ports.count(","): ports = ports.split(",") - else: + elif ports: ports = [ports] return_val = {"IPProtocol": protocol} if ports: @@ -231,7 +231,7 @@ def sorted_allowed_list(allowed_list): # sort by protocol allowed_by_protocol = sorted(allowed_list,key=lambda x: x['IPProtocol']) # sort the ports list - return sorted(allowed_by_protocol, key=lambda y: y['ports'].sort()) + return sorted(allowed_by_protocol, key=lambda y: y.get('ports', []).sort()) def main():