I want to automate my Mac OS X Yosemite setup, because you never know when it might crash. After buying my MBP I have started a manual logbook what I have installed. But using Vagrant for a long time I know there must be a better way.
So I try my automation script in a Vagrant environment. I'm using just a simple shell provider for these reasons:
- learn how to automate some steps (like install a .dmg file)
- have a provision script that could be loaded from HTTP and executed on a real MBP.
But before you ask, I also know BOXEN:
QUIT WORRYING ABOUT YOUR TOOLS.
Automate the pain out of your development environment.
Boxen installs your dependencies so you can focus on getting things done.
But they also have to do the Xcode Command Line Tool download in a semi automated way.
Another thing I have learned so far is caskroom.io
"To install, drag this icon..." no more!
Here you find many more packages to install from command line.
To build a mac-dev-box on your MBP, you will need the following:
- MacBook Pro if you haven't one already
- Packer 0.8.5
- Vagrant 1.7.4
- VMware Fusion 7.1.2, 54 €
- vagrant-vmware-fusion plugin, 59 €
You have to build an OS X Yosemite basebox from boxcutter/osx.
You will need a downloaded InstallESD.dmg
file with eg. OS X 10.10.4. Please read the boxcutter docs for details.
These were my steps to build the osx1010-desktop basebox.
git clone https://github.com/boxcutter/osx
cd osx
mkdir -p "iso/OS X Yosemite"
cp ../InstallESD.dmg "iso/OS X Yosemite/InstallESD.dmg"
sed -i.bak -e 's/Install\\ OS\\ X\\ Yosemite\.app/InstallESD.dmg/' Makefile
make vmware/osx1010-desktop
vagrant box add osx1010-desktop box/vmware/osx1010-desktop-nocm-1.0.1.box
These are my current steps to build the mac-dev-box:
git clone https://github.com/StefanScherer/mac-dev-box
cd mac-dev-box
vagrant up --provider vmware_fusion
The Vagrantfile
sets an option to start the VM with Retina (HiDPI). The provision script scripts/enable-hidpi.sh
enables HiDPI inside the VM. At the moment you have to logout and login again to make this change work. Then open the System Preferences, set the display to "scaled" using the HiDPI setting. Enjoy!
To speed up the development of such a provision script, I always use the vagrant-multiprovider-snap plugin.
vagrant plugin install vagrant-multiprovider-snap
So you build a clean machine with this and take a snapshot:
vagrant up --no-provision
vagrant snap take
Then you can do what you want with the box, manually or with vagrant provision scripts. After your provision script has improved enough, test it again with:
vagrant snap rollback
vagrant provision
Copyright (c) 2014 Stefan Scherer
MIT License, see LICENSE for more details.