Restore from Gitea ZIP snapshot (12.08.2026) after full instance reinstall
Git history was lost when the previous Gitea instance was wiped and reinstalled due to an unresolved corruption bug — this commit is the last known-good file content, exported before the reinstall. Prior commit history is not recoverable through this path.
This commit is contained in:
@@ -0,0 +1,225 @@
|
||||
---
|
||||
- name: Prepare Dynamic Inventory
|
||||
hosts: localhost
|
||||
gather_facts: yes
|
||||
tasks:
|
||||
- name: Set target host variable
|
||||
set_fact:
|
||||
target_host: "{{ target_ip }}"
|
||||
when: target_ip is defined and target_ip != ''
|
||||
|
||||
- name: Validate target host
|
||||
fail:
|
||||
msg: "Please provide target host IP address or domain name"
|
||||
when: target_host is not defined or target_host == ''
|
||||
|
||||
- name: Display target information
|
||||
debug:
|
||||
msg: |
|
||||
============================================
|
||||
Target Host: {{ target_host }}
|
||||
============================================
|
||||
|
||||
- name: Test connectivity to target (WinRM port)
|
||||
ansible.builtin.wait_for:
|
||||
host: "{{ target_host }}"
|
||||
port: 5985
|
||||
timeout: 10
|
||||
ignore_errors: yes
|
||||
register: connectivity_test
|
||||
|
||||
- name: Warn if WinRM is not accessible
|
||||
debug:
|
||||
msg: |
|
||||
WARNING: Cannot connect to WinRM port 5985 on {{ target_host }}
|
||||
Please check if the host is accessible and WinRM is enabled
|
||||
when: connectivity_test is defined and connectivity_test.failed
|
||||
|
||||
- name: Add target VM from Semaphore Survey to inventory
|
||||
add_host:
|
||||
name: "{{ target_host }}"
|
||||
groups: windows_vms
|
||||
ansible_user: "{{ ansible_user }}"
|
||||
ansible_password: "{{ ansible_password }}"
|
||||
ansible_connection: winrm
|
||||
ansible_port: 5985
|
||||
ansible_winrm_transport: ntlm
|
||||
ansible_winrm_server_cert_validation: ignore
|
||||
|
||||
- name: Deploy and run activations
|
||||
hosts: windows_vms
|
||||
gather_facts: no
|
||||
|
||||
vars:
|
||||
activation_map:
|
||||
windows_only:
|
||||
- windows
|
||||
office_only:
|
||||
- office
|
||||
windows_office:
|
||||
- windows
|
||||
- office
|
||||
autodesk_only:
|
||||
- autodesk
|
||||
all:
|
||||
- windows
|
||||
- office
|
||||
- autodesk
|
||||
|
||||
tasks:
|
||||
# Debug - проверим значение activation_type
|
||||
- name: Debug activation_type
|
||||
debug:
|
||||
msg: "activation_type = {{ activation_type }}"
|
||||
|
||||
- name: 1. Create distr directory
|
||||
ansible.windows.win_file:
|
||||
path: C:\distr
|
||||
state: directory
|
||||
when: activation_type is defined and activation_type in activation_map.keys()
|
||||
|
||||
- name: 2. Copy activation files from network share
|
||||
block:
|
||||
- name: 2a. Copy MAS_AIO.cmd
|
||||
ansible.windows.win_copy:
|
||||
src: \\fs\alls\MAS_AIO.cmd
|
||||
dest: C:\distr\MAS_AIO.cmd
|
||||
remote_src: yes
|
||||
become: yes
|
||||
become_method: runas
|
||||
become_flags: logon_type=new_credentials logon_flags=netcredentials_only
|
||||
vars:
|
||||
ansible_become_user: "{{ domain_user }}"
|
||||
ansible_become_pass: "{{ domain_password }}"
|
||||
when: activation_type is defined and activation_type in ['windows_only', 'windows_office', 'all']
|
||||
|
||||
- name: 2b. Copy AdskNLM.exe
|
||||
ansible.windows.win_copy:
|
||||
src: \\fs\alls\AdskNLM.exe
|
||||
dest: C:\distr\AdskNLM.exe
|
||||
remote_src: yes
|
||||
become: yes
|
||||
become_method: runas
|
||||
become_flags: logon_type=new_credentials logon_flags=netcredentials_only
|
||||
vars:
|
||||
ansible_become_user: "{{ domain_user }}"
|
||||
ansible_become_pass: "{{ domain_password }}"
|
||||
when: activation_type is defined and activation_type in ['autodesk_only', 'all']
|
||||
|
||||
# Windows Activation
|
||||
- name: 3. Activate Windows
|
||||
block:
|
||||
- name: 3a. Execute MAS_AIO.cmd for Windows
|
||||
ansible.windows.win_shell: C:\distr\MAS_AIO.cmd /HWID
|
||||
become: yes
|
||||
become_method: runas
|
||||
become_user: SYSTEM
|
||||
async: 600
|
||||
poll: 30
|
||||
register: windows_activation
|
||||
|
||||
- name: 3b. Check Windows activation status
|
||||
ansible.windows.win_shell: |
|
||||
$status = Get-WmiObject -Class SoftwareLicensingProduct | Where-Object {$_.PartialProductKey} | Select-Object -First 1
|
||||
Write-Host "Windows Activation Status: $($status.LicenseStatus)"
|
||||
if ($status.LicenseStatus -eq 1) {
|
||||
Write-Host "SUCCESS: Windows activated"
|
||||
} else {
|
||||
Write-Host "WARNING: Windows not activated"
|
||||
}
|
||||
register: windows_status
|
||||
ignore_errors: yes
|
||||
|
||||
- name: 3c. Display Windows activation result
|
||||
debug:
|
||||
var: windows_status.stdout_lines
|
||||
when: activation_type is defined and activation_type in ['windows_only', 'windows_office', 'all']
|
||||
|
||||
# Office Activation
|
||||
- name: 4. Activate Office
|
||||
block:
|
||||
- name: 4a. Execute MAS_AIO.cmd for Office
|
||||
ansible.windows.win_shell: C:\distr\MAS_AIO.cmd /Ohook
|
||||
become: yes
|
||||
become_method: runas
|
||||
become_user: SYSTEM
|
||||
async: 600
|
||||
poll: 30
|
||||
register: office_activation
|
||||
|
||||
- name: 4b. Check Office activation status
|
||||
ansible.windows.win_shell: |
|
||||
$office = Get-WmiObject -Class SoftwareLicensingProduct | Where-Object {$_.Name -like "*Office*" -and $_.PartialProductKey}
|
||||
if ($office) {
|
||||
Write-Host "Office found: $($office.Name)"
|
||||
Write-Host "Office Activation Status: $($office.LicenseStatus)"
|
||||
if ($office.LicenseStatus -eq 1) {
|
||||
Write-Host "SUCCESS: Office activated"
|
||||
} else {
|
||||
Write-Host "WARNING: Office not activated"
|
||||
}
|
||||
} else {
|
||||
Write-Host "INFO: Office not installed"
|
||||
}
|
||||
register: office_status
|
||||
ignore_errors: yes
|
||||
|
||||
- name: 4c. Display Office activation result
|
||||
debug:
|
||||
var: office_status.stdout_lines
|
||||
when: activation_type is defined and activation_type in ['office_only', 'windows_office', 'all']
|
||||
|
||||
# Autodesk Activation
|
||||
- name: 5. Activate Autodesk
|
||||
block:
|
||||
- name: 5a. Start AdskNLM and wait for activation
|
||||
ansible.windows.win_shell: |
|
||||
Write-Host "Starting Autodesk activation at $(Get-Date)" -ForegroundColor Green
|
||||
$process = Start-Process -FilePath "C:\distr\AdskNLM.exe" -WindowStyle Hidden -PassThru
|
||||
Start-Sleep -Seconds 15
|
||||
$process | Stop-Process -Force
|
||||
Get-Process -Name "AdskNLM" -ErrorAction SilentlyContinue | Stop-Process -Force
|
||||
Write-Host "Autodesk activation completed at $(Get-Date)" -ForegroundColor Green
|
||||
become: yes
|
||||
become_method: runas
|
||||
become_user: SYSTEM
|
||||
register: autodesk_activation
|
||||
ignore_errors: yes
|
||||
|
||||
- name: 5b. Clean up AdskNLM processes
|
||||
ansible.windows.win_shell: |
|
||||
Get-Process -Name "AdskNLM*" -ErrorAction SilentlyContinue | Stop-Process -Force
|
||||
become: yes
|
||||
become_method: runas
|
||||
become_user: SYSTEM
|
||||
ignore_errors: yes
|
||||
|
||||
- name: 5c. Verify Autodesk activation
|
||||
ansible.windows.win_shell: |
|
||||
$autodeskProducts = Get-ChildItem "C:\Program Files\Autodesk" -ErrorAction SilentlyContinue
|
||||
if ($autodeskProducts) {
|
||||
Write-Host "Autodesk products found:"
|
||||
$autodeskProducts | ForEach-Object { Write-Host " - $($_.Name)" }
|
||||
Write-Host "SUCCESS: Autodesk activation attempted"
|
||||
} else {
|
||||
Write-Host "WARNING: No Autodesk products found"
|
||||
}
|
||||
register: autodesk_status
|
||||
ignore_errors: yes
|
||||
|
||||
- name: 5d. Display Autodesk activation result
|
||||
debug:
|
||||
var: autodesk_status.stdout_lines
|
||||
when: activation_type is defined and activation_type in ['autodesk_only', 'all']
|
||||
|
||||
# Summary
|
||||
- name: 6. Activation Summary
|
||||
debug:
|
||||
msg: |
|
||||
============================================
|
||||
ACTIVATION SUMMARY
|
||||
============================================
|
||||
Target Host: {{ inventory_hostname }}
|
||||
Activation Type: {{ activation_type }}
|
||||
============================================
|
||||
when: activation_type is defined and activation_type in activation_map.keys()
|
||||
Reference in New Issue
Block a user