Created
May 15, 2025 14:15
-
-
Save chrodriguez/afa8cad08af951b8aa28c597da21b899 to your computer and use it in GitHub Desktop.
Windows 2022 - Vagrantfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Vagrant.configure("2") do |config| | |
config.vm.box = "peru/windows-server-2022-standard-x64-eval" | |
config.vm.provider :libvirt do |libvirt| | |
libvirt.nested = true | |
libvirt.cpu_mode = "host-model" | |
libvirt.cpus = 4 | |
libvirt.memory = 4096 | |
end | |
config.vm.provision "shell", privileged: true, inline: <<-PS | |
Write-Host "Checking if WSL is already installed..." | |
$feature = Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux | |
$vmPlatform = Get-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform | |
$needsReboot = $false | |
if ($feature.State -ne "Enabled") { | |
Write-Host "Installing WSL feature..." | |
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux -NoRestart | |
$needsReboot = $true | |
} | |
if ($vmPlatform.State -ne "Enabled") { | |
Write-Host "Installing VirtualMachinePlatform feature..." | |
Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform -NoRestart | |
$needsReboot = $true | |
} | |
if (-Not (Test-Path "C:\\Program Files\\Docker\\Docker\\Docker Desktop.exe")) { | |
if (-Not (Get-Command choco -ErrorAction SilentlyContinue)) { | |
Set-ExecutionPolicy Bypass -Scope Process -Force | |
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072 | |
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) | |
} | |
} | |
if ($needsReboot) { | |
Write-Host "Reboot required. Registering reboot flag." | |
shutdown /r /t 5 | |
} else { | |
Write-Host "WSL already installed. No reboot needed." | |
} | |
PS | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment