Catch template syntax errors specifically when templating strings

Fixes #9333
This commit is contained in:
James Cammarata
2014-10-20 13:10:42 -05:00
parent b0069a338e
commit b61a78532c
4 changed files with 7 additions and 2 deletions

View File

@@ -340,6 +340,8 @@ def template_from_string(basedir, data, vars, fail_on_undefined=False):
try:
t = environment.from_string(data)
except TemplateSyntaxError, e:
raise errors.AnsibleError("template error while templating string: %s" % str(e))
except Exception, e:
if 'recursion' in str(e):
raise errors.AnsibleError("recursive loop detected in template string: %s" % data)