Merge pull request #11310 from jumpserver/pr@dev@perf_applet_deploy

perf: 优化发布机的注册名称,避免重复
pull/11316/head
老广 1 year ago committed by GitHub
commit a084bc9962
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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)

Loading…
Cancel
Save