This tutorial will guide you through the process of running macOS Mojave in a VM using Vagrant. I’ve mainly used this for development and testing of Ansible playbooks targeted at configuring headless app builders for iOS devices and Macs.
This tutorial assumes you have a working installation of macOS Mojave or later running on a Mac, and that you have VirtualBox and the VirtualBox Extension Pack installed. This tutorial will make use of macinbox by bacongravy.
Install Homebrew and then install Vagrant:
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" $ brew install vagrant
Get the macOS Mojave Installer Application
Follow this link to go to the Mac App Store and download and install the macOS Mojave Installer.
Get the macOS Vagrant Box Builder
gem, the Ruby package manager:
$ sudo gem install macinbox
Create the macOS Vagrant Box
Create a directory to store your macOS Vagrant related files, and
$ mkdir ~/macos-vagrant $ cd ~/macos-vagrant $ sudo macinbox # will take a while $ vagrant init macinbox
Finally, to start the VM with Vagrant, run:
$ vagrant up
To destroy the virtual machine, simply run (while standing in the directory of your
Vagrantfile, in our example
$ vagrant destroy
When this article was published macOS Catalina had already been released. I’ll update the site with instructions on how to run Catalina as well. I’ll also post a tutorial on using Ansible to configure macOS.
Best of luck! 😀