perf: 优化ansible执行命令

pull/6402/head
ibuler 3 years ago committed by Jiangjie.Bai
parent 1e601288fa
commit 10f8b9f130

@ -250,7 +250,7 @@ class CommandRunner(AdHocRunner):
results_callback_class = CommandResultCallback
modules_choices = ('shell', 'raw', 'command', 'script', 'win_shell')
def execute(self, cmd, pattern, module='raw'):
def execute(self, cmd, pattern, module='shell'):
if module and module not in self.modules_choices:
raise AnsibleError("Module should in {}".format(self.modules_choices))

@ -86,6 +86,8 @@ class CommandExecution(OrgModelMixin):
host = self.hosts.first()
if host and host.is_windows():
shell = 'win_shell'
elif host and host.is_unixlike():
shell = 'shell'
else:
shell = 'raw'
result = runner.execute(self.command, 'all', module=shell)

Loading…
Cancel
Save