From ea3daedb14b48c0ec71fb342d66cfe999132f38e Mon Sep 17 00:00:00 2001 From: Stefan Scherer Date: Sun, 22 Aug 2021 13:15:27 +0200 Subject: [PATCH] Add Windows Server 2022 Eval --- README.md | 3 +- answer_files/2022/Autounattend.xml | 4 +- answer_files/2022_core/Autounattend.xml | 284 ++++++++++++++++++++++++ build_windows_2022.sh | 4 +- windows_2022.json | 8 +- windows_2022_core.json | 175 +++++++++++++++ 6 files changed, 468 insertions(+), 10 deletions(-) create mode 100644 answer_files/2022_core/Autounattend.xml create mode 100644 windows_2022_core.json diff --git a/README.md b/README.md index 46501d0d..bfe65170 100644 --- a/README.md +++ b/README.md @@ -29,10 +29,9 @@ The following Windows versions are known to work (built with VMware Fusion Pro * Windows 10 * Windows 10 2004 -> Vagrant Cloud box [StefanScherer/windows_10](https://app.vagrantup.com/StefanScherer/boxes/windows_10) * Windows 10 Insider -* Windows Server 2016 Desktop -> Vagrant Cloud box [StefanScherer/windows_2016](https://app.vagrantup.com/StefanScherer/boxes/windows_2016) +* Windows Server 2022 Desktop -> Vagrant Cloud box [StefanScherer/windows_2022](https://app.vagrantup.com/StefanScherer/boxes/windows_2022) * Windows Server 2019 Desktop -> Vagrant Cloud box [StefanScherer/windows_2019](https://app.vagrantup.com/StefanScherer/boxes/windows_2019) * Windows Server Core - * Windows Server 2016 without and with Docker -> Vagrant Cloud box [StefanScherer/windows_2016_docker](https://app.vagrantup.com/StefanScherer/boxes/windows_2016_docker) * Windows Server 2019 without and with Docker -> Vagrant Cloud box [StefanScherer/windows_2019_docker](https://app.vagrantup.com/StefanScherer/boxes/windows_2019_docker) * Windows Server 1709, 1803, 1809, 1903, 1909, and 2004 all without and with Docker * Windows Server InsiderPreview Semi-Annual without and with Docker diff --git a/answer_files/2022/Autounattend.xml b/answer_files/2022/Autounattend.xml index 7957a165..9175599b 100644 --- a/answer_files/2022/Autounattend.xml +++ b/answer_files/2022/Autounattend.xml @@ -104,8 +104,8 @@ - /IMAGE/INDEX - 4 + /IMAGE/NAME + Windows Server 2022 SERVERDATACENTER diff --git a/answer_files/2022_core/Autounattend.xml b/answer_files/2022_core/Autounattend.xml new file mode 100644 index 00000000..d09bba23 --- /dev/null +++ b/answer_files/2022_core/Autounattend.xml @@ -0,0 +1,284 @@ + + + + + + + + + E:\viostor\2k19\amd64 + + + + E:\NetKVM\2k19\amd64 + + + + E:\Balloon\2k19\amd64 + + + + E:\pvpanic\2k19\amd64 + + + + E:\qemupciserial\2k19\amd64 + + + + E:\qxldod\2k19\amd64 + + + + E:\vioinput\2k19\amd64 + + + + E:\viorng\2k19\amd64 + + + + E:\vioscsi\2k19\amd64 + + + + E:\vioserial\2k19\amd64 + + + + + + + en-US + + en-US + en-US + en-US + en-US + en-US + + + + + + + Primary + 1 + 350 + + + 2 + Primary + true + + + + + true + NTFS + + 1 + 1 + + + NTFS + + C + 2 + 2 + + + 0 + true + + + + + + + /IMAGE/NAME + Windows Server 2022 SERVERDATACENTERCORE + + + + 0 + 2 + + + + + + + + OnError + + true + Vagrant + Vagrant + + + + + + + false + + vagrant-2022 + Pacific Standard Time + + + + true + + + false + false + + + true + + + true + + + + + + + vagrant + true</PlainText> + </Password> + <Enabled>true</Enabled> + <Username>vagrant</Username> + </AutoLogon> + <FirstLogonCommands> + <SynchronousCommand wcm:action="add"> + <CommandLine>cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"</CommandLine> + <Description>Set Execution Policy 64 Bit</Description> + <Order>1</Order> + <RequiresUserInput>true</RequiresUserInput> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>C:\Windows\SysWOW64\cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"</CommandLine> + <Description>Set Execution Policy 32 Bit</Description> + <Order>2</Order> + <RequiresUserInput>true</RequiresUserInput> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\disable-winrm.ps1</CommandLine> + <Description>Disable WinRM</Description> + <Order>3</Order> + <RequiresUserInput>true</RequiresUserInput> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v HideFileExt /t REG_DWORD /d 0 /f</CommandLine> + <Order>4</Order> + <Description>Show file extensions in Explorer</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\System32\reg.exe ADD HKCU\Console /v QuickEdit /t REG_DWORD /d 1 /f</CommandLine> + <Order>5</Order> + <Description>Enable QuickEdit mode</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v Start_ShowRun /t REG_DWORD /d 1 /f</CommandLine> + <Order>6</Order> + <Description>Show Run command in Start Menu</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v StartMenuAdminTools /t REG_DWORD /d 1 /f</CommandLine> + <Order>7</Order> + <Description>Show Administrative Tools in Start Menu</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\System32\reg.exe ADD HKLM\SYSTEM\CurrentControlSet\Control\Power\ /v HibernateFileSizePercent /t REG_DWORD /d 0 /f</CommandLine> + <Order>8</Order> + <Description>Zero Hibernation File</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\System32\reg.exe ADD HKLM\SYSTEM\CurrentControlSet\Control\Power\ /v HibernateEnabled /t REG_DWORD /d 0 /f</CommandLine> + <Order>9</Order> + <Description>Disable Hibernation Mode</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>cmd.exe /c wmic useraccount where "name='vagrant'" set PasswordExpires=FALSE</CommandLine> + <Order>10</Order> + <Description>Disable password expiration for vagrant user</Description> + </SynchronousCommand> + <!-- WITHOUT WINDOWS UPDATES --> + <!-- + <SynchronousCommand wcm:action="add"> + <CommandLine>cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\enable-winrm.ps1</CommandLine> + <Description>Enable WinRM</Description> + <Order>99</Order> + </SynchronousCommand> + --> + <!-- END WITHOUT WINDOWS UPDATES --> + <!-- WITH WINDOWS UPDATES --> + <SynchronousCommand wcm:action="add"> + <CommandLine>cmd.exe /c a:\microsoft-updates.bat</CommandLine> + <Order>98</Order> + <Description>Enable Microsoft Updates</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\disable-screensaver.ps1</CommandLine> + <Description>Disable Screensaver</Description> + <Order>99</Order> + <RequiresUserInput>true</RequiresUserInput> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\win-updates.ps1</CommandLine> + <Description>Install Windows Updates</Description> + <Order>100</Order> + <RequiresUserInput>true</RequiresUserInput> + </SynchronousCommand> + <!-- END WITH WINDOWS UPDATES --> + </FirstLogonCommands> + <OOBE> + <HideEULAPage>true</HideEULAPage> + <HideLocalAccountScreen>true</HideLocalAccountScreen> + <HideOEMRegistrationScreen>true</HideOEMRegistrationScreen> + <HideOnlineAccountScreens>true</HideOnlineAccountScreens> + <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE> + <NetworkLocation>Home</NetworkLocation> + <ProtectYourPC>1</ProtectYourPC> + </OOBE> + <UserAccounts> + <AdministratorPassword> + <Value>vagrant</Value> + <PlainText>true</PlainText> + </AdministratorPassword> + <LocalAccounts> + <LocalAccount wcm:action="add"> + <Password> + <Value>vagrant</Value> + <PlainText>true</PlainText> + </Password> + <Group>administrators</Group> + <DisplayName>Vagrant</DisplayName> + <Name>vagrant</Name> + <Description>Vagrant User</Description> + </LocalAccount> + </LocalAccounts> + </UserAccounts> + <RegisteredOwner/> + </component> + </settings> + <settings pass="offlineServicing"> + <component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-LUA-Settings" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS"> + <EnableLUA>false</EnableLUA> + </component> + </settings> + <cpi:offlineImage xmlns:cpi="urn:schemas-microsoft-com:cpi" cpi:source="wim:c:/wim/install.wim#Windows Server 2022 SERVERSTANDARD"/> +</unattend> diff --git a/build_windows_2022.sh b/build_windows_2022.sh index 9e200431..7c7fd211 100755 --- a/build_windows_2022.sh +++ b/build_windows_2022.sh @@ -3,5 +3,5 @@ packer build \ --only=vmware-iso \ --var vhv_enable=true \ - --var iso_url=~/Downloads/20348.1.210507-1500.fe_release_SERVER_EVAL_x64FRE_en-us.iso \ - windows_2022.json + --var iso_url=~/Downloads/20348.169.210806-2348.fe_release_svc_refresh_SERVER_EVAL_x64FRE_en-us.iso \ + windows_2022_core.json diff --git a/windows_2022.json b/windows_2022.json index 13702a12..a7dcdc8a 100644 --- a/windows_2022.json +++ b/windows_2022.json @@ -76,7 +76,7 @@ "boot_wait": "2m", "communicator": "winrm", "cpus": 2, - "disk_adapter_type": "nvme", + "disk_adapter_type": "lsisas1068", "disk_size": "{{user `disk_size`}}", "disk_type_id": "{{user `disk_type_id`}}", "floppy_files": [ @@ -185,13 +185,13 @@ "memory": "2048", "headless": "false", "hyperv_switchname": "{{env `hyperv_switchname`}}", - "iso_checksum": "sha256:2ee3a0325f7230b1ff68bd8db2695f4102eae4ff32118382b1ab2e2b98a71aaa", - "iso_url": "https://software-download.microsoft.com/download/sg/20348.1.210507-1500.fe_release_SERVER_EVAL_x64FRE_en-us.iso", + "iso_checksum": "sha256:4f1457c4fe14ce48c9b2324924f33ca4f0470475e6da851b39ccbf98f44e7852", + "iso_url": "https://software-download.microsoft.com/download/pr/17763.737.190906-2324.rs5_release_svc_refresh_SERVER_EVAL_x64FRE_en-us_1.iso", "manually_download_iso_from": "https://www.microsoft.com/en-us/evalcenter/evaluate-windows-server-2022", "restart_timeout": "5m", "virtio_win_iso": "~/virtio-win.iso", "winrm_timeout": "2h", - "vmx_version": "16" + "vmx_version": "14" } } diff --git a/windows_2022_core.json b/windows_2022_core.json new file mode 100644 index 00000000..834ed3a3 --- /dev/null +++ b/windows_2022_core.json @@ -0,0 +1,175 @@ +{ + "builders": [ + { + "accelerator": "kvm", + "boot_wait": "0s", + "communicator": "winrm", + "cpus": 2, + "disk_size": "{{user `disk_size`}}", + "floppy_files": [ + "{{user `autounattend`}}", + "./scripts/disable-screensaver.ps1", + "./scripts/disable-winrm.ps1", + "./scripts/enable-winrm.ps1", + "./scripts/microsoft-updates.bat", + "./scripts/win-updates.ps1" + ], + "headless": true, + "iso_checksum": "{{user `iso_checksum`}}", + "iso_url": "{{user `iso_url`}}", + "memory": "{{user `memory`}}", + "output_directory": "windows_2022_docker-qemu", + "qemuargs": [ + [ + "-drive", + "file=windows_2022-qemu/{{ .Name }},if=virtio,cache=writeback,discard=ignore,format=qcow2,index=1" + ], + [ + "-drive", + "file={{ user `iso_url` }},media=cdrom,index=2" + ], + [ + "-drive", + "file={{ user `virtio_win_iso` }},media=cdrom,index=3" + ] + ], + "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", + "type": "qemu", + "vm_name": "WindowsServer2022Docker", + "winrm_password": "vagrant", + "winrm_timeout": "{{user `winrm_timeout`}}", + "winrm_username": "vagrant" + }, + { + "boot_wait": "0s", + "communicator": "winrm", + "configuration_version": "8.0", + "cpus": 2, + "disk_size": "{{user `disk_size`}}", + "enable_secure_boot": true, + "floppy_files": [ + "{{user `autounattend`}}", + "./scripts/disable-screensaver.ps1", + "./scripts/disable-winrm.ps1", + "./scripts/enable-winrm.ps1", + "./scripts/microsoft-updates.bat", + "./scripts/win-updates.ps1" + ], + "guest_additions_mode": "disable", + "iso_checksum": "{{user `iso_checksum`}}", + "iso_url": "{{user `iso_url`}}", + "memory": "{{user `memory`}}", + "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", + "switch_name": "{{user `hyperv_switchname`}}", + "type": "hyperv-iso", + "vm_name": "WindowsServer2022Core", + "winrm_password": "vagrant", + "winrm_timeout": "{{user `winrm_timeout`}}", + "winrm_username": "vagrant" + }, + { + "boot_wait": "2m", + "communicator": "winrm", + "cpus": 2, + "disk_adapter_type": "lsisas1068", + "disk_size": "{{user `disk_size`}}", + "disk_type_id": "{{user `disk_type_id`}}", + "floppy_files": [ + "{{user `autounattend`}}", + "./scripts/disable-screensaver.ps1", + "./scripts/disable-winrm.ps1", + "./scripts/enable-winrm.ps1", + "./scripts/microsoft-updates.bat", + "./scripts/win-updates.ps1" + ], + "guest_os_type": "windows9srv-64", + "headless": "{{user `headless`}}", + "iso_checksum": "{{user `iso_checksum`}}", + "iso_url": "{{user `iso_url`}}", + "memory": "{{user `memory`}}", + "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", + "type": "vmware-iso", + "vmx_data": { + "RemoteDisplay.vnc.enabled": "false", + "RemoteDisplay.vnc.port": "5900" + }, + "vmx_remove_ethernet_interfaces": true, + "vnc_port_max": 5980, + "vnc_port_min": 5900, + "winrm_password": "vagrant", + "winrm_timeout": "{{user `winrm_timeout`}}", + "winrm_username": "vagrant" + }, + { + "boot_wait": "2m", + "communicator": "winrm", + "cpus": 2, + "disk_size": "{{user `disk_size`}}", + "floppy_files": [ + "{{user `autounattend`}}", + "./scripts/disable-screensaver.ps1", + "./scripts/disable-winrm.ps1", + "./scripts/enable-winrm.ps1", + "./scripts/microsoft-updates.bat", + "./scripts/win-updates.ps1" + ], + "guest_additions_mode": "disable", + "guest_os_type": "Windows2016_64", + "headless": "{{user `headless`}}", + "iso_checksum": "{{user `iso_checksum`}}", + "iso_url": "{{user `iso_url`}}", + "memory": "{{user `memory`}}", + "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", + "type": "virtualbox-iso", + "winrm_password": "vagrant", + "winrm_timeout": "{{user `winrm_timeout`}}", + "winrm_username": "vagrant" + } + ], + "post-processors": [ + { + "keep_input_artifact": false, + "output": "windows_2022_core_{{.Provider}}.box", + "type": "vagrant", + "vagrantfile_template": "vagrantfile-windows_2019_core.template" + } + ], + "provisioners": [ + { + "scripts": [ + "./scripts/enable-rdp.bat" + ], + "type": "windows-shell" + }, + { + "scripts": [ + "./scripts/vm-guest-tools.ps1", + "./scripts/debloat-windows.ps1" + ], + "type": "powershell" + }, + { + "scripts": [ + "./scripts/set-winrm-automatic.bat", + "./scripts/uac-enable.bat", + "./scripts/compile-dotnet-assemblies.bat", + "./scripts/dis-updates.bat", + "./scripts/compact.bat" + ], + "type": "windows-shell" + } + ], + "variables": { + "autounattend": "./answer_files/2022_core/Autounattend.xml", + "disk_size": "61440", + "disk_type_id": "1", + "memory": "2048", + "headless": "false", + "iso_checksum": "sha256:4f1457c4fe14ce48c9b2324924f33ca4f0470475e6da851b39ccbf98f44e7852", + "iso_url": "https://software-download.microsoft.com/download/pr/17763.737.190906-2324.rs5_release_svc_refresh_SERVER_EVAL_x64FRE_en-us_1.iso", + "manually_download_iso_from": "https://www.microsoft.com/en-us/evalcenter/evaluate-windows-server-2022", + "winrm_timeout": "6h", + "virtio_win_iso": "~/virtio-win.iso" + } +} +