This project aims to expose a simple, configurable and tailored packer template for building Vagrant base boxes for Hyper-V (and VirtualBox).
There are many templates, and existing Vagrant boxes available so why bother re-inventing the wheel? Well in my experience all the projects I looked at either tried to do too much or had Hyper-V as a second class citizen. Further more if I wanted to configure the build boxes I had to fully understand the project and where it's configuration is hidden.
So the goals for this project are simple:
- Hyper-V must be the main supported builder.
- Limit the number of supported OS's to enable a clean project without a large amount of if/else style configuration.
- Make anything that a user might want to modify configurable within a build process without the need to resort to modifing templates or internal OS installation files etc.
- Packer
- PowerShell - for our build scripts
- Hyper-V
- Windows 10 build 17063 or greater is required for enhanced mode support. See https://blogs.technet.microsoft.com/virtualization/2018/02/28/sneak-peek-taking-a-spin-with-enhanced-linux-vms/
- Intel CPU with VT-X - needed for nested virtualization. If you do not have a supported CPU pass
-disableVirtualization
tobuild-windows.ps1
- Packer
- Virtualbox
The following box OS's are supported:
- Ubuntu LTS x64
- Windows 11 x64
- Arch Linus x64
- VyOS x64
A PowerShell build script has been created to handle build and configuration for the vagrant boxes.
From a PowerShell command prompt in the project root:
get-help .\build.ps1 -detailed
This will show all the configuration options available.
A default build can be run like this:
.\build.ps1
This requires a modification to the hyper-v packer plugin that hasn't been merged yet. To make this work you need to checkout
the enable-tpm
branch from https://github.com/camjjack/packer-plugin-hyperv and use that instead of the default plugin. Then uncomment the following line in windows.pkr.hcl
:
//enable_tpm = true
A PowerShell build script has been created to handle build and configuration for the vagrant boxes.
From a PowerShell command prompt in the project root:
get-help .\build-windows.ps1 -detailed
This will show all the configuration options available.
A default build can be run like this:
.\build-windows.ps1
A bash script has been created to handle build and configuration for the vagrant boxes.
./build.sh -h
This will show all the configuration options available.
A default build can be run like this:
./build.sh
A bash script has been created to handle build and configuration for the vagrant boxes.
./build-windows.sh -h
This will show all the configuration options available.
A default build can be run like this:
./build-windows.sh
The build script has a -debug option which sets some packer options to aid in debugging faulty templates. Start with the generated log file: packer-log.txt