From 94f56614e72e1b11a9ada5d4b2e49401dbda4d5b Mon Sep 17 00:00:00 2001 From: Grzegorz Nosek Date: Mon, 20 Aug 2012 21:50:44 +0200 Subject: [PATCH] Fix UTF-8 output when using executable inventory files The 'hostname' variable is then unicode, which breaks interpolating stdout etc. contents into the output strings (they are bytes and cannot be converted to Unicode using ASCII codec) --- lib/ansible/callbacks.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/ansible/callbacks.py b/lib/ansible/callbacks.py index 4f97cecf620..42bcb415dd8 100644 --- a/lib/ansible/callbacks.py +++ b/lib/ansible/callbacks.py @@ -136,6 +136,9 @@ def command_generic_msg(hostname, result, oneline, caption): stderr = result.get('stderr', '') msg = result.get('msg', '') + hostname = hostname.encode('utf-8') + caption = caption.encode('utf-8') + if not oneline: buf = "%s | %s | rc=%s >>\n" % (hostname, caption, result.get('rc',0)) if stdout: