This repository provides automated build tools for creating Vagrant boxes from multiple Linux distributions, including Amazon Linux, Rocky Linux, and Debian.
It supports building boxes from various source formats using Packer, including pre-built KVM/qcow2 images as well as traditional ISOs.
Currently designed for macOS hosts and VMware providers, but adding support for Linux hosts (including WSL) and additional providers should be straightforward.
Pre-built boxes are available from Vagrant Cloud: https://portal.cloud.hashicorp.com/vagrant/discover/defanator
- Amazon Linux 2 - amazonlinux-2/
- Amazon Linux 2023 - amazonlinux-2023/
- Rocky Linux 8 - rockylinux-8/
- Rocky Linux 9 - rockylinux-9/
- Rocky Linux 10 - rockylinux-10/
- Fedora Cloud 43 - fedora-cloud-43/
- Debian 12 "bookworm" - debian-12
- Debian 13 "trixie" - debian-13
- Ubuntu 22.04 "jammy" - ubuntu-2204
- Ubuntu 24.04 "noble" - ubuntu-2404
Each image supports:
- x86_64 (amd64) architecture
- aarch64 (arm64) architecture with EFI firmware
- Packer (>= 1.14.0)
- VMware Fusion
qemu-img(for image format conversion)curlandsha256sum- GNU Make
# Install Packer
brew install packer
# Install QEMU for qemu-img
brew install qemu
# Ensure VMware Fusion is installed
# Download from: https://www.vmware.com/products/fusion.html# Show available targets
make
# Build latest version of a specific box (e.g., Amazon Linux 2)
make box-amazonlinux-2
# Build latest Amazon Linux 2023 box
make box-amazonlinux-2023For more granular control, you can run individual steps:
# Show help for a specific image
make help-amazonlinux-2
# Fetch the original KVM image
make fetch-amazonlinux-2
# Convert KVM image to VMDK format
make convert-amazonlinux-2
# Build the box using Packer
make build-amazonlinux-2
# Package the final Vagrant box
make box-amazonlinux-2# Show current environment configuration
make show-env
# Show environment for a specific image (including versions etc)
make show-env-amazonlinux-2The build process consists of several stages:
- Fetch: Downloads latest official image (could be installation/live ISO or prebuilt KVM/qcow2 disk image)
- Convert: Converts the qcow2 image to VMDK format for VMware compatibility (optional stage)
- Prepare: Creates source VM configuration with extra data if required (like e.g. cloud-init seed ISO for Amazon Linux)
- Build: Uses Packer to customize the VM and install necessary components
- Package: Creates the final Vagrant box file
The resulting Vagrant boxes include:
- Pre-configured
vagrantuser with sudo privileges - VMware Tools installed
- SSH key authentication configured
- Cleaned up logs and temporary files for smaller box size
- Default user:
vagrantwith passwordvagrant - SSH access: Password and key-based authentication enabled
- Provider: VMware Desktop (Fusion/Workstation)
- Architecture: Automatically detected (amd64 or arm64)
Built boxes are placed in:
work/
├── amazonlinux-2/
│ └── output/
│ ├── amazonlinux-2*.box # Vagrant box file
│ ├── metadata.json # Box metadata
│ └── SHA256SUMS # Checksums
└── amazonlinux-2023/
└── output/
├── amazonlinux-2023*.box # Vagrant box file
├── metadata.json # Box metadata
└── SHA256SUMS # Checksums
In the corresponding output directory, run:
% vagrant box add metadata.json
==> box: Loading metadata for box 'metadata.json'
box: URL: file:///Users/xxxx/git/vagrant-boxes/work/amazonlinux-2023/output/metadata.json
==> box: Adding box 'defanator/amazonlinux-2023' (v2023.9.20251117.1-1) for provider: vmware_desktop (arm64)
box: Downloading: amazonlinux-2023-v2023.9.20251117.1-1-arm64.box
==> box: Successfully added box 'defanator/amazonlinux-2023' (v2023.9.20251117.1-1) for 'vmware_desktop (arm64)'!
# Clean all build artifacts
make clean
# Clean specific VM artifacts while leaving the KVM image (useful for debugging to avoid extra downloads)
make -C amazonlinux-2 preclean- Create a new directory following the existing pattern
- Copy and modify Makefile and template files
- Update image URLs and version detection logic
- Test the build process
Contributions are welcome! Please feel free to submit pull requests or open issues for bugs and feature requests.