mirror of https://github.com/jumpserver/jumpserver
perf(ops): ansible 增加 summary 汇总
parent
d795867916
commit
8f7dcd512a
|
@ -129,6 +129,9 @@ class AdHocResultCallback(CallbackMixin, CallbackModule, CMDCallBackModule):
|
|||
self.gather_result("unreachable", result)
|
||||
super().v2_runner_on_unreachable(result)
|
||||
|
||||
def v2_runner_on_start(self, *args, **kwargs):
|
||||
pass
|
||||
|
||||
def display_skipped_hosts(self):
|
||||
pass
|
||||
|
||||
|
@ -201,6 +204,9 @@ class CommandResultCallback(AdHocResultCallback):
|
|||
msg,
|
||||
), color=C.COLOR_ERROR)
|
||||
|
||||
def v2_playbook_on_stats(self, stats):
|
||||
pass
|
||||
|
||||
def _print_task_banner(self, task):
|
||||
pass
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import shutil
|
|||
from collections import namedtuple
|
||||
|
||||
from ansible import context
|
||||
from ansible.playbook import Playbook
|
||||
from ansible.module_utils.common.collections import ImmutableDict
|
||||
from ansible.executor.task_queue_manager import TaskQueueManager
|
||||
from ansible.vars.manager import VariableManager
|
||||
|
@ -217,6 +218,11 @@ class AdHocRunner:
|
|||
variable_manager=self.variable_manager,
|
||||
loader=self.loader,
|
||||
)
|
||||
loader = DataLoader()
|
||||
# used in start callback
|
||||
playbook = Playbook(loader)
|
||||
playbook._entries.append(play)
|
||||
playbook._file_name = '__adhoc_playbook__'
|
||||
|
||||
tqm = TaskQueueManager(
|
||||
inventory=self.inventory,
|
||||
|
@ -226,7 +232,9 @@ class AdHocRunner:
|
|||
passwords={"conn_pass": self.options.get("password", "")}
|
||||
)
|
||||
try:
|
||||
tqm.send_callback('v2_playbook_on_start', playbook)
|
||||
tqm.run(play)
|
||||
tqm.send_callback('v2_playbook_on_stats', tqm._stats)
|
||||
return self.results_callback
|
||||
except Exception as e:
|
||||
raise AnsibleError(e)
|
||||
|
|
Loading…
Reference in New Issue