Special thanks to Karthikeyan for his LinkedIn post about using this Packer template. His feedback inspired improvements to this template, including the use of variables and conditional statements that make it more flexible and easier to customize.

The Variables File
Create a file named my-config.pkrvars.hcl in the packer-templates directory with your custom values:
# -------------------------
# Packer Variables File
# -------------------------
# This file contains variable values for the apple-tart-tahoe.pkr.hcl template
# Usage: packer build -var-file="my-config.pkrvars.hcl" apple-tart-tahoe.pkr.hcl
# VM Configuration
vm_name = "jamf-test-vm"
ipsw_url = "/path/to/your/macos-tahoe.ipsw"
# Account Configuration
account_userName = "admin"
account_password = "admin"
# MDM Enrollment Configuration
enrollment_type = "profile" # Options: "profile" or "link"
jamf_url = "https://yourinstance.jamfcloud.com"
mdm_invitation_id = "your-invitation-id-here"
# Feature Toggles
enable_passwordless_sudo = "true"
enable_auto_login = "true"
enable_safari_automation = "true"
enable_screenlock_disable = "true"
enable_spotlight_disable = "true"
enable_clipboard_sharing = "false"If you are uploading this to git make sure to add *.pkvars.hcl to your .gitignore file.
So what do these variables mean?
VM Configuration
vm_name- Name of the virtual machine (default: "this_is_the_base_image_name")ipsw_url- Local path or URL to macOS Tahoe IPSW file
Account Configuration
account_userName- macOS account username (default: "admin")account_password- macOS account password (default: "admin")
MDM Enrollment Configuration
enrollment_type- Enrollment method: "profile" or "link" if you want a link to the enrollment page or you want the profile on the desktop after first boot. (default: "profile")jamf_url- Jamf Cloud URL (e.g.,https://instance.jamfcloud.com)mdm_invitation_id- MDM enrollment invitation ID
Feature Toggles
enable_passwordless_sudo- Enable passwordless sudo (default: "true")enable_auto_login- Enable automatic login (default: "true")enable_safari_automation- Enable Safari automation support (default: "true")enable_screenlock_disable- Disable screen lock (default: "true")enable_spotlight_disable- Disable Spotlight indexing (default: "true")enable_clipboard_sharing- Enable clipboard sharing via tart guest agent (default: "false")
β οΈ Note: enable_clipboard_sharing will download xcode command line tools and brew, so this will add 15-25 min to your build process, depending how fast your internet is.Important: Do not edit the
apple-tart-tahoe.pkr.hcl file directly. Instead, create a separate variables file (myvars.pkrvars.hcl) and use that to customize the configuration.How to build - new flag, the same great taste
# Initiate the packer file with required components
packer init apple-tart-tahoe.pkr.hcl
# Validate the template and variable file
packer validate -var-file="my-config.pkrvars.hcl" apple-tart-tahoe.pkr.hcl
# Build with your variables file
packer build -var-file="my-config.pkrvars.hcl" apple-tart-tahoe.pkr.hclNo more spooky π» audio
Within the packer template I added an extra flag for running the VM build process with no audio, after about 15 builds I was sick of hearing macOS assistant talking to me.
run_extra_args = [
"--no-audio"
]Let me know your success
This packer file has been working for me about 80% of the time, sometimes there is a hold up or weird error at the start and it doesnβt finish, keep and eye on the build process and try again if it errors out!