Skip to content

Instantly share code, notes, and snippets.

@fnichol
Last active December 30, 2019 08:23
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fnichol/6a8af536ccdeea03d235b8edc432ad14 to your computer and use it in GitHub Desktop.
Save fnichol/6a8af536ccdeea03d235b8edc432ad14 to your computer and use it in GitHub Desktop.
Building a Mac OS X Vagrant box with Bento

The Mac/Bento templates use Tim Sutton's amazingly awesome os-vm-templates project to prepare a .dmg that can perform an unattended install of Mac OS X 10.7 through to 10.11. You'll need a copy of the Mac OS X .app on locally on disk, so we'll assume that it's installed under /Applications from the App Store.

Clone the os-vm-templates project and run the prepare_iso.sh program to produce the disk image.

git clone https://github.com/timsutton/osx-vm-templates.git
cd osx-vm-templates
sudo prepare_iso/prepare_iso.sh "/Applications/Install OS X El Capitan.app" out

Make note of the md5 hash and output filename and path. We'll need this for the next step.

Now we'll clone the Bento repo and write out a small JSON file that the underlying template will use to set required variables, namely the iso_checksum and iso_url. In this example we're using VMware Fusion on a Mac workstation.

git clone https://github.com/chef/bento.git
cd bento
cat <<EOF > macosx-10.11.variables.json
{
  "iso_checksum": "40acb2285174690e5e9c04b8b4e03179",
  "iso_url": "file:///path/to/OSX_InstallESD_10.11.5_15F34.dmg"
}
EOF
./bin/bento build -o vmware-iso macosx-10.11

If everything goes to plan (say an hour or so later), you should have a ./builds/ directory containing a JSON metadata file and Vagrant box image ready to be imported. Here's an example of a box that I recently built:

> ls -l ./builds
./builds/macosx-10.10-2.1.20160526163052.git.6fdd2e497a8fc2999c4195bab9f3f5127dd70d6a.metadata.json
./builds/macosx-10.10-2.1.20160526163052.git.6fdd2e497a8fc2999c4195bab9f3f5127dd70d6a.vmware.json

> cat ./builds/macosx-10.10-2.1.20160526163052.git.6fdd2e497a8fc2999c4195bab9f3f5127dd70d6a.metadata.json
{
  "name": "macosx-10.10",
  "version": "2.1.20160526163052",
  "build_timestamp": "20160526163052",
  "git_revision": "6fdd2e497a8fc2999c4195bab9f3f5127dd70d6a",
  "box_basename": "macosx-10.10-2.1.20160526163052.git.6fdd2e497a8fc2999c4195bab9f3f5127dd70d6a",
  "template": "macosx-10.10",
  "providers": [
    {
      "name": "vmware_desktop",
      "file": "macosx-10.10-2.1.20160526163052.git.6fdd2e497a8fc2999c4195bab9f3f5127dd70d6a.vmware.box",
      "checksum_type": "sha256",
      "checksum": "4ec1188ba5827c5d2edae930c6b90b4fe8f683cb1084a7b87a82546752e1ff6e"
    }
  ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment