From 4542e83fa011f876ef57498b9e0c1aeb1d082b93 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Thu, 18 May 2017 18:06:51 -0500 Subject: [PATCH] Convert some more base64 strings to text for winrm, to support async and become (#24796) (cherry picked from commit 1eed6c5b3d01822ab5e19ea8ab743edf27bebf71) --- lib/ansible/executor/module_common.py | 6 +++--- lib/ansible/plugins/connection/winrm.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/ansible/executor/module_common.py b/lib/ansible/executor/module_common.py index 2224d1d27e..3d85c55343 100644 --- a/lib/ansible/executor/module_common.py +++ b/lib/ansible/executor/module_common.py @@ -834,9 +834,9 @@ def build_windows_module_payload(module_name, module_path, b_module_data, module if task.async > 0: exec_manifest["actions"].insert(0, 'async_watchdog') - exec_manifest["async_watchdog"] = base64.b64encode(to_bytes(async_watchdog)) + exec_manifest["async_watchdog"] = to_text(base64.b64encode(to_bytes(async_watchdog))) exec_manifest["actions"].insert(0, 'async_wrapper') - exec_manifest["async_wrapper"] = base64.b64encode(to_bytes(async_wrapper)) + exec_manifest["async_wrapper"] = to_text(base64.b64encode(to_bytes(async_wrapper))) exec_manifest["async_jid"] = str(random.randint(0, 999999999999)) exec_manifest["async_timeout_sec"] = task.async @@ -844,7 +844,7 @@ def build_windows_module_payload(module_name, module_path, b_module_data, module exec_manifest["actions"].insert(0, 'become') exec_manifest["become_user"] = play_context.become_user exec_manifest["become_password"] = play_context.become_pass - exec_manifest["become"] = base64.b64encode(to_bytes(become_wrapper)) + exec_manifest["become"] = to_text(base64.b64encode(to_bytes(become_wrapper))) lines = b_module_data.split(b'\n') module_names = set() diff --git a/lib/ansible/plugins/connection/winrm.py b/lib/ansible/plugins/connection/winrm.py index 6b038cf8ef..15944654d6 100644 --- a/lib/ansible/plugins/connection/winrm.py +++ b/lib/ansible/plugins/connection/winrm.py @@ -309,10 +309,10 @@ class Connection(ConnectionBase): def _create_raw_wrapper_payload(self, cmd, environment=dict()): payload = { - 'module_entry': base64.b64encode(to_bytes(cmd)), + 'module_entry': to_text(base64.b64encode(to_bytes(cmd))), 'powershell_modules': {}, 'actions': ['exec'], - 'exec': base64.b64encode(to_bytes(leaf_exec)), + 'exec': to_text(base64.b64encode(to_bytes(leaf_exec))), 'environment': environment }