Base changes required to allow winrm to work on py3 (#24744)

This commit is contained in:
Matt Martz 2017-05-17 16:26:32 -05:00 committed by Matt Davis
parent f217dae938
commit e7d8ebf080
2 changed files with 12 additions and 6 deletions

View file

@ -839,14 +839,14 @@ def modify_module(module_name, module_path, module_args, task_vars=dict(), modul
def build_windows_module_payload(module_name, module_path, b_module_data, module_args, task_vars, task, play_context, environment):
exec_manifest = dict(
module_entry=base64.b64encode(b_module_data),
module_entry=to_text(base64.b64encode(b_module_data)),
powershell_modules=dict(),
module_args=module_args,
actions=['exec'],
environment=environment
)
exec_manifest['exec'] = base64.b64encode(to_bytes(leaf_exec))
exec_manifest['exec'] = to_text(base64.b64encode(to_bytes(leaf_exec)))
if task.async > 0:
exec_manifest["actions"].insert(0, 'async_watchdog')
@ -874,8 +874,14 @@ def build_windows_module_payload(module_name, module_path, b_module_data, module
# TODO: add #Requires checks for Ansible.ModuleUtils.X
for m in module_names:
exec_manifest["powershell_modules"][m] = base64.b64encode(
to_bytes(_slurp(os.path.join(_MODULE_UTILS_PATH, m + ".ps1"))))
m = to_text(m)
exec_manifest["powershell_modules"][m] = to_text(
base64.b64encode(
to_bytes(
_slurp(os.path.join(_MODULE_UTILS_PATH, m + ".ps1"))
)
)
)
# FUTURE: smuggle this back as a dict instead of serializing here; the connection plugin may need to modify it
b_module_data = json.dumps(exec_manifest)