This is a Packer Builder for building images that work with Veertu Anka, a macOS virtualization tool.
Note that this builder does not manage images. Once it creates an image, it is up to you to use it or delete it.
Packer Version | Builder for Anka Version |
---|---|
Up to 1.4.5 | 1.1.0 |
1.5.x and above | 1.2.0 |
- Install Packer
- Install Veertu Anka
- Download the latest release for your host environment
- Unzip the plugin binaries to a location where Packer will detect them at run-time, such as any of the following:
- The directory where the packer binary is.
- The
~/.packer.d/plugins
directory. - The current working directory.
- Change to a directory where you have packer templates, and run as usual.
The most basic json file you can build from is:
{
"builders": [
{
"installer_app": "/Applications/Install macOS Big Sur.app",
"type": "veertu-anka"
}
]
}
This will create a base VM template using the .app
you specified in installer_app
with a name like anka-packer-base-{macOSVersion}
. Once the base VM template is created, it will create a clone from it (that shares the underlying layers from the base VM template, minimizing the amount of disk space used).
When using
installer_app
, you can modify the base VM default resource values withdisk_size
,ram_size
, andcpu_count
. Otherwise, defaults will be used (see "Configuration" section).
You can also skip the creation of the base VM template and use an existing VM template (10.15.6
):
{
"provisioners": [
{
"type": "shell",
"inline": [
"sleep 5",
"echo hello world",
"echo llamas rock"
]
}
],
"builders": [{
"type": "veertu-anka",
"cpu_count": 8,
"ram_size": "10G",
"disk_size": "150G",
"source_vm_name": "10.15.6"
}]
}
Or, create a variable inside for the source_vm_name
and then run: packer build -var 'source_vm_name=10.15.6' examples/macos-catalina-existing.json
.
The
installer_app
is ignored if you've specifiedsource_vm_name
and it does not exist already
This will clone 10.15.6
to a new VM and, if there are differences from the base VM, modify CPU, RAM, and DISK.
Check out the examples directory to see how port-forwarding and other options are used.
If you'd like for the base packer VM to be in a stopped state on creation, you can use
ANKA_CREATE_SUSPEND=0 packer build . . .
type
(required) (string)
Must be veertu-anka
.
installer_app
(optional) (string)
The path to a macOS installer. This must be provided if source_vm_name
isn't provided. This process takes about 20 minutes. The resulting VM template name will be anka-packer-base-{macOSVersion}
.
disk_size
(optional) (string)
The size in "[0-9]+G" format, defaults to 25G
.
We will automatically resize the internal disk for you by executing:
diskutil apfs resizeContainer disk1 0
ram_size
(optional) (string)
The size in "[0-9]+G" format, defaults to 2G
.
cpu_count
(optional) (integer)
The number of CPU cores, defaults to 2
.
source_vm_name
(optional) (string)
The VM to clone for provisioning, either stopped or suspended.
vm_name
(optional) (string)
The name for the VM that is created. One is generated if not provided (anka-packer-{10RandomCharacters}
).
boot_delay
(optional) (string)
The time to wait before running packer provisioner commands, defaults to 10s
.
hw_uuid
(optional) (string)
The Hardware UUID you wish to set (usually generated with uuidgen
).
port_forwarding_rules
(optional)
If port forwarding rules are already set and you want to not have them fail the packer build, use
packer build --force
"builders": [{
"type": "veertu-anka",
"cpu_count": 8,
"ram_size": "10G",
"source_vm_name": "anka-packer-base-10.15.7",
"port_forwarding_rules": [
{
"port_forwarding_guest_port": 80,
"port_forwarding_host_port": 12345,
"port_forwarding_rule_name": "website"
},
{
"port_forwarding_guest_port": 8080
}
]
}]
update_addons
(optional) (boolean)
Whether or not to update addons when starting the cloned VM.
This will force stop the VM, causing your suspended state to be lost.
You will need a recent golang installed and setup. See go.mod
for which version is expected.
make packer-test
If you've already built a base macOS VM, you can use:
make packer-test-existing SOURCE_VM_NAME=11.1.0
-or-
make build-and-install && PACKER_LOG=1 packer build examples/macos-catalina-existing.json