perf: 优化发布机日志输出

pull/13088/head
吴小白 2024-04-13 12:30:56 +08:00 committed by Bryan
parent 2afabd65f9
commit f987515b89
1 changed files with 221 additions and 223 deletions

View File

@ -17,259 +17,257 @@
TinkerInstaller: Tinker_Installer.exe TinkerInstaller: Tinker_Installer.exe
tasks: tasks:
- name: Install RDS-RD-Server (RDS) - block:
ansible.windows.win_feature: - name: Install RDS-RD-Server (RDS)
name: RDS-RD-Server ansible.windows.win_feature:
state: present name: RDS-RD-Server
include_management_tools: yes state: present
register: rds_install include_management_tools: yes
register: rds_install
- name: Stop Tinker before install (jumpserver) - name: Stop Tinker before install (jumpserver)
ansible.windows.win_powershell: ansible.windows.win_powershell:
script: | script: |
if (Get-Process -Name 'tinker' -ErrorAction SilentlyContinue) { if (Get-Process -Name 'tinker' -ErrorAction SilentlyContinue) {
TASKKILL /F /IM tinker.exe /T TASKKILL /F /IM tinker.exe /T
} }
else { else {
$Ansible.Changed = $false $Ansible.Changed = $false
} }
- name: Stop Tinkerd before install (jumpserver) - name: Download JumpServer Tinker installer (jumpserver)
ansible.windows.win_powershell: ansible.windows.win_get_url:
script: | url: "{{ APPLET_DOWNLOAD_HOST }}/download/applets/{{ TinkerInstaller }}"
if (Get-Service -Name 'JumpServer Tinker' -ErrorAction SilentlyContinue) { dest: "{{ ansible_env.TEMP }}\\{{ TinkerInstaller }}"
Stop-Service -Name 'JumpServer Tinker' -Force validate_certs: "{{ not IGNORE_VERIFY_CERTS }}"
}
else {
$Ansible.Changed = $false
}
- name: Download JumpServer Tinker installer (jumpserver) - name: Install JumpServer Tinker (jumpserver)
ansible.windows.win_get_url: ansible.windows.win_package:
url: "{{ APPLET_DOWNLOAD_HOST }}/download/applets/{{ TinkerInstaller }}" path: "{{ ansible_env.TEMP }}\\{{ TinkerInstaller }}"
dest: "{{ ansible_env.TEMP }}\\{{ TinkerInstaller }}" arguments:
validate_certs: "{{ not IGNORE_VERIFY_CERTS }}" - /VERYSILENT
- /SUPPRESSMSGBOXES
- /NORESTART
state: present
- name: Install JumpServer Tinker (jumpserver) - name: Set Tinkerd on the global system path (jumpserver)
ansible.windows.win_package: ansible.windows.win_path:
path: "{{ ansible_env.TEMP }}\\{{ TinkerInstaller }}" elements:
arguments: - '%USERPROFILE%\AppData\Local\Programs\Tinker\'
- /VERYSILENT scope: user
- /SUPPRESSMSGBOXES
- /NORESTART
state: present
- name: Set Tinkerd on the global system path (jumpserver) - name: Download python-3.11.6
ansible.windows.win_path: ansible.windows.win_get_url:
elements: url: "{{ APPLET_DOWNLOAD_HOST }}/download/applets/python-3.11.6-amd64.exe"
- '%USERPROFILE%\AppData\Local\Programs\Tinker\' dest: "{{ ansible_env.TEMP }}\\python-3.11.6-amd64.exe"
scope: user validate_certs: "{{ not IGNORE_VERIFY_CERTS }}"
- name: Download python-3.11.6 - name: Install the python-3.11.6
ansible.windows.win_get_url: ansible.windows.win_package:
url: "{{ APPLET_DOWNLOAD_HOST }}/download/applets/python-3.11.6-amd64.exe" path: "{{ ansible_env.TEMP }}\\python-3.11.6-amd64.exe"
dest: "{{ ansible_env.TEMP }}\\python-3.11.6-amd64.exe" arguments:
validate_certs: "{{ not IGNORE_VERIFY_CERTS }}" - /quiet
- InstallAllUsers=1
- PrependPath=1
- Include_test=0
- Include_launcher=0
state: present
register: win_install_python
- name: Install the python-3.11.6 - name: Check pip command exists
ansible.windows.win_package: ansible.windows.win_powershell:
path: "{{ ansible_env.TEMP }}\\python-3.11.6-amd64.exe" script: |
arguments: if (Get-Command -Name 'pip' -ErrorAction SilentlyContinue) {
- /quiet $Ansible.Changed = $false
- InstallAllUsers=1 }
- PrependPath=1 else {
- Include_test=0 $Ansible.Changed = $true
- Include_launcher=0 }
state: present ignore_errors: yes
register: win_install_python register: check_pip_command
- name: Check pip command exists - name: Reboot if installing requires it
ansible.windows.win_powershell: ansible.windows.win_reboot:
script: | post_reboot_delay: 10
if (Get-Command -Name 'pip' -ErrorAction SilentlyContinue) { test_command: whoami
$Ansible.Changed = $false when: check_pip_command.changed or rds_install.reboot_required or win_install_python.reboot_required
}
else {
$Ansible.Changed = $true
}
register: check_pip_command
ignore_errors: yes
- name: Reboot if installing requires it - name: Set RDS LicenseServer (regedit)
ansible.windows.win_reboot: ansible.windows.win_regedit:
post_reboot_delay: 10 path: HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services
test_command: whoami name: LicenseServers
when: check_pip_command.changed or rds_install.reboot_required or win_install_python.reboot_required data: "{{ RDS_LicenseServer }}"
type: string
when: RDS_Licensing
- name: Set RDS LicenseServer (regedit) - name: Set RDS LicensingMode (regedit)
ansible.windows.win_regedit: ansible.windows.win_regedit:
path: HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services path: HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services
name: LicenseServers name: LicensingMode
data: "{{ RDS_LicenseServer }}" data: "{{ RDS_LicensingMode }}"
type: string type: dword
when: RDS_Licensing when: RDS_Licensing
- name: Set RDS LicensingMode (regedit) - name: Set RDS fSingleSessionPerUser (regedit)
ansible.windows.win_regedit: ansible.windows.win_regedit:
path: HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services path: HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services
name: LicensingMode name: fSingleSessionPerUser
data: "{{ RDS_LicensingMode }}" data: "{{ RDS_fSingleSessionPerUser }}"
type: dword type: dword
when: RDS_Licensing when: RDS_Licensing
- name: Set RDS fSingleSessionPerUser (regedit) - name: Set RDS MaxDisconnectionTime (regedit)
ansible.windows.win_regedit: ansible.windows.win_regedit:
path: HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services path: HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services
name: fSingleSessionPerUser name: MaxDisconnectionTime
data: "{{ RDS_fSingleSessionPerUser }}" data: "{{ RDS_MaxDisconnectionTime }}"
type: dword type: dword
when: RDS_Licensing when: RDS_MaxDisconnectionTime >= 60000
- name: Set RDS MaxDisconnectionTime (regedit) - name: Set RDS RemoteAppLogoffTimeLimit (regedit)
ansible.windows.win_regedit: ansible.windows.win_regedit:
path: HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services path: HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services
name: MaxDisconnectionTime name: RemoteAppLogoffTimeLimit
data: "{{ RDS_MaxDisconnectionTime }}" data: "{{ RDS_RemoteAppLogoffTimeLimit }}"
type: dword type: dword
when: RDS_MaxDisconnectionTime >= 60000
- name: Set RDS RemoteAppLogoffTimeLimit (regedit) - name: Download pip packages
ansible.windows.win_regedit: ansible.windows.win_get_url:
path: HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services url: "{{ APPLET_DOWNLOAD_HOST }}/download/applets/pip_packages.zip"
name: RemoteAppLogoffTimeLimit dest: "{{ ansible_env.TEMP }}\\pip_packages.zip"
data: "{{ RDS_RemoteAppLogoffTimeLimit }}" validate_certs: "{{ not IGNORE_VERIFY_CERTS }}"
type: dword
- name: Download pip packages - name: Unzip pip_packages
ansible.windows.win_get_url: community.windows.win_unzip:
url: "{{ APPLET_DOWNLOAD_HOST }}/download/applets/pip_packages.zip" src: "{{ ansible_env.TEMP }}\\pip_packages.zip"
dest: "{{ ansible_env.TEMP }}\\pip_packages.zip" dest: "{{ ansible_env.TEMP }}\\pip_packages"
validate_certs: "{{ not IGNORE_VERIFY_CERTS }}"
- name: Unzip pip_packages - name: Install python requirements offline
community.windows.win_unzip: ansible.windows.win_powershell:
src: "{{ ansible_env.TEMP }}\\pip_packages.zip" script: |
dest: "{{ ansible_env.TEMP }}\\pip_packages" pip install -r '{{ ansible_env.TEMP }}\pip_packages\pip_packages\requirements.txt' --no-index --find-links='{{ ansible_env.TEMP }}\pip_packages\pip_packages'
- name: Install python requirements offline - name: Stop chromedriver before install (jumpserver)
ansible.windows.win_powershell: ansible.windows.win_powershell:
script: | script: |
pip install -r '{{ ansible_env.TEMP }}\pip_packages\pip_packages\requirements.txt' --no-index --find-links='{{ ansible_env.TEMP }}\pip_packages\pip_packages' if (Get-Process -Name 'chromedriver' -ErrorAction SilentlyContinue) {
TASKKILL /F /IM chromedriver.exe /T
}
else {
$Ansible.Changed = $false
}
- name: Stop chromedriver before install (jumpserver) - name: Download chromedriver (Chrome)
ansible.windows.win_powershell: ansible.windows.win_get_url:
script: | url: "{{ APPLET_DOWNLOAD_HOST }}/download/applets/chromedriver-win64.zip"
if (Get-Process -Name 'chromedriver' -ErrorAction SilentlyContinue) { dest: "{{ ansible_env.TEMP }}\\chromedriver-win64.zip"
TASKKILL /F /IM chromedriver.exe /T validate_certs: "{{ not IGNORE_VERIFY_CERTS }}"
}
else {
$Ansible.Changed = $false
}
- name: Download chromedriver (Chrome) - name: Remove old chromedriver (Chrome)
ansible.windows.win_get_url: ansible.windows.win_file:
url: "{{ APPLET_DOWNLOAD_HOST }}/download/applets/chromedriver-win64.zip" path: "{{ item }}"
dest: "{{ ansible_env.TEMP }}\\chromedriver-win64.zip" state: absent
validate_certs: "{{ not IGNORE_VERIFY_CERTS }}" with_items:
- 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
- name: Remove old chromedriver (Chrome) - name: Unzip chromedriver (Chrome)
ansible.windows.win_file: community.windows.win_unzip:
path: "{{ item }}" src: "{{ ansible_env.TEMP }}\\chromedriver-win64.zip"
state: absent dest: C:\Program Files\JumpServer\drivers
with_items:
- 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
- name: Unzip chromedriver (Chrome) - name: Stop Chrome before install (jumpserver)
community.windows.win_unzip: ansible.windows.win_powershell:
src: "{{ ansible_env.TEMP }}\\chromedriver-win64.zip" script: |
dest: C:\Program Files\JumpServer\drivers if (Get-Process -Name 'chrome' -ErrorAction SilentlyContinue) {
TASKKILL /F /IM chrome.exe /T
}
else {
$Ansible.Changed = $false
}
- name: Stop Chrome before install (jumpserver) - name: Download Chrome zip package (Chrome)
ansible.windows.win_powershell: ansible.windows.win_get_url:
script: | url: "{{ APPLET_DOWNLOAD_HOST }}/download/applets/chrome-win.zip"
if (Get-Process -Name 'chrome' -ErrorAction SilentlyContinue) { dest: "{{ ansible_env.TEMP }}\\chrome-win.zip"
TASKKILL /F /IM chrome.exe /T validate_certs: "{{ not IGNORE_VERIFY_CERTS }}"
}
else {
$Ansible.Changed = $false
}
- name: Download Chrome zip package (Chrome) - name: Remove old Chrome (Chrome)
ansible.windows.win_get_url: ansible.windows.win_file:
url: "{{ APPLET_DOWNLOAD_HOST }}/download/applets/chrome-win.zip" path: "{{ item }}"
dest: "{{ ansible_env.TEMP }}\\chrome-win.zip" state: absent
validate_certs: "{{ not IGNORE_VERIFY_CERTS }}" with_items:
- C:\Program Files\JumpServer\applications\Chrome
- C:\Program Files\Chrome\chrome-win32
- C:\Program Files\Chrome\chrome-win
- C:\Program Files\chrome-win
- name: Remove old Chrome (Chrome) - name: Unzip Chrome (Chrome)
ansible.windows.win_file: community.windows.win_unzip:
path: "{{ item }}" src: "{{ ansible_env.TEMP }}\\chrome-win.zip"
state: absent dest: C:\Program Files\JumpServer\applications
with_items:
- C:\Program Files\JumpServer\applications\Chrome
- C:\Program Files\Chrome\chrome-win32
- C:\Program Files\Chrome\chrome-win
- C:\Program Files\chrome-win
- name: Unzip Chrome (Chrome) - name: Check and Clean global system path (Chrome)
community.windows.win_unzip: ansible.windows.win_path:
src: "{{ ansible_env.TEMP }}\\chrome-win.zip" elements:
dest: C:\Program Files\JumpServer\applications - '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\Chrome\chrome-win32'
- 'C:\Program Files\Chrome\chrome-win'
- 'C:\Program Files\chrome-win'
state: absent
- name: Check and Clean 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\Python310\Scripts\' - 'C:\Program Files\JumpServer\applications\Chrome\Application'
- 'C:\Program Files\Python310\' - 'C:\Program Files\JumpServer\drivers\chromedriver-win64'
- '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-win'
- 'C:\Program Files\chrome-win'
state: absent
- name: Set Chrome and driver on the global system path (Chrome) - name: Set Chrome variables disable Google Api (Chrome)
ansible.windows.win_path: ansible.windows.win_environment:
elements: level: machine
- 'C:\Program Files\JumpServer\applications\Chrome\Application' variables:
- 'C:\Program Files\JumpServer\drivers\chromedriver-win64' GOOGLE_API_KEY: ''
GOOGLE_DEFAULT_CLIENT_ID: ''
GOOGLE_DEFAULT_CLIENT_SECRET: ''
- name: Set Chrome variables disable Google Api (Chrome) - name: Generate tinkerd component config
ansible.windows.win_environment: ansible.windows.win_powershell:
level: machine script: |
variables: tinkerd config --hostname {{ HOST_NAME }} --core_host {{ CORE_HOST }} --token {{ BOOTSTRAP_TOKEN }} --host_id {{ HOST_ID }} --ignore-verify-certs {{ IGNORE_VERIFY_CERTS }}
GOOGLE_API_KEY: ''
GOOGLE_DEFAULT_CLIENT_ID: ''
GOOGLE_DEFAULT_CLIENT_SECRET: ''
- name: Generate tinkerd component config - name: Install tinkerd service
ansible.windows.win_powershell: ansible.windows.win_powershell:
script: | script: |
tinkerd config --hostname {{ HOST_NAME }} --core_host {{ CORE_HOST }} --token {{ BOOTSTRAP_TOKEN }} --host_id {{ HOST_ID }} --ignore-verify-certs {{ IGNORE_VERIFY_CERTS }} tinkerd service install
- name: Install tinkerd service - name: Start tinkerd service
ansible.windows.win_powershell: ansible.windows.win_powershell:
script: | script: |
tinkerd service install tinkerd service start
- name: Start tinkerd service - name: Wait Tinker api health
ansible.windows.win_powershell: ansible.windows.win_uri:
script: | url: http://localhost:6068/api/health/
tinkerd service start status_code: 200
method: GET
register: _result
until: _result.status_code == 200
retries: 30
delay: 5
- name: Wait Tinker api health - name: Sync all remote applets
ansible.windows.win_uri: ansible.windows.win_powershell:
url: http://localhost:6068/api/health/ script: |
status_code: 200 tinkerd install all
method: GET register: sync_remote_applets
register: _result
until: _result.status_code == 200
retries: 30
delay: 5
- name: Sync all remote applets rescue:
ansible.windows.win_powershell: - debug:
script: | var: ansible_failed_result
tinkerd install all - fail:
msg: "Failed to deploy applet host"