Ansible for old Macs
I have been playing around with Ansible lately and one of the use cases I have found is for a Mac rebuild.
I have tested with MacOS Monterey on a MacBook 12-inch, Early 2016. I will rebuild my 2017 Intel Macbook Pro running Ventura shortly.
Initially, I wouldn’t really have distinguished between old/new Mac but I just dove into using Homebrew and it was taking hours. Had I done a little research prior I would have noticed it isn’t even supported anymore on Monterey. So I modified my approach to use MacPorts and it runs great. No issues! It isn’t as hip as HomeBrew, I guess, but works on older macs easily.
It essentially sets up my Mac how I like it. Installs various stuff and configures the terminal to look and function better. Feel free to use and modify to your own preferences. Ansible is fun!
You can clone or fork the repository from here
Instructions
Basically, fork or clone this repository then modify and run.
Below is my rebuild process.
- Refresh installation of Mac using Command R during boot. Takes a couple of hours.
- Update OS. Another 45 minutes with reboot.
- [optional] Change hostname
- [optional] Update DNS to the internal DNS server for local name resolution
- [optional] Add the new hostname to the local DNS server
- [optional] Set a static IP via reserved DHCP.
- Install x-tools. Another 20 minutes.
xcode-select --install
- Download then install MacPorts. You can download from here. Click on your version of OSX
- Download and install Python for mac. You can get here
- Install Python which also installs
pip
. Make sure to click on the Install Certificates.command when the installation completes. - Upgrade pip
pip3 install --upgrade pip
- Install Ansible on the Macbook
pip3 install ansible
- Clone or fork this repo.
- Modify the hosts file to the hostname of your Mac. You can check by running the
hostname
command. - Modify the group_vars/all.yml to your username. NOTE: It is expected the username is already created on the Mac as this is required during installation/rebuild.
- Run playbook from Macbook. It is meant to be run using ansible-pull from your git repo. It needs to be run using sudo. Takes about an hour to complete on my MacBook.
# If a public repo then run the following from the Mac. Replace with your values.
sudo ansible-pull -U https://github.com/<Your Account>/your_git.git
# If a private repo then run the following from the Mac. Replace with your values.
export OAUTH_TOKEN="Insert your github oauth token here"
ansible-pull -U https://oauth2:$OAUTH_TOKEN@github.com/ProServicesStorage/ansible_configs.git