diff --git a/plugins/module_utils/rule.py b/plugins/module_utils/rule.py index 54d5a6d0..25ace9ea 100644 --- a/plugins/module_utils/rule.py +++ b/plugins/module_utils/rule.py @@ -154,7 +154,10 @@ def _parse_floating_interfaces(self, interfaces): """ validate param interface field when floating is true """ res = [] for interface in interfaces.split(','): - res.append(self.pfsense.parse_interface(interface)) + if interface == 'any': + res.append(interface) + else: + res.append(self.pfsense.parse_interface(interface)) self._floating_interfaces = interfaces return ','.join(res) diff --git a/plugins/modules/pfsense_rule.py b/plugins/modules/pfsense_rule.py index 749358ef..0c22db1e 100644 --- a/plugins/modules/pfsense_rule.py +++ b/plugins/modules/pfsense_rule.py @@ -42,7 +42,7 @@ default: false type: bool interface: - description: The interface for the rule + description: The interface for the rule. Use 'any' to apply to all interface (for floating rules only). required: true type: str floating: diff --git a/tests/unit/plugins/modules/test_pfsense_rule_create.py b/tests/unit/plugins/modules/test_pfsense_rule_create.py index 3855a37a..fd2fa61d 100644 --- a/tests/unit/plugins/modules/test_pfsense_rule_create.py +++ b/tests/unit/plugins/modules/test_pfsense_rule_create.py @@ -66,6 +66,17 @@ def test_rule_create_floating(self): command = "create rule 'one_rule' on 'floating(lan)', source='any', destination='any', direction='any'" self.do_module_test(obj, command=command) + def test_rule_create_floating_any(self): + """ test creation of a new floating rule with any interface """ + obj = dict(name='one_rule', source='any', destination='any', interface='any', floating='yes', direction='any') + command = "create rule 'one_rule' on 'floating(any)', source='any', destination='any', direction='any'" + + def test_rule_create_non_floating_any(self): + """ test creation of a new rule with any interface """ + obj = dict(name='one_rule', source='any', destination='any', interface='any', floating='no', direction='any') + msg = "any is not a valid interface" + self.do_module_test(obj, failed=True, msg=msg) + def test_rule_create_floating_quick(self): """ test creation of a new floating rule with quick match """ obj = dict(name='one_rule', source='any', destination='any', interface='lan', floating='yes', direction='any', quick='yes')