perf: update applet delopyment task

pull/9098/head
Eric 2 years ago
parent 3a62abf381
commit ef3654ffa4

@ -7,23 +7,22 @@
2. 程序需要, 用户不需要更改的写到settings中 2. 程序需要, 用户不需要更改的写到settings中
3. 程序需要, 用户需要更改的写到本config中 3. 程序需要, 用户需要更改的写到本config中
""" """
import base64
import copy
import errno
import json
import logging
import os import os
import re import re
import sys import sys
import types import types
import errno
import json
import yaml
import copy
import base64
import logging
from importlib import import_module from importlib import import_module
from urllib.parse import urljoin, urlparse from urllib.parse import urljoin, urlparse
from gmssl.sm4 import CryptSM4, SM4_ENCRYPT, SM4_DECRYPT
import yaml
from django.urls import reverse_lazy from django.urls import reverse_lazy
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from gmssl.sm4 import CryptSM4, SM4_ENCRYPT, SM4_DECRYPT
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
PROJECT_DIR = os.path.dirname(BASE_DIR) PROJECT_DIR = os.path.dirname(BASE_DIR)
@ -499,6 +498,9 @@ class Config(dict):
'FORGOT_PASSWORD_URL': '', 'FORGOT_PASSWORD_URL': '',
'HEALTH_CHECK_TOKEN': '', 'HEALTH_CHECK_TOKEN': '',
# Applet 等软件的下载地址
'APPLET_DOWNLOAD_HOST': '',
} }
def __init__(self, *args): def __init__(self, *args):

@ -1,4 +1,5 @@
import os import os
from django.urls import reverse_lazy from django.urls import reverse_lazy
from .. import const from .. import const
@ -36,6 +37,9 @@ DEBUG_DEV = CONFIG.DEBUG_DEV
# Absolute url for some case, for example email link # Absolute url for some case, for example email link
SITE_URL = CONFIG.SITE_URL SITE_URL = CONFIG.SITE_URL
# Absolute url for downloading applet
APPLET_DOWNLOAD_HOST = CONFIG.APPLET_DOWNLOAD_HOST
# https://docs.djangoproject.com/en/4.1/ref/settings/ # https://docs.djangoproject.com/en/4.1/ref/settings/
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
@ -313,7 +317,6 @@ PASSWORD_HASHERS = [
'django.contrib.auth.hashers.BCryptSHA256PasswordHasher', 'django.contrib.auth.hashers.BCryptSHA256PasswordHasher',
] ]
GMSSL_ENABLED = CONFIG.GMSSL_ENABLED GMSSL_ENABLED = CONFIG.GMSSL_ENABLED
GM_HASHER = 'common.hashers.PBKDF2SM3PasswordHasher' GM_HASHER = 'common.hashers.PBKDF2SM3PasswordHasher'
if GMSSL_ENABLED: if GMSSL_ENABLED:
@ -329,4 +332,3 @@ if os.environ.get('DEBUG_TOOLBAR', False):
DEBUG_TOOLBAR_PANELS = [ DEBUG_TOOLBAR_PANELS = [
'debug_toolbar.panels.profiling.ProfilingPanel', 'debug_toolbar.panels.profiling.ProfilingPanel',
] ]

@ -45,20 +45,26 @@ class DeployAppletHostManager:
def generate_initial_playbook(self): def generate_initial_playbook(self):
site_url = settings.SITE_URL site_url = settings.SITE_URL
download_host = settings.APPLET_DOWNLOAD_HOST
bootstrap_token = settings.BOOTSTRAP_TOKEN bootstrap_token = settings.BOOTSTRAP_TOKEN
host_id = str(self.deployment.host.id) host_id = str(self.deployment.host.id)
if not site_url: if not site_url:
site_url = "http://localhost:8080" site_url = "http://localhost:8080"
if not download_host:
download_host = site_url
options = self.deployment.host.deploy_options options = self.deployment.host.deploy_options
site_url = site_url.rstrip("/")
download_host = download_host.rstrip("/")
def handler(plays): def handler(plays):
for play in plays: for play in plays:
play["vars"].update(options) play["vars"].update(options)
play["vars"]["DownloadHost"] = site_url + "/download" play["vars"]["APPLET_DOWNLOAD_HOST"] = download_host
play["vars"]["CORE_HOST"] = site_url play["vars"]["CORE_HOST"] = site_url
play["vars"]["BOOTSTRAP_TOKEN"] = bootstrap_token play["vars"]["BOOTSTRAP_TOKEN"] = bootstrap_token
play["vars"]["HOST_ID"] = host_id play["vars"]["HOST_ID"] = host_id
play["vars"]["HOST_NAME"] = self.deployment.host.name play["vars"]["HOST_NAME"] = self.deployment.host.name
return plays
return self._generate_playbook("playbook.yml", handler) return self._generate_playbook("playbook.yml", handler)

