diff --git a/lib/ansible/utils/template.py b/lib/ansible/utils/template.py
index fc4ff9fd20..e58543c411 100644
--- a/lib/ansible/utils/template.py
+++ b/lib/ansible/utils/template.py
@@ -316,6 +316,8 @@ def template_from_string(basedir, data, vars, fail_on_undefined=False):
         except Exception, e:
             if 'recursion' in str(e):
                 raise errors.AnsibleError("recursive loop detected in template string: %s" % data)
+            elif isinstance(e, TemplateSyntaxError):
+                raise errors.AnsibleError("there was an error in the template: %s" % data)
             else:
                 return data