perf: 优化 account,去掉版本好

This commit is contained in:
ibuler
2023-02-22 11:18:42 +08:00
parent b91b9ef39e
commit 4c233cfb69
9 changed files with 43 additions and 54 deletions

View File

@@ -64,7 +64,7 @@ class BasePlaybookManager:
if not os.path.exists(path):
os.makedirs(path, exist_ok=True, mode=0o755)
if settings.DEBUG_DEV:
logger.debug('Ansible runtime dir: {}'.format(path))
print(f'Ansible runtime dir:{path}')
return path
@staticmethod
@@ -153,10 +153,9 @@ class BasePlaybookManager:
return sub_playbook_path
def get_runners(self):
# TODO 临时打印一下 找一下打印不出日志的原因
print('ansible runner: 任务开始执行')
assets_group_by_platform = self.get_assets_group_by_platform()
print('ansible runner: 获取资产分组', assets_group_by_platform)
if settings.DEBUG_DEV:
print("assets_group_by_platform: {}".format(assets_group_by_platform))
runners = []
for platform, assets in assets_group_by_platform.items():
assets_bulked = [assets[i:i + self.bulk_size] for i in range(0, len(assets), self.bulk_size)]
@@ -210,6 +209,7 @@ class BasePlaybookManager:
with open(path, 'r') as f:
d = json.load(f)
def delete_keys(d, keys_to_delete):
"""
递归函数:删除嵌套字典中的指定键
@@ -223,6 +223,7 @@ class BasePlaybookManager:
else:
delete_keys(d[key], keys_to_delete)
return d
d = delete_keys(d, ['secret', 'ansible_password'])
with open(path, 'w') as f:
json.dump(d, f)