From 21fdb2bbc7f68999d512787c5d9130e2b5d55ae6 Mon Sep 17 00:00:00 2001 From: James Tanner Date: Fri, 3 Jan 2014 11:18:20 -0500 Subject: [PATCH] Fixes #5200 Handle template contents with unicode strings better --- lib/ansible/utils/template.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/ansible/utils/template.py b/lib/ansible/utils/template.py index 9180f47326..2491035c59 100644 --- a/lib/ansible/utils/template.py +++ b/lib/ansible/utils/template.py @@ -497,7 +497,14 @@ def template_from_file(basedir, path, vars): if data.endswith('\n') and not res.endswith('\n'): res = res + '\n' - return template(basedir, res, vars) + + if isinstance(res, unicode): + # do not try to re-template a unicode string + result = res + else: + result = template(basedir, res, vars) + + return result def template_from_string(basedir, data, vars, fail_on_undefined=False): ''' run a string through the (Jinja2) templating engine '''