Build macOS test VMs for Jamf Pro and Intune with Packer and Tart

Packer templates that build ready-to-clone macOS virtual machines on Apple silicon with Tart, set up for testing Jamf Pro or Intune enrolment, for macOS 15, 26 and 27.

Testing an MDM workflow properly needs a clean Mac every time. Virtual machines make that cheap. Virtualization_macOS is a set of Packer templates that build macOS virtual machines on Apple silicon, ready for Jamf Pro or Microsoft Intune testing.

The idea comes from MotionBug’s The Cookbook: Baking up your perfect Jamf Pro Test VM, and the Setup Assistant keystrokes are adapted from the cirruslabs/macos-image-templates project.

The two tools

  • Packer builds machine images from a template file, the same way every time.
  • Tart builds, runs and manages macOS and Linux virtual machines on Apple silicon, using Apple’s Virtualization framework.

Templates

File macOS How setup is done
macos15.6.1_sequoia-tart.pkr.hcl 15.6.1 (24G90) Setup Assistant driven by boot_command keystrokes
macos26.2_tahoe-tart.pkr.hcl 26.2 (25C56) Setup Assistant driven by boot_command keystrokes
macos27.2_golden-gate-tart.pkr.hcl 27.2 (26B123) Tart’s --provisioning-opts, with no Setup Assistant

The macOS 27 template needs Tart 2.33.0 or later, which is the release that added --provisioning-opts, and a host running macOS 27 or later. An older macOS 27.0 template is kept in previous_versions/.

What you get in the finished VM

  • MDM of your choice. One variable, mdm_vendor, decides it. jamf writes a Jamf Pro enrolment profile to the Desktop with your invitation ID and Jamf URL. intune downloads and installs the Company Portal. Anything else, such as none, skips MDM.
  • A local account with a username and password you set, logged in automatically.
  • Passwordless sudo, so the rest of the build and your own automation can run privileged commands.
  • Gatekeeper disabled, so unsigned test builds run.
  • Screen Sharing and Remote Login (SSH) enabled.
  • Spotlight indexing off, screen lock off and sleep prevented, which suits unattended lab use.
  • Safari opened once with safaridriver enabled, for browser automation.
  • Clipboard sharing between host and guest, through the Tart Guest Agent.
  • A random VM-TART-XXXX computer name on every build.
  • The Recovery partition kept, so softwareupdate still works inside the VM.

Most of these are toggles, and every credential, URL and toggle is a Packer variable.

Building a VM

You need an Apple silicon Mac, Homebrew, Packer 1.16 or later and Tart.

brew install openai/tools/tart
brew tap hashicorp/tap
brew install hashicorp/tap/packer

If Jamf Pro is your MDM, create an enrolment invitation in Jamf Pro and copy the ID from the end of its URL (.../enroll?invitation=XXXXXXXXXXXX) into the mdm_invitation_id variable.

Then build:

packer init macos26.2_tahoe-tart.pkr.hcl
packer validate macos26.2_tahoe-tart.pkr.hcl
packer build macos26.2_tahoe-tart.pkr.hcl

Variables can be overridden at build time:

packer build -var="account_userName=macadmin" -var="account_password=supersecurepass" macos26.2_tahoe-tart.pkr.hcl

The build needs no interaction. Once macOS is installed, Tart starts the VM and the automated setup runs. Do not click or type in the VM window until it finishes.

Using the image

Clone the image for each test, so the original stays clean:

tart clone your-image prod-test-vm
tart set prod-test-vm --display-refit --random-serial --random-mac
tart run prod-test-vm

--random-serial and --random-mac give each clone its own identity, which avoids collisions in your MDM. Other useful options are --dir=SharedFolder:~ to share a folder from the host and --recovery to boot into recovery mode. tart help run lists the rest.

Get it

The templates and full variable reference are in the Virtualization_macOS repository.