From 5bf9ea629882a9ef58fe37b68d84dd49980450c6 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Thu, 26 Mar 2015 11:52:19 -0700 Subject: [PATCH] make sure the shebang we inject into the module is a str Fixes #8564 --- lib/ansible/module_common.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/ansible/module_common.py b/lib/ansible/module_common.py index 5e3732e967..2ee23c90b7 100644 --- a/lib/ansible/module_common.py +++ b/lib/ansible/module_common.py @@ -26,6 +26,7 @@ from ansible import errors from ansible import utils from ansible import constants as C from ansible import __version__ +from asnible.utils.unicode import to_bytes REPLACER = "#<>" REPLACER_ARGS = "\"<>\"" @@ -184,7 +185,8 @@ class ModuleReplacer(object): interpreter_config = 'ansible_%s_interpreter' % os.path.basename(interpreter) if interpreter_config in inject: - lines[0] = shebang = "#!%s %s" % (inject[interpreter_config], " ".join(args[1:])) + interpreter = to_bytes(inject[interpreter_config], errors='strict') + lines[0] = shebang = "#!%s %s" % (interpreter, " ".join(args[1:])) module_data = "\n".join(lines) return (module_data, module_style, shebang)