diff --git a/module_utils/network_lsr/argument_validator.py b/module_utils/network_lsr/argument_validator.py index e3b0316..b5a9253 100644 --- a/module_utils/network_lsr/argument_validator.py +++ b/module_utils/network_lsr/argument_validator.py @@ -407,6 +407,11 @@ class ArgValidatorList(ArgValidator): # not supported. If you need that, define a proper list. value = [s for s in value.split(" ") if s] + if value is None: + # Users might want to use jinja2 templates to set properties. As such, + # it's convenient to accept None as an alias for an empty list + # e.g. setting like `"match": {"path": None}` will be allowed by the role + return [] result = [] for (idx, v) in enumerate(value): try: diff --git a/tests/unit/test_network_connections.py b/tests/unit/test_network_connections.py index 79358f7..74f4d37 100644 --- a/tests/unit/test_network_connections.py +++ b/tests/unit/test_network_connections.py @@ -445,6 +445,7 @@ class TestValidator(unittest.TestCase): ) self.assertEqual([1, 5], v.validate(["1", 5])) self.assertValidationError(v, [1, "s"]) + self.assertEqual(v.validate(None), []) def test_empty(self): self.maxDiff = None