Here is how to install Ansible on macOS in 2026. Tested and verified.
Prerequisites
- macOS 13 (Ventura) or later
- Homebrew installed (
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)")
Method 1: Homebrew (Recommended)
brew install ansibleVerify:
ansible --versionMethod 2: pip (Python Package Manager)
# Ensure Python 3 is installed
python3 --version
# Install pipx (recommended for CLI tools)
brew install pipx
pipx ensurepath
# Install Ansible
pipx install ansible
# Or with pip directly
pip3 install ansible --userMethod 3: pip in Virtual Environment
python3 -m venv ~/ansible-venv
source ~/ansible-venv/bin/activate
pip install ansiblePost-Installation Setup
# Create default config directory
mkdir -p ~/.ansible
# Create a basic ansible.cfg
cat > ~/.ansible.cfg << 'EOF'
[defaults]
inventory = ./inventory
host_key_checking = False
interpreter_python = auto_silent
EOF
# Create a test inventory
mkdir -p ~/ansible-project
cat > ~/ansible-project/inventory << 'EOF'
[local]
localhost ansible_connection=local
EOF
# Test with a ping
cd ~/ansible-project
ansible all -m pingVerify Installation
ansible --version
ansible-playbook --version
ansible-galaxy --version
ansible-vault --versionUpgrade Ansible
# Homebrew
brew upgrade ansible
# pip
pip3 install --upgrade ansible
