From bbd36fea03038ff92f0df93a5eb01036edc409be Mon Sep 17 00:00:00 2001 From: Eric Date: Thu, 17 Aug 2023 10:33:59 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E6=9C=BA=E7=9A=84=E6=B3=A8=E5=86=8C=E5=90=8D=E7=A7=B0=EF=BC=8C?= =?UTF-8?q?=E9=81=BF=E5=85=8D=E9=87=8D=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/terminal/automations/deploy_applet_host/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/terminal/automations/deploy_applet_host/__init__.py b/apps/terminal/automations/deploy_applet_host/__init__.py index 164340098..449306a92 100644 --- a/apps/terminal/automations/deploy_applet_host/__init__.py +++ b/apps/terminal/automations/deploy_applet_host/__init__.py @@ -6,7 +6,7 @@ from django.conf import settings from django.utils import timezone from common.db.utils import safe_db_connection -from common.utils import get_logger +from common.utils import get_logger, random_string from ops.ansible import PlaybookRunner, JMSInventory from terminal.models import Applet, AppletHostDeployment @@ -58,13 +58,15 @@ class DeployAppletHostManager: download_host = download_host.rstrip("/") def handler(plays): + applet_host_name = self.deployment.host.name + hostname = '{}-{}'.format(applet_host_name, random_string(7)) for play in plays: play["vars"].update(options) play["vars"]["APPLET_DOWNLOAD_HOST"] = download_host play["vars"]["CORE_HOST"] = core_host play["vars"]["BOOTSTRAP_TOKEN"] = bootstrap_token play["vars"]["HOST_ID"] = host_id - play["vars"]["HOST_NAME"] = self.deployment.host.name + play["vars"]["HOST_NAME"] = hostname return plays return self._generate_playbook("playbook.yml", handler)