Keeping Macbook Pros Up to Date with Ansible
A year ago I switched from the Gnu/Linux ecosystem to use macOS at the beginning it was difficult to get used to all the graphical user interfaces but since I have been using i3wm for almost 10 years the versatility with the tiling window manager was unsurpassed even though I haven’t check if there is a Tiling window manager for macOS, I quickly adapt my development workflow with a few graphical apps like Vscode instead of vim XCode instead of the Android SDK and so on, I definitely try Windows 10 due to the previous job but I never get used to thanks to the incredible development of the Canonical and Microsoft guys that created Windows Subsystem for Linux.
Now macOS is a new world and it is still for me, it was clear that the Operative System at the design level was really different While the macOS kernel combines the feature of a microkernel and a monolithic kernel, Linux is solely a monolithic kernel(it depends but yeah monolithic), both give you access to Unix commands, bash/zsh, and other shells, you also get a package manager like most of the Linux distros out there with homebrew, at the security level is easy to use a global keychain using the security command and created hacks for the different MFA vendors, now that leads me to buy a personal MacBook🚀, and since I have multiple macbooks pro I had to check if there was a repeatable option to keep all my macboooks up to date and synced across different versions, what I want was :
- keep the same homebrew packages installed across all my devices
- Easy to detect configurations drifts
- Easy to setup when I need to setup new macbooks
- with State
Looking for all internet I found different methods using iCloud, third-party apps and finally I found one of my favorite authors on the internet Jeff Geerling who created this awesome open source 😃👌repo and he also shares the information on his Youtube Channel
You will only need to apply the following steps as the readme mention :
- Ensure Apple’s command line tools are installed (
xcode-select --install
to launch the installer). - Install Ansible with a recent python version
$PATH="$HOME/Library/Python/3.8/bin:/opt/homebrew/bin:$PATH"
$sudo pip3 install --upgrade pip
$pip3 install ansible
- Clone the repo
$git clone https://github.com/geerlingguy/mac-dev-playbook.git
- Install the ansible roles :
$ansible-galaxy install -r requirements.yml
- Edit the
config.yml
file and run the playbook
ansible-playbook main.yml --ask-become-pass
Configuration file sample:
If you want to use this for homebrew package, here is the only thing that you will need :
---
homebrew_installed_packages:
- autoconf
- bash-completion
- gettext
- sqlite
- readline
- pv
- wget
- wrk
homebrew_cask_apps:
- firefox
- visual-studio-code
where homebrew_installed_packages
is a list of all brew packages, you can also install cask applications
There is also a few interesting options that you can check like the posibility to clone you dotfiles_repo install npm, gem, pip and composer packages.
Thats it for now