From 2aef0335cb231533a7d24432333e798deacb8566 Mon Sep 17 00:00:00 2001 From: Grzegorz Nosek Date: Mon, 20 Aug 2012 21:00:31 +0200 Subject: [PATCH] Handle UTF-8 in templates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is required to run commands containing non-ASCII characters, e.g.: ansible localhost -m shell -a 'echo ą' --- lib/ansible/utils.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/ansible/utils.py b/lib/ansible/utils.py index 7dff22b4af..2b21ac0ec6 100644 --- a/lib/ansible/utils.py +++ b/lib/ansible/utils.py @@ -215,6 +215,10 @@ def template(text, vars): ''' run a text buffer through the templating engine until it no longer changes ''' prev_text = '' + try: + text = text.decode('utf-8') + except UnicodeEncodeError: + pass # already unicode depth = 0 while prev_text != text: depth = depth + 1