Ansible Pilot

How to install Ansible in macOS - Ansible install

How to Install the latest and a specific version of Ansible with Homebrew Package Manager.

October 20, 2022
Access the Complete Video Course and Learn Quick Ansible by 200+ Practical Lessons

How to install Ansible in macOS. Today we’re going to talk about the easier way to install and maintain Ansible inside macOS. I’m Luca Berton and welcome to today’s episode of Ansible Pilot

How to install Ansible in macOS

Today we’re talking about How to install Ansible in macOS. The easier way to install and maintain Ansible inside macOS is to use the Homebrew Package Manager. It has already a build of Ansible with some versions available. The main advantage of using brew is that it takes care of all the necessary dependencies and it manage also the upgrade process. An alternative could be to use Python PIP but you’re going to download the source code and compile the software. It could be a solution for a developer that want always the latest up-to-date release.

Demo install Ansible in macOS

Let me demonstrate to you how to install the latest and a specific version of Ansible in macOS with Homebrew Package Manager.

code

#!/bin/bash
brew --version
brew search ansible
brew install ansible
ansible --version
#!/bin/bash
brew remove ansible
brew search ansible
brew install [email protected]
/usr/local/opt/ansible\@2.9/bin/ansible --version

Execution

devops@devops-mac ~ % brew install ansible                        
==> Downloading https://ghcr.io/v2/homebrew/core/openssl/1.1/manifests/1.1.1q
Already downloaded: /Users/lberton/Library/Caches/Homebrew/downloads/6271b05548776a2b3b124d10bd5580078ddd5ae46f9c34d37ca7cf2c26c2d8f3--openssl@1.1-1.1.1q.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/openssl/1.1/blobs/sha256:9a130889462e43fdc473302fb7fa0ac871af0ad6a3e9df3de27c1ea2b211f2e0
Already downloaded: /Users/lberton/Library/Caches/Homebrew/downloads/006e790d2a4d90217d43ec152d72e4cafaa6e5c96fa0ef705bc5664fec2de759--openssl@1.1--1.1.1q.big_sur.bottle.tar.gz
==> Downloading https://ghcr.io/v2/homebrew/core/sqlite/manifests/3.39.0
Already downloaded: /Users/lberton/Library/Caches/Homebrew/downloads/78bd4ae0dc207f1478551239ce569b858a0a2b27f2b37ed9c3cedbb7a1b7b79d--sqlite-3.39.0.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/sqlite/blobs/sha256:6a6fd8d58bfc45afa6d4f1700f500acedb533cfe8d3d60ce1a5769dbeff37c23
Already downloaded: /Users/lberton/Library/Caches/Homebrew/downloads/ecba162cae6835f4c4f79c60be1d753107b63c5947396314d41d6b78cceea9c7--sqlite--3.39.0.big_sur.bottle.tar.gz
==> Downloading https://ghcr.io/v2/homebrew/core/ansible/manifests/6.1.0
Already downloaded: /Users/lberton/Library/Caches/Homebrew/downloads/054df42c02318ca18131811de37f79d62aa763c2568b51106643cdac2835dae8--ansible-6.1.0.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/ansible/blobs/sha256:c2623d39441055834d7b449e8bb2d1eaa7cb3f57eb4a575fbd4b71fbc8073aea
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:c2623d39441055834d7b449e8bb2d1eaa7cb3f57eb4a575fbd4b71fbc8073aea?se=2022-07-15T12%3A10%3A00Z&sig=yURD
######################################################################## 100.0%
==> Installing dependencies for ansible: [email protected] and sqlite
==> Installing ansible dependency: [email protected]
==> Pouring [email protected]_sur.bottle.tar.gz
🍺  /usr/local/Cellar/[email protected]/1.1.1q: 8,097 files, 18.5MB
==> Installing ansible dependency: sqlite
==> Pouring sqlite--3.39.0.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/sqlite/3.39.0: 11 files, 4.4MB
==> Installing ansible
==> Pouring ansible--6.1.0.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/ansible/6.1.0: 27,638 files, 342.0MB

Verification

After the successful installation you could verify in the command line:

devops@devops-mac ~ % ansible --version
ansible [core 2.13.1]
  config file = None
  configured module search path = ['/Users/lberton/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/Cellar/ansible/6.1.0/libexec/lib/python3.10/site-packages/ansible
  ansible collection location = /Users/lberton/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.10.5 (main, Jun 23 2022, 17:15:32) [Clang 13.0.0 (clang-1300.0.29.30)]
  jinja version = 3.1.2
  libyaml = True

code with ❤️ in GitHub

Recap

Now you know how to install the latest and a specific version of Ansible in macOS using Homebrew Package Manager. Subscribe to the YouTube channel, Medium, and Website, X (formerly Twitter) to not miss the next episode of the Ansible Pilot.

Academy

Learn the Ansible automation technology with some real-life examples in my

My book Ansible By Examples: 200+ Automation Examples For Linux and Windows System Administrator and DevOps

BUY the Complete PDF BOOK to easily Copy and Paste the 250+ Ansible code

Want to keep this project going? Please donate

Access the Complete Video Course and Learn Quick Ansible by 200+ Practical Lessons
Follow me

Subscribe not to miss any new releases