perf: inventory 为空 任务跳过 (#9664)

Co-authored-by: feng <1304903146@qq.com>
pull/9666/head
fit2bot 2023-02-21 15:33:15 +08:00 committed by GitHub
parent e4d28f5f3e
commit 4735565cb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 2 deletions

View File

@ -174,6 +174,12 @@ class BasePlaybookManager:
self.runtime_dir,
callback=PlaybookCallback(),
)
with open(inventory_path, 'r') as f:
inventory_data = json.load(f)
if not inventory_data['all'].get('hosts'):
continue
runners.append(runer)
return runners
@ -244,11 +250,12 @@ class BasePlaybookManager:
self.before_runner_start(runner)
try:
cb = runner.run(**kwargs)
self.delete_sensitive_data(runner.inventory)
self.on_runner_success(runner, cb)
except Exception as e:
self.on_runner_failed(runner, e)
print('\n')
finally:
self.delete_sensitive_data(runner.inventory)
print('\n')
self.execution.status = 'success'
self.execution.date_finished = timezone.now()
self.execution.save()