Install older version of ansible with Homebrew
I ran into an issue today where I could not execute a deployment on kubernetes due to a issue in ansible's k8s_raw module with ansible 2.6.5.
On my older mac I could simply switch to the older installed version of ansible, on my old mac however I wasn't as fortunate. Luckily there's a way to solve this by fetching the full git history of ansible yourself.
Move your terminal to the correct directory:
cd "$(brew --repo homebrew/core)"
Fetch the full history for brew:
git fetch --unshallow
Then view the full history for ansible (or any other formula for that matter):
git log Formula/ansible.rb
The log will look something as this:
adam@mbp-adam homebrew-core (master) $ git log Formula/ansible.rb commit 4dc294072201ea7fe97f9477b9b87f57994af4d3 Author: BrewTestBot <email@example.com> Date: Sun Sep 30 05:36:03 2018 +0000 ansible: update 2.6.5 bottle. commit cfdf848f1eb4df427c176eb411ef0fcd1dadd6c1 Author: Chongyu Zhu <firstname.lastname@example.org> Date: Sun Sep 30 12:41:46 2018 +0800 ansible 2.6.5 Closes #32559. Signed-off-by: Chongyu Zhu <email@example.com> commit 33d04bd7bb43e1235d56b77a8d6c6a49391c33c6 Author: BrewTestBot <firstname.lastname@example.org> Date: Sat Sep 8 11:48:10 2018 +0000 ansible: update 2.6.4 bottle.
Check out the commit of the version you would like to install:
git checkout 33d04bd7bb43e1235d56b77a8d6c6a49391c33c6
Unlink the current installed version:
brew unlink ansible
And install the version you checked out:
HOMEBREW_NO_AUTO_UPDATE=1 brew install ansible
The HOMEBREW_NO_AUTO_UPDATE is of importance here since this will force ansible to not fetch the latest updates.
After the installation you can verify the correct version:
Then you'll need to switch to the master branch again:
git checkout master
Check your local installed versions with:
brew list ansible --versions
And easily switch between version with:
brew switch ansible 2.6.4