From 4ccea9905b2484ade3f91cdc5be9a9c0867e9672 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Fri, 1 Apr 2016 19:55:34 -0700 Subject: [PATCH] Fix async for old style modules and don't send an args file for new-style modules --- lib/ansible/plugins/action/async.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/ansible/plugins/action/async.py b/lib/ansible/plugins/action/async.py index b85f1c20f46..2002d248bd8 100644 --- a/lib/ansible/plugins/action/async.py +++ b/lib/ansible/plugins/action/async.py @@ -22,7 +22,7 @@ import random from ansible import constants as C from ansible.plugins.action import ActionBase - +from ansible.utils.unicode import to_unicode class ActionModule(ActionBase): @@ -60,7 +60,14 @@ class ActionModule(ActionBase): (async_module_style, shebang, async_module_data) = self._configure_module(module_name='async_wrapper', module_args=dict(), task_vars=task_vars) self._transfer_data(async_module_path, async_module_data) - argsfile = self._transfer_data(self._connection._shell.join_path(tmp, 'arguments'), json.dumps(module_args)) + argsfile = None + if module_style == 'non_native_want_json': + argsfile = self._transfer_data(self._connection._shell.join_path(tmp, 'arguments'), json.dumps(module_args)) + elif module_style == 'old': + args_data = "" + for k, v in iteritems(module_args): + args_data += '%s="%s" ' % (k, pipes.quote(to_unicode(v))) + argsfile = self._transfer_data(self._connection._shell.join_path(tmp, 'arguments'), args_data) self._fixup_perms(tmp, remote_user, execute=True, recursive=True) # Only the following two files need to be executable but we'd have to @@ -77,7 +84,10 @@ class ActionModule(ActionBase): async_limit = self._task.async async_jid = str(random.randint(0, 999999999999)) - async_cmd = " ".join([str(x) for x in [env_string, async_module_path, async_jid, async_limit, remote_module_path, argsfile]]) + async_cmd = [env_string, async_module_path, async_jid, async_limit, remote_module_path] + if argsfile: + async_cmd.append(argsfile) + async_cmd = " ".join([to_unicode(x) for x in async_cmd]) result.update(self._low_level_execute_command(cmd=async_cmd)) # clean up after