diff --git a/apps/ops/ansible/inventory.py b/apps/ops/ansible/inventory.py index c88c5c95f..6ac8cdb83 100644 --- a/apps/ops/ansible/inventory.py +++ b/apps/ops/ansible/inventory.py @@ -10,7 +10,7 @@ __all__ = ['JMSInventory'] class JMSInventory: def __init__(self, assets, account_policy='privileged_first', - account_prefer='root,Administrator', host_callback=None, unique_host_name=False): + account_prefer='root,Administrator', host_callback=None): """ :param assets: :param account_prefer: account username name if not set use account_policy @@ -21,7 +21,6 @@ class JMSInventory: self.account_policy = account_policy self.host_callback = host_callback self.exclude_hosts = {} - self.unique_host_name = unique_host_name @staticmethod def clean_assets(assets): @@ -114,8 +113,6 @@ class JMSInventory: 'secret': account.secret, 'secret_type': account.secret_type } if account else None } - if self.unique_host_name: - host['name'] += '({})'.format(asset.id) if host['jms_account'] and asset.platform.type == 'oracle': host['jms_account']['mode'] = 'sysdba' if account.privileged else None diff --git a/apps/ops/models/job.py b/apps/ops/models/job.py index 94c157cb8..ce3c5c358 100644 --- a/apps/ops/models/job.py +++ b/apps/ops/models/job.py @@ -88,7 +88,7 @@ class Job(JMSOrgBaseModel, PeriodTaskModelMixin): @property def inventory(self): - return JMSInventory(self.assets.all(), self.runas_policy, self.runas, unique_host_name=True) + return JMSInventory(self.assets.all(), self.runas_policy, self.runas) def create_execution(self): return self.executions.create() @@ -133,26 +133,25 @@ class JobExecution(JMSOrgBaseModel): "status": "ok", "tasks": [], } - host_name = "{}({})".format(asset.name, asset.id) - if self.summary["excludes"].get(host_name, None): + if self.summary["excludes"].get(asset.name, None): asset_detail.update({"status": "excludes"}) result["detail"].append(asset_detail) break - if self.result["dark"].get(host_name, None): + if self.result["dark"].get(asset.name, None): asset_detail.update({"status": "failed"}) - for key, task in self.result["dark"][host_name].items(): + for key, task in self.result["dark"][asset.name].items(): task_detail = {"name": key, "output": "{}{}".format(task.get("stdout", ""), task.get("stderr", ""))} asset_detail["tasks"].append(task_detail) - if self.result["failures"].get(host_name, None): + if self.result["failures"].get(asset.name, None): asset_detail.update({"status": "failed"}) - for key, task in self.result["failures"][host_name].items(): + for key, task in self.result["failures"][asset.name].items(): task_detail = {"name": key, "output": "{}{}".format(task.get("stdout", ""), task.get("stderr", ""))} asset_detail["tasks"].append(task_detail) - if self.result["ok"].get(host_name, None): - for key, task in self.result["ok"][host_name].items(): + if self.result["ok"].get(asset.name, None): + for key, task in self.result["ok"][asset.name].items(): task_detail = {"name": key, "output": "{}{}".format(task.get("stdout", ""), task.get("stderr", ""))} asset_detail["tasks"].append(task_detail)