mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 14:22:46 +00:00
fix combine filter using undefined vars (#55840)
* Check variables are defined before using combine filter * Add tests for the combine filter * Remove dependencies that should already be installed * relocate the function to recursively check for undefined vars add another test * changelog
This commit is contained in:
committed by
Brian Coca
parent
c4004b5fb1
commit
11279a909d
@@ -178,6 +178,20 @@ def _count_newlines_from_end(in_str):
|
||||
return i
|
||||
|
||||
|
||||
def recursive_check_defined(item):
|
||||
from jinja2.runtime import Undefined
|
||||
|
||||
if isinstance(item, MutableMapping):
|
||||
for key in item:
|
||||
recursive_check_defined(item[key])
|
||||
elif isinstance(item, list):
|
||||
for i in item:
|
||||
recursive_check_defined(i)
|
||||
else:
|
||||
if isinstance(item, Undefined):
|
||||
raise AnsibleFilterError("{0} is undefined".format(item))
|
||||
|
||||
|
||||
class AnsibleUndefined(StrictUndefined):
|
||||
'''
|
||||
A custom Undefined class, which returns further Undefined objects on access,
|
||||
|
||||
Reference in New Issue
Block a user