-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2578d49
Showing
18 changed files
with
1,193 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
variables.auto.pkrvars.hcl | ||
packer_cache/ |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
# packer-windows-vsphere-iso | ||
|
||
This repo builds automatically Windows VM templates (Windows 11, Windows 10, Server 2019, Server 2022) for VMware vSphere environment using Hashicorp's Packer using freely available Windows Eval ISOs. | ||
|
||
With this repo VM templates for the following Windows operating systems can by built. | ||
|
||
- Windows 10 Enterprise | ||
- Windows 11 Enterprise | ||
- Windows Server 2019 Datacenter | ||
- Windows Server 2022 Datacenter | ||
|
||
You don't need do pre-download any Windows ISO. | ||
Windows ISO files gets download automatically from public sources. | ||
|
||
## How to use this repo | ||
|
||
### Pre-requesites | ||
|
||
Download or `git clone https://github.com/andif888/packer-windows-vsphere-iso.git` this repo and make sure you have [Packer](https://www.packer.io/downloads) Version 1.7.1 or later installed. | ||
|
||
### Step 1: Adjust variables | ||
|
||
Rename the file [variables.auto.pkrvars.hcl.sample](variables.auto.pkrvars.hcl.sample) to `variables.auto.pkrvars.hcl` and adjust the variables for your VMware vSphere environment. Some documentation on each variable is inside the sample file. | ||
```bash | ||
mv variables.auto.pkrvars.hcl.sample variables.auto.pkrvars.hcl | ||
nano variables.auto.pkrvars.hcl | ||
``` | ||
|
||
### Step 2: Init Packer | ||
|
||
Init Packer by using the following command | ||
```bash | ||
packer init . | ||
``` | ||
|
||
### Step 3: Build a VM Template | ||
|
||
To build a VM template run one of the provided `build`-scripts. | ||
For example to build a Windows 11 template run: | ||
```bash | ||
./build-11.sh | ||
``` | ||
If your are on a Windows machine then use the `build-*.ps1` files. | ||
|
||
|
||
### Optional: Windows Template default credentials | ||
|
||
the default credentials after a successful build are | ||
Username: `vagrant` | ||
Password: `vagrant` | ||
|
||
If you would like to change the default ćredentials before a packer build, then you need to edit the following files: | ||
|
||
- **variables.auto.pkrvars.hcl** | ||
- **autounattend.xml** | ||
|
||
### Optional: Install Windows Updates during build | ||
|
||
You can optionally install Windows Updates during the build operation. | ||
If you would like this feature then you need to edit the [windows.pkr.hcl](windows.pkr.hcl) file before the build operation. Please uncomment the following sections: | ||
|
||
Line: 11-14 | ||
```hcl | ||
windows-update = { | ||
version = "0.14.0" | ||
source = "github.com/rgl/windows-update" | ||
} | ||
``` | ||
Line: 163-170 | ||
```hcl | ||
provisioner "windows-update" { | ||
search_criteria = "IsInstalled=0" | ||
filters = [ | ||
"exclude:$_.Title -like '*Preview*'", | ||
"include:$true", | ||
] | ||
update_limit = 25 | ||
} | ||
``` | ||
After that you have to run `packer init .` again to automatically download the Packer Windows-Update Plugin. | ||
```bash | ||
packer init . | ||
``` | ||
|
||
## Window 11 - BypassTPMCheck | ||
|
||
Normaly Windows 11 requires a TPM to get installed successfully. | ||
VMware vSphere provides a virtualized TPM since Version 6.7 and later. | ||
In this repo we do not configure a vTPM in vSphere for Windows 11. | ||
Instead we use a easy workaround to turn off TPM check during Windows 11 installation. | ||
In the [autounattend.xml](answer_files/11/en/autoanattend.xml) we add some registrykeys which effectively enable the **BypassTPMCheck** in Windows 11. | ||
|
||
```xml | ||
<RunSynchronousCommand wcm:action="add"> | ||
<Order>1</Order> | ||
<Description>BypassTPMCheck</Description> | ||
<Path>cmd /c reg add "HKLM\SYSTEM\Setup\LabConfig" /v "BypassTPMCheck" /t REG_DWORD /d 1</Path> | ||
</RunSynchronousCommand> | ||
<RunSynchronousCommand wcm:action="add"> | ||
<Order>2</Order> | ||
<Description>BypassSecureBootCheck</Description> | ||
<Path>cmd /c reg add "HKLM\SYSTEM\Setup\LabConfig" /v "BypassSecureBootCheck" /t REG_DWORD /d 1</Path> | ||
</RunSynchronousCommand> | ||
<RunSynchronousCommand wcm:action="add"> | ||
<Order>3</Order> | ||
<Description>BypassRAMCheck</Description> | ||
<Path>cmd /c reg add "HKLM\SYSTEM\Setup\LabConfig" /v "BypassRAMCheck" /t REG_DWORD /d 1</Path> | ||
</RunSynchronousCommand> | ||
``` |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,200 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<unattend xmlns="urn:schemas-microsoft-com:unattend"> | ||
<settings pass="windowsPE"> | ||
<component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<SetupUILanguage> | ||
<UILanguage>en-US</UILanguage> | ||
</SetupUILanguage> | ||
<InputLocale>0409:00000409</InputLocale> | ||
<SystemLocale>en-US</SystemLocale> | ||
<UILanguage>en-US</UILanguage> | ||
<UILanguageFallback>en-US</UILanguageFallback> | ||
<UserLocale>en-US</UserLocale> | ||
</component> | ||
<component name="Microsoft-Windows-PnpCustomizationsWinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<DriverPaths> | ||
<PathAndCredentials wcm:action="add" wcm:keyValue="A"> | ||
<!-- pvscsi-Windows8.flp --> | ||
<Path>B:\</Path> | ||
</PathAndCredentials> | ||
</DriverPaths> | ||
</component> | ||
<component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<DiskConfiguration> | ||
<Disk wcm:action="add"> | ||
<CreatePartitions> | ||
<CreatePartition wcm:action="add"> | ||
<Size>250</Size> | ||
<Order>1</Order> | ||
<Type>Primary</Type> | ||
</CreatePartition> | ||
<CreatePartition wcm:action="add"> | ||
<Order>2</Order> | ||
<Extend>true</Extend> | ||
<Type>Primary</Type> | ||
</CreatePartition> | ||
</CreatePartitions> | ||
<ModifyPartitions> | ||
<ModifyPartition wcm:action="add"> | ||
<Order>1</Order> | ||
<PartitionID>1</PartitionID> | ||
<Format>NTFS</Format> | ||
<Label>Boot</Label> | ||
<Active>true</Active> | ||
</ModifyPartition> | ||
<ModifyPartition wcm:action="add"> | ||
<Order>2</Order> | ||
<PartitionID>2</PartitionID> | ||
<Format>NTFS</Format> | ||
<Label>System</Label> | ||
</ModifyPartition> | ||
</ModifyPartitions> | ||
<DiskID>0</DiskID> | ||
<WillWipeDisk>true</WillWipeDisk> | ||
</Disk> | ||
</DiskConfiguration> | ||
<ImageInstall> | ||
<OSImage> | ||
<InstallFrom> | ||
<MetaData wcm:action="add"> | ||
<Key>/IMAGE/INDEX</Key> | ||
<Value>1</Value> | ||
</MetaData> | ||
</InstallFrom> | ||
<InstallTo> | ||
<DiskID>0</DiskID> | ||
<PartitionID>2</PartitionID> | ||
</InstallTo> | ||
<WillShowUI>OnError</WillShowUI> | ||
<InstallToAvailablePartition>false</InstallToAvailablePartition> | ||
</OSImage> | ||
</ImageInstall> | ||
<UserData> | ||
<AcceptEula>true</AcceptEula> | ||
<!-- | ||
<ProductKey> | ||
<WillShowUI>Never</WillShowUI> | ||
<Key>XGVPP-NMH47-7TTHJ-W3FW7-8HV2C</Key> | ||
</ProductKey> | ||
--> | ||
</UserData> | ||
</component> | ||
</settings> | ||
<settings pass="offlineServicing"> | ||
<component name="Microsoft-Windows-LUA-Settings" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<!-- Disable user account control --> | ||
<EnableLUA>false</EnableLUA> | ||
</component> | ||
</settings> | ||
<settings pass="specialize"> | ||
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<TimeZone>Central Standard Time</TimeZone> | ||
</component> | ||
<component name="Microsoft-Windows-Deployment" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<RunSynchronous> | ||
<RunSynchronousCommand wcm:action="add"> | ||
<WillReboot>Always</WillReboot> | ||
<Path>a:\vmtools.cmd</Path> | ||
<Order>1</Order> | ||
</RunSynchronousCommand> | ||
</RunSynchronous> | ||
</component> | ||
<component name="Microsoft-Windows-TerminalServices-LocalSessionManager" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<fDenyTSConnections>false</fDenyTSConnections> | ||
</component> | ||
<component name="Networking-MPSSVC-Svc" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<FirewallGroups> | ||
<FirewallGroup wcm:action="add" wcm:keyValue="RemoteDesktop"> | ||
<Active>true</Active> | ||
<Group>Remote Desktop</Group> | ||
<Profile>all</Profile> | ||
</FirewallGroup> | ||
</FirewallGroups> | ||
</component> | ||
<component name="Microsoft-Windows-TerminalServices-RDP-WinStationExtensions" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<SecurityLayer>2</SecurityLayer> | ||
<UserAuthentication>1</UserAuthentication> | ||
</component> | ||
<component name="Microsoft-Windows-OutOfBoxExperience" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<DoNotOpenInitialConfigurationTasksAtLogon>true</DoNotOpenInitialConfigurationTasksAtLogon> | ||
</component> | ||
<component name="Microsoft-Windows-Security-SPP-UX" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<SkipAutoActivation>true</SkipAutoActivation> | ||
</component> | ||
</settings> | ||
<settings pass="oobeSystem"> | ||
<component name="Microsoft-Windows-International-Core" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<InputLocale>en-US</InputLocale> | ||
<SystemLocale>en-US</SystemLocale> | ||
<UILanguage>en-US</UILanguage> | ||
<UserLocale>en-US</UserLocale> | ||
</component> | ||
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<AutoLogon> | ||
<Password> | ||
<Value>vagrant</Value> | ||
<PlainText>true</PlainText> | ||
</Password> | ||
<LogonCount>2</LogonCount> | ||
<Username>vagrant</Username> | ||
<Enabled>true</Enabled> | ||
</AutoLogon> | ||
<FirstLogonCommands> | ||
<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>1</Order> | ||
<Description>Show file extensions in Explorer</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>2</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>3</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>4</Order> | ||
<Description>Disable password expiration for vagrant user</Description> | ||
</SynchronousCommand> | ||
<SynchronousCommand wcm:action="add"> | ||
<Order>5</Order> | ||
<CommandLine>powershell -ExecutionPolicy Bypass -File a:\setup.ps1</CommandLine> | ||
<Description>Enable WinRM service</Description> | ||
<RequiresUserInput>true</RequiresUserInput> | ||
</SynchronousCommand> | ||
</FirstLogonCommands> | ||
<ShowWindowsLive>false</ShowWindowsLive> | ||
<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> | ||
</component> | ||
</settings> | ||
</unattend> |
Oops, something went wrong.