Macos Vagrant Box



Vagrant provides the framework and configuration format to create and manage complete portable development environments. These development environments can live on your computer or in the cloud, and are portable between Windows, macOS, and Linux. Vagrant ships out of the box with support for VirtualBox and HyperV only. What is Parallels Provider? Vagrant 1.8 changed SMB mounting to use the more secure credential file mechanism. However, many operating systems ship with an outdated filesystem type for SMB out of the box which does not support this. The above workaround reverts Vagrant to the insecure before, but causes it work.

A while ago, the chaps over at the Vagrant project have recently released a plugin to let Vagrant work with VMWare Fusion - this means we can finally use Vagrant to provision OS X VMs.

Why is this a good thing? Do you NetBoot VMWare to test your builds? Or maybe you still have that test Mac on your desk to test your builds. Either way, it’s going to be several minutes to restore an image, even if you’re thin imaging. With the VM already on your machine, you’re ready to go in seconds. Another bonus is that Vagrant isn’t only limited to OS X virtual machines - for example, I have a Vagrant configuration that spins up an Ubuntu box configured as a Munki server, with a copy of my repository on an external drive. This allows me to test deployments from anywhere, with everything local to my Mac (have you ever tried testing a Final Cut Studio package from home? 48GB takes a while to download.). I’ll go into more detail on this setup in a future post, but for now here’s how to get a Mac base box into Vagrant.

Box

##Pre-requisites

  • Vagrant (this was written using Vagrant 1.2.7)
  • Packer (I’m using Packer 0.3.1)
  • Git (Install the Command Line Tools from within Xcode’s preferences if you don’t have it).

##Get set up with Packer

Before we install Packer, you’re going to need to download it. No, really, you need it.

Assuming you’ve downloaded it to ~/Downloads, extract the zip file so you will be left with something like this: ~/Downloads/0.3.1_darwin_amd. Everything prefaced with a $ should be entered in your terminal.

You now have a choice: you can refer to the packer binary by it’s full path every time (/usr/local/packer/packer), or you can modify your path. The next step is entirely optional, but I highly recommend it. You need to edit ~/.profile.

And add this line to the file, then save it (CTRL-O then CTRL-X):

And then quit and re-open Terminal.app.

Templates

Box

Packer uses template files to define how it should build the VM for you. Fortunately, Tim Sutton has created a template file that can be used with Packer.

There are a couple of prep steps we need to do before we can instruct Packer to make our box. First off it’s going to need installation media. There is a script that will prepare the Install OS X Mountain Lion.app so it can be used with Packer.

You’ll see some activity in your terminal, and then you’ll be given the filename of your installation DMG and the checksum. You’ll need these in the next step.

Open up packer/template.json in your favourite editor. Paste in the checksum you were given in the last step (yours will probably be different from mine), and specify the path to your installation DMG (obviously use the path to your home directory, not mine!). You can also edit the size of the disk, the memory etc in this file.

Prepare the build!

You’re ready to go. This next step will take AGES so go and make a cup of coffee (or tea), as this is going to install OS X, run through the scripts to install the bits Vagrant needs (like Puppet), then make a Vagrant base box.

After you hit return, VMware will open up and OS X will start installing. Once everything is done, and Packer tells you it’s done in your terminal window, you just need to add it to Vagrant and then you’re ready to use it.

##Adding the VM to Vagrant

Using the VM in Vagrant

We’re going to make a quick Vagrant configuration using your newly built box.

You’re probaly going to want a GUI when it boots, so open up ~/Desktop/osx_test/Vagrantfile in your text editor of choice and find the next section.

And change it to read

Unfortunately there isn’t any support for OS X in the official Vagrant release (yet), but good old Tim Sutton has sorted that out for us. We’re going to clone his repository, switch to the branch with his changes and copy the needed files into the main Vagrant installation. Hopefully his changes will be merged into a future of Vagrant, but for now:

We’re ready to boot the thing now - make it so, number one.

You should see VMWare Fusion open if it’s not already running and your VM boot after a little while.

What’s next?

You can configure this box with a script, or using Puppet or Chef (can you guess which I’d do?)?

This version was created over 4 years ago.

This is a issue tracker for OS X Vagrant boxes, which can be found in Download section

Box was tested only on VirtualBox with Mac OS as a host. Mainly, I made it to build our iOS applications via CI-server.

Downloads

Since VagrantCloud can't host this images, you can use direct links to download them. Download speed may be slow.

  • Mac OS X Yosemite 10.10 (XCode 6.4): v0.2.1 (13Gb) (sha1: 6339bf812017b9f0046d9fdda79cc6f3d2ab169a)
  • macOS Sierra (XCode 8.2): v0.3.1 (14.1Gb)

