Install Ansible on Mac

Last Updated:


The best and fastest way to get started on macOS is to use Homebrew.

Installing Homebrew (if you haven't)

Install it via walkthrough by running this command in Terminal:

    /bin/bash -c "$(curl -fsSL"

More details at:

Updating $PATH

Checking Existing $PATH

Run the following command to see your current $PATH environment variable. You'll see output similar to mine below. If your output is slightly different, that's ok.

    echo $PATH;

Make a note of the output, in case something goes wrong during the installation. Unlikely, but it can happen.

Macs with an Intel CPU

If your Mac has an Intel CPU, you can ignore this next section and go to Installing Ansible via Homebrew

Macs with the Apple M1 CPU

Update your $PATH environment variable with the following command.

    # Sets Homebrew Variables for ZShell
    # (default shell on macOS)
    echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile;

    # Sets Homebrew Variables for Bash
    # (may be used in legacy applications)
    echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.bashrc;

    # This updates your current Terminal shell session with the new environment variables.
    # If you skip this, be sure to close any open Terminal windows and re-open new ones.
    eval "$(/opt/homebrew/bin/brew shellenv)";

Your $PATH variable should now include "/opt/homebrew" entries near the beginning.

    echo $PATH;

Installing Ansible via Homebrew

This is for all versions of macOS, once you've installed Homebrew above. Run the following command and you're done!

    brew update; brew install ansible;

Checking Ansible Version

Ensure Ansible has been installed correctly and see its version number with the command below.

    ansible --version;

    ansible [core 2.12.4]
    [... more info ...]

That's it! You're all set to begin using Ansible.