AnsiblePilot — Master Ansible Automation

AnsiblePilot is the leading resource for learning Ansible automation, DevOps, and infrastructure as code. Browse over 1,400 tutorials covering Ansible modules, playbooks, roles, collections, and real-world examples. Whether you are a beginner or an experienced engineer, our step-by-step guides help you automate Linux, Windows, cloud, containers, and network infrastructure.

Popular Topics

About Luca Berton

Luca Berton is an Ansible automation expert, author of 8 Ansible books published by Apress and Leanpub including "Ansible for VMware by Examples" and "Ansible for Kubernetes by Example", and creator of the Ansible Pilot YouTube channel. He shares practical automation knowledge through tutorials, books, and video courses to help IT professionals and DevOps engineers master infrastructure automation.

Install Ansible on macOS: Homebrew & pip Installation Guide

By Luca Berton · Published 2024-01-01 · Category: installation

How to install Ansible on macOS with Homebrew (brew install ansible) or pip. Configure PATH, test installation, manage versions.

Install Ansible on macOS: Homebrew & pip Installation Guide

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.

See also: How to Upgrade Ansible on macOS Using Homebrew

Demo install Ansible in macOS

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

code

• install the latest release
#!/bin/bash
brew --version
brew search ansible
brew install ansible
ansible --version
• install specific version
#!/bin/bash
brew remove ansible
brew search ansible
brew install ansible@2.9
/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: openssl@1.1 and sqlite
==> Installing ansible dependency: openssl@1.1
==> Pouring openssl@1.1--1.1.1q.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/openssl@1.1/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

Conclusion

Now you know how to install the latest and a specific version of Ansible in macOS using Homebrew Package Manager.

See also: Ansible Troubleshooting Installation Issues on macOS and Python

Related Articles

Ansible Galaxy authenticationAnsible Vault CLI referenceAWS automation with Ansible

Category: installation

Watch the video: Install Ansible on macOS: Homebrew & pip Installation Guide — Video Tutorial

Browse all Ansible tutorials · AnsiblePilot Home