mirror of https://github.com/jumpserver/jumpserver
perf: 优化ansible执行命令
parent
1e601288fa
commit
10f8b9f130
|
@ -250,7 +250,7 @@ class CommandRunner(AdHocRunner):
|
||||||
results_callback_class = CommandResultCallback
|
results_callback_class = CommandResultCallback
|
||||||
modules_choices = ('shell', 'raw', 'command', 'script', 'win_shell')
|
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:
|
if module and module not in self.modules_choices:
|
||||||
raise AnsibleError("Module should in {}".format(self.modules_choices))
|
raise AnsibleError("Module should in {}".format(self.modules_choices))
|
||||||
|
|
||||||
|
|
|
@ -86,6 +86,8 @@ class CommandExecution(OrgModelMixin):
|
||||||
host = self.hosts.first()
|
host = self.hosts.first()
|
||||||
if host and host.is_windows():
|
if host and host.is_windows():
|
||||||
shell = 'win_shell'
|
shell = 'win_shell'
|
||||||
|
elif host and host.is_unixlike():
|
||||||
|
shell = 'shell'
|
||||||
else:
|
else:
|
||||||
shell = 'raw'
|
shell = 'raw'
|
||||||
result = runner.execute(self.command, 'all', module=shell)
|
result = runner.execute(self.command, 'all', module=shell)
|
||||||
|
|
Loading…
Reference in New Issue