Giter VIP home page Giter VIP logo

packer-macos-11's Introduction

packer-macOS-11

This a packer template for macOS 11 or 12 built on VMware fusion 12. It's created using the newer packer hcl2 syntax. These templates only support x86 platform as Apple has introduced breaking changes with the new Applesilicon platform.

Discussion thread for usage questions

See this hashicorp discuss thread for general usage questions & answers.

--> building-macos-12-x-vms-with-packer-and-fusion <--

Key capabilities

  • scripts/macosiso.sh creates a macOS installer via mist
  • Using voiceover and boot commands to open terminal.app !!
  • Downloading .pkg and script payloads to the recovery environment
  • Running the payload scripts that handle the install process
  • packer user creation and autologin
  • Clearing setup screens
  • Enable remotelogin system settings
  • Install Command Line Developer tools
  • Approve VMware tools Kernel Extensions

Building macOS 11+ with this packer template

  • Minimum packer version is 1.7.x
  • VMware Fusion 12.0 or greater

Prerequisite installer bits

The current version of this project now uses mist to create macOS x86 installer iso files. Grab a copy from https://github.com/ninxsoft/Mist and make sure it's available on your path before the next steps.

For generating the boot iso and matching shasum run the macosiso.sh script providing the OS major version you want to create. Generating the iso directly with mist also works. You will just need to povide packer the sha256 via input variable.

scripts/macosiso.sh 12.2

With the customize build I'm installing Xcode command line tools 13. Grab both the latest Xcode Command Line tools installer dmg from developer.apple.com. Toss them into the install_bits directory.

Here is what your install_bits directory should look like to successfully build the full image:

install_bits/
├── Command_Line_Tools_for_Xcode_13.2.dmg
├── macOS_12.2.1_21D62.iso
└── macOS_12.2.1_21D62.shasum

NOTE: Filenames will change as newer versions are released

Named builds

This template has two named builds base and customize. The idea here is to split the lengthy process of macOS installation (baking the image) from the customization (frying the image). The base build does the os install with the vmware-iso builder and customize takes the output VM from that and customizes it. Re-running the customization quickly gets allows for quicker testing of that phase.

Building the base image

Builds just the OS including VMware tools

packer build -force -only=base.vmware-iso.macOS macOS.pkr.hcl

Building the customize image

Useful for testing customizations without waiting for the whole OS to install.

packer build -force -only=customize.vmware-vmx.macOS macOS.pkr.hcl

Input variables

This template uses input variables for a bunch of customizable values. Run packer inspect to see the defaults and what can be changed. See the docs for more options like creating a local variables file for customization https://www.packer.io/docs/templates/hcl_templates/variables .

packer inspect macOS_11.pkr.hcl

Varibles file

The recommended way to tweak settings in the template is by creating a packer variables file. Any of the Input variables can be adjusted this way. Specify a var file with the build commands to change the defaults.

packer build -force -only=customize.vmware-vmx.macOS -var-file bigsur.pkrvars.hcl macOS.pkr.hcl

Here is an example var file named bigsur.pkrvars.hcl

boot_key_interval_iso = "20ms"
boot_wait_iso = "150s"
boot_keygroup_interval_iso = "150ms"
seeding_program = "none" # PublicSeed  CustomerSeed DeveloperSeed none
xcode_cli = "install_bits/Command_Line_Tools_for_Xcode_13.dmg"
iso_filename = "install_bits/macOS_1160_installer.iso"
iso_file_checksum = "file:install_bits/macOS_1160_installer.shasum"
ram_gb = "8"
cpu_count = "2"
tools_path = "install_bits/darwin.iso"
macos_version = "11.6"

Adjust resources

If you need to adjust the cpu and RAM requirements to match your available resources.

cpu_count="2"
ram_gb="6"

Adjust timing

The process for starting the installer is very dependant on timing, unfortunately. If you run into unexpected results when the installer is starting up you may need to adjust the timing to match your system. Each release of the OS and specific hardware running the build can change the optimal timing. When in doubt add some time to these values to see if that fixes the issue.

boot_key_interval_iso="400ms"
boot_wait_iso="400s"
boot_keygroup_interval_iso="5s"

Customize computer serial and model

Variables have been added to customize board id, hardware model & serial number. This can be handy for testing DEP workflows.

board_id="Mac-27AD2F918AE68F61"
serial_number="M00000000001" 
hw_model="MacPro7,1"

Install pre-release software updates

Apple has been seeding pre-release builds as software update only more often. To configure the installation of these pre-release versions pass the seed value you want to configure on the OS.

seeding_program="DeveloperSeed" 

Possible values are

PublicSeed
CustomerSeed
DeveloperSeed
none

Customize username, password, hostname & ssh key

Changing the username/pass in the http/packer.pkg has been deprecated. The current version supports passing user details as packer variables. Configuring the following vars will remove the packer user and add a new one with the provided variables. Setting a hostname and ssh key simplifies connecting to the VM once the build is completed.

