mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-22 22:11:44 -07:00
Add option to fail on undefined variables to listify
And use it in the call to get the loop items for a task.
This commit is contained in:
parent
a586c74967
commit
2673eb0afb
3 changed files with 14 additions and 7 deletions
|
@ -26,14 +26,14 @@ from ansible.template.safe_eval import safe_eval
|
|||
__all__ = ['listify_lookup_plugin_terms']
|
||||
|
||||
#FIXME: probably just move this into lookup plugin base class
|
||||
def listify_lookup_plugin_terms(terms, variables, loader):
|
||||
def listify_lookup_plugin_terms(terms, variables, loader, fail_on_undefined=False):
|
||||
|
||||
if isinstance(terms, basestring):
|
||||
stripped = terms.strip()
|
||||
templar = Templar(loader=loader, variables=variables)
|
||||
|
||||
#FIXME: warn/deprecation on bare vars in with_ so we can eventually remove fail on undefined override
|
||||
terms = templar.template(terms, convert_bare=True, fail_on_undefined=False)
|
||||
terms = templar.template(terms, convert_bare=True, fail_on_undefined=fail_on_undefined)
|
||||
|
||||
#TODO: check if this is needed as template should also return correct type already
|
||||
terms = safe_eval(terms)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue