From 588045cc4615c6c9d8522f5dfa346b5feffeb4e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yannig=20Perr=C3=A9?= Date: Wed, 17 Feb 2016 21:30:34 +0100 Subject: [PATCH] Improve message content to get more hint about the raised error. --- lib/ansible/template/vars.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/ansible/template/vars.py b/lib/ansible/template/vars.py index d55169368ac..badf93b1e86 100644 --- a/lib/ansible/template/vars.py +++ b/lib/ansible/template/vars.py @@ -21,6 +21,7 @@ __metaclass__ = type from ansible.compat.six import iteritems from jinja2.utils import missing +from ansible.utils.unicode import to_unicode __all__ = ['AnsibleJ2Vars'] @@ -83,7 +84,12 @@ class AnsibleJ2Vars: if isinstance(variable, dict) and varname == "vars" or isinstance(variable, HostVars): return variable else: - return self._templar.template(variable) + value = None + try: + value = self._templar.template(variable) + except Exception as e: + raise type(e)(to_unicode(variable) + ': ' + e.message) + return value def add_locals(self, locals): '''