Use Ansible to Configure your Workstation

Let me show you a simple and easy way to manage your MacOS workstation using Ansible. Ansible is awesome, and we should automate all the things.

I tinkered with doing this myself from scratch with some success, but I've discovered Jeff Geerling's incredible collection of Ansible roles and collections and didn't look back. They are simple, and ready to go.

Take a look at my workstation repository, also do check out Jeff's Ansible work.

First you need to install the dependencies. I am using a dotfiles Ansible role to manage my dotfiles, and a collection of mac roles:

ansible-galaxy collection install geerlingguy.mac
ansible-galaxy role install geerlingguy.dotfiles

The mac collection has roles for homebrew, mas, and dock, but I am only concerned with homebrew to install some of my favorite packages. Learn more at

Create a playbook setup-macos-workstation.yml:

- hosts: localhost
  name: Setup Workstation
  user: roy
  connection: local

    - vars/main.yml

    - geerlingguy.dotfiles
    - geerlingguy.mac.homebrew

  tasks: []

The next thing is to define the dotfiles you want and where to get them, and then also what you want to install via homebrew.

Create vars/main.yml

dotfiles_repo: ""
dotfiles_repo_version: main
  - .zshrc
  - .gitconfig
  - .railsrc
  - .aliases
  - .vimrc
  - rails-template.rb

homebrew_cask_accept_external_apps: true
  - libyaml
  - curl
  - coreutils
  - git
  - git-crypt
  - terraform
  - wget
  - zsh
  - doctl
  - go
  - tflint
  - asdf
  - direnv
homebrew_cask_appdir: /Applications
  - iterm2
  - slack
  - visual-studio-code
  - docker
  - postman
  - spotify
  - notion
  - discord

Run the playbook to download your dotfiles and symlink them to your home directory, and then install all of the packages with brew.

ansible-playbook setup-macos-workstation.yml

This gets me like 80% of the way for setting up my workstation. Some things you have to configure and install manually. But it's nice to have my workstation expressed as code.

Join the discussion on:

Join the discussion Create an account Log In


Did you like this post? Let me know by sending me a message. Is there a topic you would like me to cover? Let me know about that too. I look forward to hearing from you!

Let's Connect