remove_packer_user = true
new_username = "claris"
new_password = "m00000f!"
new_ssh_key = "ssh-ed25519..."
new_hostname = "mac123vm"

Apple GPU support

If the host system is running macOS 11.x or later enabling the virtualized GPU provides a dramatic speedup of the GUI. This version of the template uses a post-processor to add the needed vmx config if the host OS is macOS 11.x+. This capability is a beta VMware Fusion feature and has some known issues.

Use downloaded version of VMware tools .iso

Sometimes newer versions of VMware tools are available from vmware.com . Check https://vmware.com/go/tools . If you want to use an iso besides the one included with VMware fusion then update the variable tools_path

tools_path="install_bits/darwin.iso"

Add your own config script

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.

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

Simple wrapper script to run both base & customize builds

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.

./build monterey.pkrvars.hcl

packer-macos-11's People

Contributors

beatrupp avatar damonbreeden avatar timsutton avatar trodemaster avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

packer-macos-11's Issues

How is packer.pkg made?

Could you provide steps for someone to recreate packer.pkg and setupsshlogin.pkg from scratch? I would like to be able to recreate as much of this as possible from scratch.

How to make compatible with vagrant

Interested to use this as a means to build a vagrant box for Macos Monterey. Mainly due to macinbox box now failing due to changes in macOS installer pieces since Big Sur.

Tried to build with the following observations:

  • the buildprerequs.sh appears to pull down pre-release versions by default. I'm assume the change to remove DeveoperSeed is all that's required
  • I've tried changing the username/password in macos.pkg.hcl but this appear to be ignored. The documentation seems to suggest a Python utility to recreate the installation packages and scripts but this appears missing from the repo (makepkgs.sh also harcode the file path for the script to include ~/code/... ). Is this available somewhere else?
  • Packer appears to hang waiting on SSH to be exposed. Can't find any logs or other means to diagnose why this might be happening. Within guest Remote Login is enabled and a manually attempt to ssh port is successful. Debug option for packer doesn't show any further detalls.

Thoughts appreciated

Booting in Boot Manager

I tried multiple way but when my VM start it's always on the boot manager...
it seams the ISO file cannot been use to boot... does I forgetting a step somewhere?

11.3 not completing install from full .iso

As of Beta 5 installs of 11.3 are failing to configure the needed user and ssh configs. This results in the build stalling out at the initial setup window. I'm investigating changes to the packages or another method for running shell scripts directly in the correct context to configure the system settings.

Workaround if you need a 11.3 VM is to install with 11.2.2 .iso and upgrade to 11.3. See readme for info on update configuration..

Force Network adapter type

Hi,
thanks for this tool... one option I didn't found:
Is there a way to force the Force Network adapter Type.
I would like to be in "Ethernet" instead of the "Share with my Mac" default mode...

what is the purpose of bootstrap.pkg

hi, genuinely asking what the purpose of bootstrap.pkg is
it gets built from the directory packages/bootstrap which is full of empty files
i don't see bootstrap.pkg (only bootstrap.sh) referred to anywhere in the hcl or anywhere else
seems that the users are created via packer.pkg, and ssh is enabled via setupsshlogin.pkg, and i can't see a need for anything else to bootstrap the image

thanks for your work

Clarifications

Hello there !

I've been following this project since quite sometimes, and are actually working on/with it for my job.
I got a question about it.

  • How have you created the packer.dmg and the ssh-install PKG? (I tried to reproduce both and I still can't skip the Installation process)
  • Why does the Feedback assistant keep poking up even if it's no beta ?

Anyway thanks for work!

Is libvirt provider possible

Greetings,

I wonder if would be possible to change the provider type from vmware to libvirt.

I'm not used to create boxes, so I'll search for it more from now on.

Thanks.

more steps are needed to change the username/password applied at login

it would be appreciated if you could share your workflow to generate the setupsshlogin.pkg file

specifically this line
echo 'packer ALL=(ALL) NOPASSWD: ALL' >/private/etc/sudoers.d/packer

doesn't get updated with a new username when that changes (in packages/setupsshlogin/build/setupsshlogin.pkg)

a different way to make sure that sudoers get sudo access is to add this line

%sudo ALL=NOPASSWD: ALL
to /etc/sudoers or smth inside of sudoers.d

Support virtualbox

I'm using Vagrant + VirtualBox, while this repo uses VMware fusion. Is it easy to switch from fusion to virtualbox with most the code in this repo? Thanks a lot.

VMware Tools Installation Failed

Hello!
I noticed that during a complete install that vmware-tools fails due to SIP/kext.

The error is System Extension Blocked. I know that this is addressed at the following line in your setupsshlogin.sh script, but it doesn't seem to persist.

I just wanted to let you know, great project otherwise!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.