From ebb6b8442ba901bb7650419d0fc01c9f2ebc8be2 Mon Sep 17 00:00:00 2001 From: James Tanner Date: Mon, 17 Mar 2014 12:14:29 -0400 Subject: [PATCH] Catch unicode unescape failures in copy action plugin --- lib/ansible/runner/action_plugins/copy.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/ansible/runner/action_plugins/copy.py b/lib/ansible/runner/action_plugins/copy.py index d395d1df6f5..f8063862cc4 100644 --- a/lib/ansible/runner/action_plugins/copy.py +++ b/lib/ansible/runner/action_plugins/copy.py @@ -58,7 +58,11 @@ class ActionModule(object): # now we need to unescape it so that the newlines are evaluated properly # when writing the file to disk if content: - content = content.decode('unicode-escape') + if isinstance(content, unicode): + try: + content = content.decode('unicode-escape') + except UnicodeDecodeError: + pass if (source is None and content is None and not 'first_available_file' in inject) or dest is None: result=dict(failed=True, msg="src (or content) and dest are required")