Enhance references to logging functionality. Fixes #3431.

This commit is contained in:
Michael DeHaan 2013-10-08 08:26:40 -04:00
parent f081c68a65
commit c69e19c6a6
3 changed files with 18 additions and 4 deletions

View file

@ -495,6 +495,7 @@ def template_from_string(basedir, data, vars, fail_on_undefined=False):
# TODO: may need some way of using lookup plugins here seeing we aren't calling
# the legacy engine, lookup() as a function, perhaps?
data = data.decode('utf-8')
try:
t = environment.from_string(data)
except Exception, e:
@ -509,7 +510,12 @@ def template_from_string(basedir, data, vars, fail_on_undefined=False):
t.globals['lookup'] = my_lookup
res = jinja2.utils.concat(t.root_render_func(t.new_context(_jinja2_vars(basedir, vars, t.globals, fail_on_undefined), shared=True)))
jvars =_jinja2_vars(basedir, vars, t.globals, fail_on_undefined)
new_context = t.new_context(jvars, shared=True)
rf = t.root_render_func(new_context)
res = jinja2.utils.concat(rf)
return res
except (jinja2.exceptions.UndefinedError, errors.AnsibleUndefinedVariable):
if fail_on_undefined: