mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #5131 from janeznemanic/devel
Fix for issue #4730 - stacktrace when deferenencing a non-existent group
This commit is contained in:
commit
1679d83637
1 changed files with 5 additions and 4 deletions
|
@ -532,13 +532,14 @@ def template_from_string(basedir, data, vars, fail_on_undefined=False):
|
||||||
return lookup(*args, basedir=basedir, **kwargs)
|
return lookup(*args, basedir=basedir, **kwargs)
|
||||||
|
|
||||||
t.globals['lookup'] = my_lookup
|
t.globals['lookup'] = my_lookup
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
jvars =_jinja2_vars(basedir, vars, t.globals, fail_on_undefined)
|
jvars =_jinja2_vars(basedir, vars, t.globals, fail_on_undefined)
|
||||||
new_context = t.new_context(jvars, shared=True)
|
new_context = t.new_context(jvars, shared=True)
|
||||||
rf = t.root_render_func(new_context)
|
rf = t.root_render_func(new_context)
|
||||||
|
try:
|
||||||
res = jinja2.utils.concat(rf)
|
res = jinja2.utils.concat(rf)
|
||||||
|
except TypeError, te:
|
||||||
|
if 'StrictUndefined' in str(te):
|
||||||
|
raise errors.AnsibleUndefinedVariable("unable to look up a name or access an attribute in template string")
|
||||||
return res
|
return res
|
||||||
except (jinja2.exceptions.UndefinedError, errors.AnsibleUndefinedVariable):
|
except (jinja2.exceptions.UndefinedError, errors.AnsibleUndefinedVariable):
|
||||||
if fail_on_undefined:
|
if fail_on_undefined:
|
||||||
|
|
Loading…
Reference in a new issue