Merge pull request #15248 from abadger/fix-async

Fix async for old style modules and don't send an args file for new-style modules
pull/15257/head
Matt Davis 9 years ago
commit 441fe44569

@ -22,7 +22,7 @@ import random
from ansible import constants as C from ansible import constants as C
from ansible.plugins.action import ActionBase from ansible.plugins.action import ActionBase
from ansible.utils.unicode import to_unicode
class ActionModule(ActionBase): 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) (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) self._transfer_data(async_module_path, async_module_data)
argsfile = None
if module_style == 'non_native_want_json':
argsfile = self._transfer_data(self._connection._shell.join_path(tmp, 'arguments'), json.dumps(module_args)) 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) self._fixup_perms(tmp, remote_user, execute=True, recursive=True)
# Only the following two files need to be executable but we'd have to # 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_limit = self._task.async
async_jid = str(random.randint(0, 999999999999)) 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)) result.update(self._low_level_execute_command(cmd=async_cmd))
# clean up after # clean up after

Loading…
Cancel
Save