From 1a33e57970ae1b612b6c267fb993136e80f45b2e Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Mon, 4 Apr 2022 13:53:11 +0200 Subject: [PATCH] Minor bugfix when searching for nonexistent rule group --- plugins/modules/networkfirewall_rule_group_info.py | 6 ++++-- .../networkfirewall_rule_group/tasks/minimal.yml | 11 +++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/plugins/modules/networkfirewall_rule_group_info.py b/plugins/modules/networkfirewall_rule_group_info.py index 37cb6d2b0c1..b21e060795b 100644 --- a/plugins/modules/networkfirewall_rule_group_info.py +++ b/plugins/modules/networkfirewall_rule_group_info.py @@ -430,8 +430,10 @@ def main(): if name or arn: rule = manager.get_rule_group(name=name, rule_type=rule_type, arn=arn) - rules = [rule] - results['rule_groups'] = rules + if rule: + results['rule_groups'] = [rule] + else: + results['rule_groups'] = [] else: rule_list = manager.list(scope=scope) results['rule_list'] = rule_list diff --git a/tests/integration/targets/networkfirewall_rule_group/tasks/minimal.yml b/tests/integration/targets/networkfirewall_rule_group/tasks/minimal.yml index 75be7d8c486..73f96d3a585 100644 --- a/tests/integration/targets/networkfirewall_rule_group/tasks/minimal.yml +++ b/tests/integration/targets/networkfirewall_rule_group/tasks/minimal.yml @@ -50,6 +50,17 @@ - '"rule_groups" in account_rules_info' # We've not created anything yet, so there's no guarantee anything will be here + - name: 'Fetch non existent rule groups' + networkfirewall_rule_group_info: + name: '{{ minimal_group_name }}-Missing' + rule_type: 'stateful' + register: account_rules_info + + - assert: + that: + - '"rule_groups" in account_rules_info' + - account_rules_info.rule_groups | length == 0 + ################################################################### # Creation