Also, you can download older boxes from the Hashicorp Atlas page AndrewDryga/vagrant-box-osx/ (if it's accessible at the moment), or simply by starting with vagrant init AndrewDryga/vagrant-box-osx instead of url.

Setting up

  1. Install Vagrant and VirtualBox;
  2. cd into your project directory;
  3. Run vagrant init AndrewDryga/vagrant-box-osx;
  4. Your Vagrantfile should be ready as soon as Vagrant downloads box;
  5. Start VM by calling vagrant up.

OS X Licensing

Apple's EULA states that you can install your copy on your actual Apple-hardware, plus up to two VMs running on your Apple-hardware. So using this box on another hardware is may be illegal and you should do it on your own risk.

By using it you agree with all macOS Sierra and XCode license agreements.

What's included?

Sierra box:

  • Default Vagrantfile (inside box) that fixes most of common issues;
  • Homebrew;
  • Homebrew Cask;
  • NodeJS 7.2.1 (npm 3.10.10, n 2.1.3);
  • Lunchy;
  • Puppet 4.8.1;
  • XCode 8.2 (and XCode Command Line Tools).

Yosemite box:

  • Default Vagrantfile (inside box) that fixes most of common issues;
  • Homebrew;
  • Homebrew Cask;
  • Puppet 3.7.4;
  • XCode 6.4;
  • XCode Command Line Tools;
  • NodeJS 0.12.7 (for npm);
  • Appium 1.4.10;
  • iOS Simulator (all devices for iOS 8.4).

Useful cli tools and information

  • Nomad CLI - provides a set of tools that allow to manage certificates, profiles and many other things;
  • ObjC.io Issue 6 - how-to article about building apps in cli-only (this one about Travis-Ci);
  • security - use it to manage your keychains;
  • xctool - Facebook project for building iOS apps.

Common issues

  • Box may crash on AMD-based hosts due to VirtualBox issues.
  • Do not turn 3D acceleration on in VirtualBox, or it will start retuning aborted condition and would not start in headless mode;
  • VirtualBox doesn't have Guest additions for Mac OS X, so you can't have shared folders. Instead you can use normal network shared folders (docs):# Use NFS for the shared folderconfig.vm.synced_folder '.', '/vagrant', id: 'core', :nfs => true, :mount_options => ['nolock,vers=3,udp,noatime']
  • If your VM freezes with hfs mounted macintosh hd on device root_device then you need to set cpuidset inside your Vagrantfile: vb.customize ['modifyvm', :id, '--cpuidset', '1','000206a7','02100800','1fbae3bf','bfebfbff'] (it's included since version 0.2);
  • If your mouse does not work on a MacBook Pro host machine, shut down the VM and open the VirtualBox Manager. Edit the VM's settings. Choose the System tab. Under the Motherboard sub-tab, set the Chipset option to be PIIX 3, and set the Pointing Device option to be USB Tablet. Restart the VM;
  • When OSX is trying to prompt graphically for password (i.e when using swift REPL), it will raise the error error:process exited with status -1) (lost connection) because there is no graphical output when using vagrant via ssh login, enable the develop mode can solve this situation, run the following command:sudo /usr/sbin/DevToolsSecurity --enable;
  • If you need user password (for example for Homebrew Cask). Vagrant have default consideration to create user vagrant with password vagrant, you can use it.

Warning

VirtualBox support for Mac OS X is experimental. More information can be found in official docs.

Tips to build your own box

Main think you should remember is that you need latest VirtualBox version BEFORE you start installation. Process of installation is pretty straight forward (as on usual Mac), but you need to erase virtual drive during installation via Disk Utilities. After that just follow Vagrant guide to create base box and another one to package it.

Sometimes you need to rebuild VirtualBox kernel extensions before installing OS on VM.

Helpful links (most of them are outdated):

  • Also you might be interested to take look at radeksimko/vagrant-osx that can build boxes for VMWare Vagrant provider.
  • virtualbox Externally hosted (vagrant-osx.nyc3.digitaloceanspaces.com)

This version was created over 5 years ago.

Macos Vagrant Box Centos

The full description and issue tracker can be found on GitHub AndrewDryga/vagrant-box-osx.

What's included?

  • Puppet 3.7.4
  • XCode 6.4
  • XCode Command Line Tools
  • NodeJS 0.12.7 (for npm)
  • Appium 1.4.10
  • iOS Simulator (all devices for iOS 8.4)

Useful cli tools and information

  • Nomad CLI - provides a set of tools that allow to manage certificates, profiles and many other things;
  • ObjC.io Issue 6 - how-to article about building apps in cli-only (this one about Travis-Ci);
  • security - use it to manage your keychains;
  • xctool - Facebook project for building iOS apps.

Vagrant Macos Catalina

Common issues

  • Do not turn 3D acceleration on in VirtualBox, or it will start retuning aborted condition and would not start in headless mode;
  • VirtualBox doesn't have Guest additions for Mac OS X, so you can't have shared folders. Instead you can use normal network shared folders (docs).
  • If you face VM freezed on message hfs mounted macintosh hd on device root_device then you need to set cpuidset inside your Vagrantfile: vb.customize ['modifyvm', :id, '--cpuidset', '1','000206a7','02100800','1fbae3bf','bfebfbff'] (it's included since version 0.2);
  • If your mouse does not work on a MacBook Pro host machine, shut down the VM and open the VirtualBox Manager. Edit the VM's settings. Choose the System tab. Under the Motherboard sub-tab, set the Chipset option to be PIIX 3, and set the Pointing Device option to be USB Tablet. Restart the VM;
  • When OSX is trying to prompt graphically for password (i.e when using swift REPL), it will raise the error error:process exited with status -1) (lost connection) because there is no graphical output when using vagrant via ssh login, enable the develop mode can solve this situation, run the following command:sudo /usr/sbin/DevToolsSecurity --enable;
  • In early versions of this box you need to accept XCode license by you own. If you face error: Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo., just run this command: sudo xcodebuild -license accept;
  • If you need user password (for example for Homebrew Cask). Vagrant have default consideration to create user vagrant with password vagrant, you can use it.

OS X Licensing

Apple's EULA states that you can install your copy on your actual Apple-hardware, plus up to two VMs running on your Apple-hardware. So using this box on another hardware is may be illigal and you should do it on your own risk.

  • virtualbox Hosted by Vagrant Cloud (13 GB)

This version was created over 5 years ago.

The full description and issue tracker can be found on GitHub AndrewDryga/vagrant-box-osx.

  • virtualbox Hosted by Vagrant Cloud

This version was created over 5 years ago.

The full description and issue tracker can be found on GitHub AndrewDryga/vagrant-box-osx.

  • virtualbox Externally hosted (files.dryga.com)