From 1e85c7544bbb273be6132357453fa2b7849df8c1 Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Sat, 19 Oct 2013 10:51:35 -0400 Subject: [PATCH] Further WIP on template cleanup. --- lib/ansible/utils/template.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/ansible/utils/template.py b/lib/ansible/utils/template.py index 316a64c4f6..05114a4775 100644 --- a/lib/ansible/utils/template.py +++ b/lib/ansible/utils/template.py @@ -394,6 +394,7 @@ def template_from_file(basedir, path, vars): environment.filters.update(_get_filters()) environment.globals['lookup'] = my_lookup if fail_on_undefined: + print "DEBUG: fail on undefined is engaged" environment.undefined = StrictUndefined try: @@ -438,7 +439,7 @@ def template_from_file(basedir, path, vars): ) try: - res = template.render(vars) + res = t.render(vars) except jinja2.exceptions.UndefinedError, e: raise errors.AnsibleUndefinedVariable("One or more undefined variables: %s" % str(e)) @@ -453,6 +454,9 @@ def template_from_string(basedir, data, vars, fail_on_undefined=False): data = unicode(data, 'utf-8') environment = jinja2.Environment(trim_blocks=True, undefined=StrictUndefined, extensions=_get_extensions()) environment.filters.update(_get_filters()) + if fail_on_undefined: + print "DEBUG: fail on undefined is engaged, 2" + environment.undefined = StrictUndefined if '_original_file' in vars: basedir = os.path.dirname(vars['_original_file'])