Setting up new Mac with Ansible
Most Software Engineers stay in their job on an average 2 years. Most of the FAANG companies, at least the one’s I’ve worked for, issue new hardware every 2 years. It is almost guaranteed that you will be setting up a new machine in next 12-24 months and you’ll be doing it quite often throughout your career.
So, what’s the most efficient way to setup your new computer?
Setting up your new machine is not only a frustrating task, but results are not guaranteed to be the same every single time you do it. It takes a long time to be productive again, and there is always something missing.
It’s a good idea to invest some time in automating this process. Ansible is a tool that helps you do that. It’s primarily used for provisioning web servers, remote hosts where same tasks need to run at scale, in a predictable manner. You can use this powerful tool to do the same with your personal computer.
In this post, I’m will go over how I’ve setup my Ansible playbooks, and hopefully motivate you to setup something similar.
How do I setup a new machine?
Every time I get a new mac, I run 3 simple commands to configure it exactly like I want and am fully productive in a matter of minutes. The setup looks identical on every machine.
You can find my Ansible repository here.
Overview
Lets go over broader sections of my Ansible script:
This is the root level ansible playbook, it’s an executable ansible script. In order to run ansible on a computer I have to run
./playbook.yml
This top level script needs to specify which hosts it’s going to run on, in this case localhost. It can declare some variables that can be used by attached scripts, and certain debugging /cleanup tasks.
Once all the basic things are setup, it then calls 4 different plays from ./tasks directory. They do the following:
Build your own
I highly recommend writing your own ansible script from scratch. It will take less than an hour of your time but save many hours in future as well as days worth of frustration setting up new systems.
I’d highly recommend building your own ansible playbook from scratch. Feel free to reference my ansible repo or any of the ones listed below. Good luck atuomating!
Here are some good references I found on this topic:
- Mac development playbook by Jeff Geerling. He also has some excellent youtube content about all things Ansible.
- Adam Johnson’s blogpost on Macbook provisioning and related playbooks.
- Theprimeagen’s Ansible playbooks.