From 10f8b9f130cb0aca2bde4536554aed9755822484 Mon Sep 17 00:00:00 2001 From: ibuler Date: Thu, 8 Jul 2021 14:36:18 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96ansible=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/ops/ansible/runner.py | 2 +- apps/ops/models/command.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/ops/ansible/runner.py b/apps/ops/ansible/runner.py index ebac415b5..a25d681b9 100644 --- a/apps/ops/ansible/runner.py +++ b/apps/ops/ansible/runner.py @@ -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)) diff --git a/apps/ops/models/command.py b/apps/ops/models/command.py index 4a4c9e552..819acc3d5 100644 --- a/apps/ops/models/command.py +++ b/apps/ops/models/command.py @@ -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)