@ -2,7 +2,7 @@
- hosts: all - hosts: all
vars: vars:
DownloadHost: https://demo.jumpserver.org/download APPLET_DOWNLOAD_HOST: https://demo.jumpserver.org
HOST_NAME: test HOST_NAME: test
HOST_ID: 00000000-0000-0000-0000-000000000000 HOST_ID: 00000000-0000-0000-0000-000000000000
CORE_HOST: https://demo.jumpserver.org CORE_HOST: https://demo.jumpserver.org
@ -32,7 +32,7 @@
- name: Download JumpServer Tinker installer (jumpserver) - name: Download JumpServer Tinker installer (jumpserver)
ansible.windows.win_get_url: ansible.windows.win_get_url:
url: "{{ DownloadHost }}/{{ TinkerInstaller }}" url: "{{ APPLET_DOWNLOAD_HOST }}/download/applets/{{ TinkerInstaller }}"
dest: "{{ ansible_env.TEMP }}\\{{ TinkerInstaller }}" dest: "{{ ansible_env.TEMP }}\\{{ TinkerInstaller }}"
- name: Install JumpServer Tinker (jumpserver) - name: Install JumpServer Tinker (jumpserver)
@ -52,7 +52,7 @@
- name: Download python-3.10.8 - name: Download python-3.10.8
ansible.windows.win_get_url: ansible.windows.win_get_url:
url: "{{ DownloadHost }}/python-3.10.8-amd64.exe" url: "{{ APPLET_DOWNLOAD_HOST }}/download/applets/python-3.10.8-amd64.exe"
dest: "{{ ansible_env.TEMP }}\\python-3.10.8-amd64.exe" dest: "{{ ansible_env.TEMP }}\\python-3.10.8-amd64.exe"
- name: Install the python-3.10.8 - name: Install the python-3.10.8
@ -112,27 +112,27 @@
- name: Download pip packages - name: Download pip packages
ansible.windows.win_get_url: ansible.windows.win_get_url:
url: "{{ DownloadHost }}/pip_packages_v0.0.1.zip" url: "{{ APPLET_DOWNLOAD_HOST }}/download/applets/pip_packages.zip"
dest: "{{ ansible_env.TEMP }}\\pip_packages_v0.0.1.zip" dest: "{{ ansible_env.TEMP }}\\pip_packages.zip"
- name: Unzip pip_packages - name: Unzip pip_packages
community.windows.win_unzip: community.windows.win_unzip:
src: "{{ ansible_env.TEMP }}\\pip_packages_v0.0.1.zip" src: "{{ ansible_env.TEMP }}\\pip_packages.zip"
dest: "{{ ansible_env.TEMP }}" dest: "{{ ansible_env.TEMP }}\\pip_packages"
- name: Install python requirements offline - name: Install python requirements offline
ansible.windows.win_shell: > ansible.windows.win_shell: >
pip install -r '{{ ansible_env.TEMP }}\pip_packages_v0.0.1\requirements.txt' pip install -r '{{ ansible_env.TEMP }}\pip_packages\requirements.txt'
--no-index --find-links='{{ ansible_env.TEMP }}\pip_packages_v0.0.1' --no-index --find-links='{{ ansible_env.TEMP }}\pip_packages'
- name: Download chromedriver (chrome) - name: Download chromedriver (chrome)
ansible.windows.win_get_url: ansible.windows.win_get_url:
url: "{{ DownloadHost }}/chromedriver_win32.107.zip" url: "{{ APPLET_DOWNLOAD_HOST }}/download/applets/chromedriver_win32.zip"
dest: "{{ ansible_env.TEMP }}\\chromedriver_win32.107.zip" dest: "{{ ansible_env.TEMP }}\\chromedriver_win32.zip"
- name: Unzip chromedriver (chrome) - name: Unzip chromedriver (chrome)
community.windows.win_unzip: community.windows.win_unzip:
src: "{{ ansible_env.TEMP }}\\chromedriver_win32.107.zip" src: "{{ ansible_env.TEMP }}\\chromedriver_win32.zip"
dest: C:\Program Files\JumpServer\drivers dest: C:\Program Files\JumpServer\drivers
- name: Set chromedriver on the global system path (chrome) - name: Set chromedriver on the global system path (chrome)
@ -142,7 +142,7 @@
- name: Download chrome msi package (chrome) - name: Download chrome msi package (chrome)
ansible.windows.win_get_url: ansible.windows.win_get_url:
url: "{{ DownloadHost }}/googlechromestandaloneenterprise64.msi" url: "{{ APPLET_DOWNLOAD_HOST }}/download/applets/googlechromestandaloneenterprise64.msi"
dest: "{{ ansible_env.TEMP }}\\googlechromestandaloneenterprise64.msi" dest: "{{ ansible_env.TEMP }}\\googlechromestandaloneenterprise64.msi"
- name: Install chrome (chrome) - name: Install chrome (chrome)

Loading…
Cancel
Save