From 0792983ec8c19cc8341525dbd6a21a0446867bab Mon Sep 17 00:00:00 2001 From: Marc Poirier Date: Thu, 11 Feb 2016 15:29:48 -0500 Subject: [PATCH] Display the string which is causing an exception to be raised. In the ansible template module, when there is an error while expanding a templated string, displaying the string causing the exception is very useful. --- lib/ansible/template/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/template/__init__.py b/lib/ansible/template/__init__.py index fdc8eba720e..bec34f81aa7 100644 --- a/lib/ansible/template/__init__.py +++ b/lib/ansible/template/__init__.py @@ -464,7 +464,7 @@ class Templar: try: t = myenv.from_string(data) except TemplateSyntaxError as e: - raise AnsibleError("template error while templating string: %s" % str(e)) + raise AnsibleError("template error while templating string: %s. String: %s" % (str(e), data)) except Exception as e: if 'recursion' in str(e): raise AnsibleError("recursive loop detected in template string: %s" % data)