Add Windows game optimization setup and configuration scripts

This commit is contained in:
2025-07-05 21:36:47 +02:00
parent bc85a7bcef
commit 372df1b9e9
11 changed files with 683 additions and 5 deletions
+5
View File
@@ -0,0 +1,5 @@
@echo off
start "" "C:\Program Files (x86)\Steam\steam.exe"
start "" "C:\Program Files\Sunshine\sunshine.exe"
start "" "C:\Path\To\MetaAirLink\metaairlink.exe"
exit
@@ -0,0 +1,11 @@
hostname: game-01.lab.alexpires.me
ansible_user: "{{ lookup('env', 'ANSIBLE_USER') }}"
ansible_password: "{{ lookup('env', 'WIN_PROVISION_PASSWORD') }}"
ansible_connection: winrm
ansible_winrm_transport: basic
ansible_winrm_server_cert_validation: ignore
game_user: "GameUser"
game_password: "{{ lookup('env', 'WIN_GAME_PASSWORD') }}"
game_default_groups:
- Administradores # This is mandatory to install games
@@ -1,7 +1,7 @@
hostname: gpu-01.lab.alexpires.me
ansible_user: "{{ lookup('env', 'ANSIBLE_USER') }}"
network_interface: eno1
network_interface: enp3s0
# Users
login_users:
+7
View File
@@ -0,0 +1,7 @@
- name: Setup Windows Game Optimization
hosts: windows_game
tasks:
- name: Setup WakeOnLan
ansible.builtin.include_tasks:
file: tasks/windows_game.yml
+2
View File
@@ -13,3 +13,5 @@ KMS_KEY_ARN=$KMS_KEY_ARN
GITEA_APP_TOKEN=$GITEA_APP_TOKEN
CLOUDNS_AUTH_ID=$CLOUDNS_AUTH_ID
CLOUDNS_PASSWORD=$CLOUDNS_PASSWORD
WIN_PROVISION_PASSWORD=$WIN_PROVISION_PASSWORD
WIN_GAME_PASSWORD=$WIN_GAME_PASSWORD
+186
View File
@@ -0,0 +1,186 @@
- name: Create limited GameUser
ansible.windows.win_user:
name: "{{ game_user }}"
password: "{{ game_password }}"
groups: "{{ game_default_groups }}"
account_disabled: false
password_never_expires: true
user_cannot_change_password: true
state: present
- name: Configure auto-login for GameUser
ansible.windows.win_regedit:
path: HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
name: "{{ item.name }}"
data: "{{ item.data }}"
type: string
loop:
- { name: "AutoAdminLogon", data: "1" }
- { name: "DefaultUserName", data: "{{ game_user }}" }
- { name: "DefaultPassword", data: "{{ game_password }}" }
- { name: "DefaultDomainName", data: "{{ ansible_hostname }}" }
- name: Create launcher script directory
ansible.windows.win_file:
path: C:\GameShell
state: directory
- name: Deploy launcher.bat
ansible.windows.win_copy:
dest: C:\GameShell\launcher.bat
content: "{{ lookup('file', 'scripts/launcher.bat') }}"
- name: Set High Performance Power Plan
ansible.windows.win_command: powercfg -setactive SCHEME_MIN
- name: Disable auto suspend (sleep) for plugged in
ansible.windows.win_command: powercfg -change -standby-timeout-ac 0
- name: Disable auto suspend (sleep) for battery
ansible.windows.win_command: powercfg -change -standby-timeout-dc 0
- name: Disable Windows Defender Real-Time Protection
ansible.windows.win_shell: Set-MpPreference -DisableRealtimeMonitoring $true
- name: Remove unnecessary startup items (HKLM)
ansible.windows.win_regedit:
path: HKLM:\Software\Microsoft\Windows\CurrentVersion\Run
name: SecurityHealth
state: absent
- name: Remove startup folder shortcuts (user)
ansible.windows.win_file:
path: "{{ item }}"
state: absent
with_fileglob:
- "{{ ansible_env.APPDATA }}\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\*.lnk"
- name: Remove startup folder shortcuts (all users)
ansible.windows.win_file:
path: "{{ item }}"
state: absent
with_fileglob:
- "C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\*.lnk"
- name: Disable Xbox Game Bar and DVR
ansible.windows.win_regedit:
path: HKCU:\Software\Microsoft\Windows\CurrentVersion\GameDVR
name: AppCaptureEnabled
data: 0
type: dword
state: present
- name: Disable GameDVR_Enabled
ansible.windows.win_regedit:
path: HKCU:\System\GameConfigStore
name: GameDVR_Enabled
data: 0
type: dword
state: present
- name: Disable GameDVR_FSEBehaviorMode
ansible.windows.win_regedit:
path: HKCU:\System\GameConfigStore
name: GameDVR_FSEBehaviorMode
data: 2
type: dword
state: present
- name: Disable GameDVR_HonorUserFSEBehaviorMode
ansible.windows.win_regedit:
path: HKCU:\System\GameConfigStore
name: GameDVR_HonorUserFSEBehaviorMode
data: 1
type: dword
state: present
- name: Disable Windows notifications
ansible.windows.win_regedit:
path: HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications
name: ToastEnabled
data: 0
type: dword
state: present
- name: Disable background services
vars:
services_to_disable:
- WSearch
- SysMain
- DiagTrack
- XblAuthManager
- XblGameSave
- XboxGipSvc
- Fax
- MapsBroker
- RetailDemo
- RemoteRegistry
- WMPNetworkSvc
- edgeupdate
- WpnService
- BITS
- WerSvc
- Spooler
- SCardSvr
ansible.windows.win_service:
name: "{{ item }}"
start_mode: disabled
state: stopped
loop: "{{ services_to_disable }}"
- name: Get all services
ansible.windows.win_service_info:
register: win_services
- name: Disable scheduled telemetry tasks
vars:
scheduled_tasks_to_disable:
- "\\Microsoft\\Windows\\Application Experience\\ProgramDataUpdater"
- "\\Microsoft\\Windows\\Customer Experience Improvement Program\\Consolidator"
- "\\Microsoft\\Windows\\Customer Experience Improvement Program\\KernelCeipTask"
- "\\Microsoft\\Windows\\Feedback\\Siuf\\DmClient"
- "\\Microsoft\\Windows\\Windows Error Reporting\\QueueReporting"
ansible.windows.win_shell: |
schtasks /Change /TN "{{ item }}" /Disable
loop: "{{ scheduled_tasks_to_disable }}"
register: telemetry_task_result
failed_when: "{{ telemetry_task_result.rc != 0 and ('ERROR: The system cannot find the file specified.' not in telemetry_task_result.stderr) }}"
- name: Disable Windows Search feature
ansible.windows.win_shell: DISM /Online /Disable-Feature /FeatureName:SearchEngine-Client-Package /NoRestart
register: disable_search_result
failed_when: >
disable_search_result.rc != 0 and
('The specified package is not valid Windows package' not in disable_search_result.stderr) and
('is already disabled' not in disable_search_result.stdout)
- name: Disable Windows Media Player feature
ansible.windows.win_shell: DISM /Online /Disable-Feature /FeatureName:WindowsMediaPlayer /NoRestart
register: disable_wmp_result
failed_when: >
disable_wmp_result.rc != 0 and
('The specified package is not valid Windows package' not in disable_wmp_result.stderr) and
('is already disabled' not in disable_wmp_result.stdout)
- name: Disable Print to PDF
ansible.windows.win_shell: DISM /Online /Disable-Feature /FeatureName:Printing-PrintToPDFServices-Features /NoRestart
register: disable_print_pdf_result
failed_when: >
disable_print_pdf_result.rc != 0 and
('The specified package is not valid Windows package' not in disable_print_pdf_result.stderr) and
('is already disabled' not in disable_print_pdf_result.stdout)
- name: Reminder - NVIDIA Control Panel Tweaks (manual)
ansible.builtin.debug:
msg: |
Please manually set the following in NVIDIA Control Panel:
- Power Management: Prefer Maximum Performance
- Low Latency Mode: Ultra
- Vertical Sync: Off or Fast Sync (depending on monitor)
# - name: Set custom shell to launcher.bat
# ansible.windows.win_regedit:
# path: HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
# name: Shell
# data: C:\GameShell\launcher.bat
# type: string