MacBook Setup Using Ansible and Homebrew

The Problem:

You have a brand new fresh install of OSX on your MacBook and you need to get up and running. You want all your apps installed using Homebrew & Cask and OSX setup with goodies like zsh and .dotfiles.

The solution:

Use Ansible to deploy CLI apps via Homebrew and GUI Apps via Cask. Then have Ansible setup the shell with zsh and .dotfiles that are pulled from a GitHub repo.

GitHub - e30chris/Ansible-MacDeploy


Everything infrastructure is code according to proper DevOps and the MacBook that is the control center for that DevOps is certainly going to be setup using code as much as possible.


  • Bring in OSX user settings like desktop backgrounds and other System Preferences.


  • Fresh OSX install
  • Homebrew installed
  • Ansible installed via Homebrew
  • GitHub Authenticated
  • GitHub API token set
  • .dotfiles forked and customized to your liking

Fresh OSX Install

USB install OSX

Homebrew installed

Follow the SysAdmin Bible and read the script before you run it:

Github Raw of Homebrew install script

Run the script once verified that you know what it will be doing:

ruby -e "$(curl -fsSL"

Verify Homebrew is correct:

sandor@theargo$ brew doctor

Install Ansible via Homebrew

Installing the latest from dev:

sandor@theargo$ brew install ansible --HEAD

GitHub Authenticated

sandor@theargo$ git config --global "sandor"
sandor@theargo$ git config --global ""
sandor@theargo$ ssh-keygen -t rsa -b 4096 -C "sandor@macbook"
sandor@theargo$ ssh-add ~/.ssh/id_rsa
sandor@theargo$ pbcopy < ~/.ssh/

Add your SSH Public Key to GitHub -> Settings.

GitHub API Token Set

This avoids annoying brew errors on lookups.


.dotfile forked

All hail Holmans .dotfiles

Explained by Holman

Download and run the playbook


sandor@theargo$ git clone ~/Codestuff/Ansible/.


  • Set the OSX username that is running the playbook in vars/main.yml


sandor@theargo$ ansible-playbook -i hosts site.yml --ask-sudo-pass

Then run the .dotfiles bootstrap script

sandor@theargo$ ~/.dotfiles/script/bootstrap

Now go and setup all the OSX pieces that are not easily Ansibilized like the App Store.