Packer Template for macOS 11+ on VMware Fusion

Share on:

With the October 2021 update to this macOS packer template, it now supports 11.0.1 through 12.0 versions. Changing the username and password used to build the images is more straightforward, and quite a few new options have been parameterized.

One change I have been chasing for a while is approving the VMware tools kernel extension. This is a new requirement for macOS 11 and later. Apple encourages organizations to use MDM for that task. The approach I’m using with the customize part of the build is to boot the VM with SIP disabled and use GUI scripting to approve the kext.

The build process has changed slightly with names of the builds simplified and removal of the full build, which did all of the steps in one go. If you want to test DEP likely, you will only use the base build and manage the rest of the config with your MDM tooling. Details included in the README.md

Additionally, a new variable bootstrapper_script has been added. Using this is an easy way to add a few more commands to the build or pull down a script to extend the build process to your needs. I use it to install golang, macports and dotfiles via a script in another repo. See below for an example.

1bootstrapper_script = [ "curl https://@raw.githubusercontent.com/gitusers/myconfig/main/bootstrap.sh -o bootstrap.sh",
2"chmod +x bootstrap.sh",
3"./bootstrap.sh" ]

Head to the github page directly https://github.com/trodemaster/packer-macOS-11 A discussion thread has been created in the packer comunity https://discuss.hashicorp.com/t/building-macos-12-x-vms-with-packer-and-fusion/31069

This repo uses submodules so make sure to clone them down as well.

1git clone --recurse-submodules https://github.com/trodemaster/packer-macOS-11.git

Included is a simple wrapper script used to build the base image and then the customized image. It takes a single parameter that is a packer variable file. This simplifies the build process if you maintain multiple versions of macOS VMs.

1./buildworld.sh monterey.pkrvars.hcl

The video below is an accelerated time screen recording of the ~50-minute build process. You can see voiceover and boot command keys getting terminal.app open and download the payloads to start the build.