perf: use python embed

pull/14326/head^2
吴小白 2024-10-10 11:53:11 +08:00 committed by Bryan
parent 1f32ab274c
commit 6fa14833b3
1 changed files with 41 additions and 55 deletions

View File

@ -15,7 +15,7 @@
RDS_MaxDisconnectionTime: 60000 RDS_MaxDisconnectionTime: 60000
RDS_RemoteAppLogoffTimeLimit: 0 RDS_RemoteAppLogoffTimeLimit: 0
INSTALL_APPLETS: true INSTALL_APPLETS: true
PYTHON_VERSION: 3.11.6 PYTHON_VERSION: 3.11.10
CHROME_VERSION: 118.0.5993.118 CHROME_VERSION: 118.0.5993.118
CHROME_DRIVER_VERSION: 118.0.5993.70 CHROME_DRIVER_VERSION: 118.0.5993.70
TINKER_VERSION: v0.1.9 TINKER_VERSION: v0.1.9
@ -76,39 +76,43 @@
- name: Download python-{{ PYTHON_VERSION }} - name: Download python-{{ PYTHON_VERSION }}
ansible.windows.win_get_url: ansible.windows.win_get_url:
url: "{{ APPLET_DOWNLOAD_HOST }}/download/applets/python-{{ PYTHON_VERSION }}-amd64.exe" url: "{{ APPLET_DOWNLOAD_HOST }}/download/applets/jumpserver-tinker-python-{{ PYTHON_VERSION }}-win64.zip"
dest: "{{ ansible_env.TEMP }}\\python-{{ PYTHON_VERSION }}-amd64.exe" dest: "{{ ansible_env.TEMP }}\\jumpserver-tinker-python-{{ PYTHON_VERSION }}-win64.zip"
validate_certs: "{{ not IGNORE_VERIFY_CERTS }}" validate_certs: "{{ not IGNORE_VERIFY_CERTS }}"
- name: Install the python-{{ PYTHON_VERSION }} - name: Install the python-{{ PYTHON_VERSION }}
ansible.windows.win_package: community.windows.win_unzip:
path: "{{ ansible_env.TEMP }}\\python-{{ PYTHON_VERSION }}-amd64.exe" src: "{{ ansible_env.TEMP }}\\jumpserver-tinker-python-{{ PYTHON_VERSION }}-win64.zip"
arguments: dest: "%ProgramFiles%\\JumpServer\\applications"
- /quiet
- InstallAllUsers=1
- PrependPath=1
- Include_test=0
- Include_launcher=0
state: present
register: win_install_python
- name: Check pip command exists - name: Check and Clean global system path (Python)
ansible.windows.win_powershell: ansible.windows.win_path:
script: | elements:
if (Get-Command -Name 'pip' -ErrorAction SilentlyContinue) { - 'C:\Program Files\Python310\Scripts'
$Ansible.Changed = $false - 'C:\Program Files\Python310'
} - 'C:\Program Files\Python311\Scripts'
else { - 'C:\Program Files\Python311'
$Ansible.Changed = $true state: absent
}
ignore_errors: yes - name: Set python-{{ PYTHON_VERSION }} on the global system path
register: check_pip_command ansible.windows.win_path:
elements:
- '%ProgramFiles%\JumpServer\applications\Python'
- '%ProgramFiles%\JumpServer\applications\Python\Scripts'
- name: Set python-{{ PYTHON_VERSION }} on the global system python path
ansible.windows.win_path:
name: PYTHONPATH
scope: machine
elements:
- '%ProgramFiles%\JumpServer\applications\Python\packages'
- '%ProgramFiles%\JumpServer\applications\Python\Lib\site-packages'
- name: Reboot if installing requires it - name: Reboot if installing requires it
ansible.windows.win_reboot: ansible.windows.win_reboot:
post_reboot_delay: 10 post_reboot_delay: 10
test_command: whoami test_command: whoami
when: check_pip_command.changed or rds_install.reboot_required or win_install_python.reboot_required when: rds_install.reboot_required
- name: Set RDS LicenseServer (regedit) - name: Set RDS LicenseServer (regedit)
ansible.windows.win_regedit: ansible.windows.win_regedit:
@ -149,22 +153,6 @@
data: "{{ RDS_RemoteAppLogoffTimeLimit }}" data: "{{ RDS_RemoteAppLogoffTimeLimit }}"
type: dword type: dword
- name: Download pip packages
ansible.windows.win_get_url:
url: "{{ APPLET_DOWNLOAD_HOST }}/download/applets/pip_packages.zip"
dest: "{{ ansible_env.TEMP }}\\pip_packages.zip"
validate_certs: "{{ not IGNORE_VERIFY_CERTS }}"
- name: Unzip pip_packages
community.windows.win_unzip:
src: "{{ ansible_env.TEMP }}\\pip_packages.zip"
dest: "{{ ansible_env.TEMP }}\\pip_packages"
- name: Install python requirements offline
ansible.windows.win_powershell:
script: |
pip install -r '{{ ansible_env.TEMP }}\pip_packages\pip_packages\requirements.txt' --no-index --find-links='{{ ansible_env.TEMP }}\pip_packages\pip_packages'
- name: Stop chromedriver before install - name: Stop chromedriver before install
ansible.windows.win_powershell: ansible.windows.win_powershell:
script: | script: |
@ -180,10 +168,10 @@
path: "{{ item }}" path: "{{ item }}"
state: absent state: absent
with_items: with_items:
- C:\Program Files\JumpServer\drivers\chromedriver-win32 - 'C:\Program Files\JumpServer\drivers\chromedriver-win32'
- C:\Program Files\JumpServer\drivers\chromedriver_win32 - 'C:\Program Files\JumpServer\drivers\chromedriver_win32'
- C:\Program Files\JumpServer\drivers\chromedriver-win64 - 'C:\Program Files\JumpServer\drivers\chromedriver-win64'
- C:\Program Files\JumpServer\drivers\chromedriver_win64 - 'C:\Program Files\JumpServer\drivers\chromedriver_win64'
- name: Download chromedriver (Chrome) - name: Download chromedriver (Chrome)
ansible.windows.win_get_url: ansible.windows.win_get_url:
@ -194,7 +182,7 @@
- name: Unzip chromedriver (Chrome) - name: Unzip chromedriver (Chrome)
community.windows.win_unzip: community.windows.win_unzip:
src: "{{ ansible_env.TEMP }}\\chromedriver-{{ CHROME_DRIVER_VERSION }}-win64.zip" src: "{{ ansible_env.TEMP }}\\chromedriver-{{ CHROME_DRIVER_VERSION }}-win64.zip"
dest: C:\Program Files\JumpServer\drivers dest: "%ProgramFiles%\\JumpServer\\drivers"
- name: Download Chrome zip package (Chrome) - name: Download Chrome zip package (Chrome)
ansible.windows.win_get_url: ansible.windows.win_get_url:
@ -217,21 +205,19 @@
path: "{{ item }}" path: "{{ item }}"
state: absent state: absent
with_items: with_items:
- C:\Program Files\JumpServer\applications\Chrome - 'C:\Program Files\JumpServer\applications\Chrome'
- C:\Program Files\Chrome\chrome-win32 - 'C:\Program Files\Chrome\chrome-win32'
- C:\Program Files\Chrome\chrome-win - 'C:\Program Files\Chrome\chrome-win'
- C:\Program Files\chrome-win - 'C:\Program Files\chrome-win'
- name: Unzip Chrome (Chrome) - name: Unzip Chrome (Chrome)
community.windows.win_unzip: community.windows.win_unzip:
src: "{{ ansible_env.TEMP }}\\chrome-{{ CHROME_VERSION }}-win.zip" src: "{{ ansible_env.TEMP }}\\chrome-{{ CHROME_VERSION }}-win.zip"
dest: C:\Program Files\JumpServer\applications dest: "%ProgramFiles%\\JumpServer\\applications"
- name: Check and Clean global system path (Chrome) - name: Check and Clean global system path (Chrome)
ansible.windows.win_path: ansible.windows.win_path:
elements: elements:
- 'C:\Program Files\Python310\Scripts\'
- 'C:\Program Files\Python310\'
- 'C:\Program Files\JumpServer\drivers\chromedriver-win32' - 'C:\Program Files\JumpServer\drivers\chromedriver-win32'
- 'C:\Program Files\JumpServer\drivers\chromedriver_win32' - 'C:\Program Files\JumpServer\drivers\chromedriver_win32'
- 'C:\Program Files\Chrome\chrome-win32' - 'C:\Program Files\Chrome\chrome-win32'
@ -242,8 +228,8 @@
- name: Set Chrome and driver on the global system path (Chrome) - name: Set Chrome and driver on the global system path (Chrome)
ansible.windows.win_path: ansible.windows.win_path:
elements: elements:
- 'C:\Program Files\JumpServer\applications\Chrome\Application' - '%ProgramFiles%\JumpServer\applications\Chrome\Application'
- 'C:\Program Files\JumpServer\drivers\chromedriver-win64' - '%ProgramFiles%\JumpServer\drivers\chromedriver-win64'
- name: Set Chrome variables disable Google Api (Chrome) - name: Set Chrome variables disable Google Api (Chrome)
ansible.windows.win_environment: ansible.windows.win_environment: