Skip to content

Instantly share code, notes, and snippets.

@rmoriz
Last active April 14, 2023 20:30
Show Gist options
  • Save rmoriz/37b671afe53c984b2f85 to your computer and use it in GitHub Desktop.
Save rmoriz/37b671afe53c984b2f85 to your computer and use it in GitHub Desktop.
Build an OSX 10.10 base-box for test-kitchen and VirtualBox

Requirements

Steps

  1. Open OSX App Store, download Yosemite. Once the download is finished, the installer starts. Close it right away.

  2. Execute:

    mkdir /tmp/osxvm
    cd /tmp/osxvm
    git clone https://github.com/timsutton/osx-vm-templates
    cd osx-vm-templates
    sudo prepare_iso/prepare_iso.sh "/Applications/Install OS X Yosemite.app" out  # note result .dmg filename
    md5 out/OSX_InstallESD_10.10.3_14D136.dmg # note result checksum
    cd packer
  3. For use with test-kitchen we want a base image without chef, puppet, other stuff. Also we're only going to build the virtualbox image. Open the template.json file and adjust:

--- i/packer/template.json
+++ w/packer/template.json
@@ -101,11 +101,7 @@
       "execute_command": "chmod +x {{ .Path }}; sudo {{ .Vars }} {{ .Path }}",
       "scripts": [
         "../scripts/vagrant.sh",
-        "../scripts/vmware.sh",
-        "../scripts/parallels.sh",
         "../scripts/xcode-cli-tools.sh",
-        "../scripts/chef-omnibus.sh",
-        "../scripts/puppet.sh",
         "../scripts/add-network-interface-detection.sh",
         "../scripts/autologin.sh",
         "../scripts/system-update.sh",
  1. Start packer. This will take a lot of time and disk space (10+ GB)

    # update filename and checksum!
    packer build \
      -var iso_url=../out/OSX_InstallESD_10.10.3_14D136.dmg \
      -var iso_checksum=3d379eb82fd8417974aa94d76157d511 \
      -var username=vagrant \
      -var password=vagrant \
      -var autologin=true \
      -var install_vagrant_keys=true \
      -except vmware-iso,parallels-iso \
      template.json
      
  2. Import box to Vagrant

    vagrant box add packer_virtualbox-iso_virtualbox.box --name macosx-10.10
  3. Enjoy test-kitchen

.kitchen.yml:

---
driver:
  name: vagrant

provisioner:
  name: chef_zero


platforms:
  - name: macosx-10.10

suites:
  - name: default
    run_list:
      - recipe[your-cookbook::default]
    attributes:

Notes

Vagrant seems to have a bug, that will be fixed soon:

Vagrant insecure key detected. Vagrant will automatically replace
default: this with a newly generated keypair for better security.
Vagrant is configured to generate a random keypair and insert it
onto the guest machine, but it appears Vagrant doesn't know how to do
this with your guest OS. Please disable key insertion by setting
`config.ssh.insert_key = false` in the Vagrantfile.

After doing so, run `vagrant reload` for the setting to take effect.

If you'd like Vagrant to learn how to insert keys on this OS, please
open an issue with details about your environment.

You can find the Vagrantfile(s) inside .kitchen, add config.ssh.insert_key = false and execute vagrant reload in each directory containing a Vagrantfile.

Status

Tested on: 2015-05-28

Tested with:

@rmoriz
Copy link
Author

rmoriz commented Jun 1, 2015

👍 for both :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment