From b7e78656ac1288d36b3032543f49faa05d9c9a01 Mon Sep 17 00:00:00 2001 From: Robert Simmons Date: Wed, 8 Feb 2017 07:49:04 -0600 Subject: [PATCH] [cloud] gce_net fix for unsetting firewall rule properties in the project. (#20483) --- lib/ansible/modules/cloud/google/gce_net.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/cloud/google/gce_net.py b/lib/ansible/modules/cloud/google/gce_net.py index 6c8f02cd641..d1daddf40d4 100644 --- a/lib/ansible/modules/cloud/google/gce_net.py +++ b/lib/ansible/modules/cloud/google/gce_net.py @@ -357,6 +357,9 @@ def main(): fw.allowed = allowed_list fw_changed = True + # source_ranges might not be set in the project; cast it to an empty list + fw.source_ranges = fw.source_ranges or [] + # If these attributes are lists, we sort them first, then compare. # Otherwise, we update if they differ. if fw.source_ranges != src_range: @@ -368,8 +371,11 @@ def main(): fw.source_ranges = src_range fw_changed = True + # source_tags might not be set in the project; cast it to an empty list + fw.source_tags = fw.source_tags or [] + if fw.source_tags != src_tags: - if isinstance(src_range, list): + if isinstance(src_tags, list): if sorted(fw.source_tags) != sorted(src_tags): fw.source_tags = src_tags fw_changed = True @@ -377,6 +383,9 @@ def main(): fw.source_tags = src_tags fw_changed = True + # target_tags might not be set in the project; cast it to an empty list + fw.target_tags = fw.target_tags or [] + if fw.target_tags != target_tags: if isinstance(target_tags, list): if sorted(fw.target_tags) != sorted(target_tags):