You now know what Ansible is and which problems it will solve at Aurora Store. It's time to install it on your control node, the machine from which you will run all of your automation. A clean, well-understood installation will save you plenty of trouble later on: mixed versions, modules that "don't show up", or Python dependencies that clash with the system's. In this lesson you will look at the requirements, the different ways to install Ansible (and which one we recommend), how to verify the installation by interpreting each line of ansible --version, and how to keep it up to date.

  1. Control node and managed node requirements

Ansible draws a clear distinction between two kinds of machines, and each has different requirements.

1.1 Control node

This is your computer, where you will install Ansible.

  • Operating system: Linux, macOS or any UNIX-like system. Windows cannot be a control node natively (later you will see how to use WSL2).
  • Python: ansible-core 2.17 requires Python 3.10 or later on the control node, and later releases (2.18, 2.19…) raise that minimum to Python 3.11. Practical advice: use Python 3.11 or 3.12.
  • OpenSSH client (ssh), available by default on Linux and macOS.

Check your Python and SSH versions:

python3 --version
ssh -V

Sample output:

Python 3.12.3
OpenSSH_9.6p1 Ubuntu-3ubuntu13, OpenSSL 3.0.13 30 Jan 2024

1.2 Managed nodes

These are the servers you are going to manage (web1, web2 and db1 at Aurora Store).

  • A running SSH server (sshd).
  • Python 3 (3.8 or later on modern releases; check the support matrix for the version you use). Ubuntu 24.04 ships Python 3.12 out of the box, so you won't have to do anything.
  • No need to install Ansible on them: that's the advantage of the agentless model.
Requirement Control node Managed nodes
Ansible installed Yes No
Python 3.10+ (preferably 3.11/3.12) Roughly 3.8+ (depending on version)
SSH Client (ssh) Server (sshd)
Operating system Linux, macOS, WSL2 Linux/UNIX (Windows via WinRM/SSH)

  1. ansible versus ansible-core

When you look up how to install Ansible you will come across two packages with similar names. Understanding the difference matters.

Package What it contains Example version When to use it
ansible-core The engine: executables (ansible, ansible-playbook…), the language and the ansible.builtin collection 2.17, 2.18, 2.19 Minimal installs, containers, when you manage collections yourself
ansible ansible-core plus a large selection of community collections (community.general, ansible.posix, community.postgresql, amazon.aws…) 10, 11, 12 Learning and most projects: "batteries included"

Version mapping (approximate):

ansible package Includes ansible-core
10.x 2.17
11.x 2.18
12.x 2.19

In this course we will install the ansible package (version 10 or later), because later on we will use collections such as community.postgresql without having to install them by hand. The concept of a collection is covered in the "Collections and Fully Qualified Names (FQCN)" lesson in Module 2.

pipx is a tool that installs Python applications, each in its own isolated virtual environment, and makes their executables available on your PATH. It is the method recommended by the official documentation because:

  • It doesn't mix Ansible's dependencies with the system's Python packages.
  • It doesn't require sudo.
  • It makes upgrading and uninstalling easy.

3.1 Installing pipx

On Ubuntu/Debian:

sudo apt update
sudo apt install -y pipx
pipx ensurepath
  • sudo apt install -y pipx: installs pipx from the official repositories.
  • pipx ensurepath: adds ~/.local/bin (where pipx places executables) to your shell's PATH.

On Fedora/RHEL: sudo dnf install -y pipx. On macOS with Homebrew: brew install pipx.

After pipx ensurepath, close and reopen your terminal (or run source ~/.bashrc) so the PATH change takes effect.

3.2 Installing Ansible

pipx install --include-deps ansible
  • pipx install ansible: creates a dedicated virtual environment and installs the ansible package into it.
  • --include-deps: essential with the ansible package. The executables (ansible, ansible-playbook, etc.) actually belong to its ansible-core dependency; without this option, pipx wouldn't expose them on the PATH.

If you only want the engine:

pipx install ansible-core

If you need a specific version (for example, to match your team's):

pipx install --include-deps "ansible==10.*"

3.3 Adding Python libraries to the Ansible environment

Some modules need additional Python libraries on the control node. With pipx you add them with inject:

pipx inject ansible passlib

This installs passlib inside Ansible's environment (not system-wide). You don't need it now; it's just so you know how to do it when a lesson calls for it.

  1. Alternative: pip in a virtual environment

If you'd rather manage the virtual environment yourself (for example, to have a different Ansible version per project), you can use venv and pip:

python3 -m venv ~/venvs/ansible
source ~/venvs/ansible/bin/activate
pip install --upgrade pip
pip install ansible

Explanation:

  • python3 -m venv ~/venvs/ansible: creates a virtual environment in that folder.
  • source .../activate: activates the environment; from now on python and pip are the environment's.
  • pip install ansible: installs Ansible inside the environment.

Drawback: you have to activate the environment in every new terminal before using ansible. To leave the environment, run deactivate.

Avoid sudo pip install ansible: it installs packages into the system Python and can break tools the operating system itself relies on. On Ubuntu 24.04 and Debian 12, pip also blocks that operation by default (externally-managed-environment error).

  1. Alternative: system package managers

Package managers are convenient, but they often ship older versions than PyPI.

5.1 Ubuntu (the project's official PPA)

sudo apt update
sudo apt install -y software-properties-common
sudo add-apt-repository --yes --update ppa:ansible/ansible
sudo apt install -y ansible
  • add-apt-repository ... ppa:ansible/ansible: adds the repository maintained by the Ansible project, with newer versions than Ubuntu's.
  • apt install -y ansible: installs the full package.

5.2 Fedora and RHEL

# Fedora: full package
sudo dnf install -y ansible

# RHEL / Rocky / AlmaLinux: the engine is in AppStream
sudo dnf install -y ansible-core

5.3 macOS with Homebrew

brew install ansible

5.4 Comparing the methods

Method Version Isolation Needs sudo Ease of upgrading Recommended for
pipx Very recent Yes No pipx upgrade This course and general use
pip + venv Very recent Yes No pip install -U (with the environment active) Several versions per project
apt (PPA) / dnf Recent or somewhat old No (system-wide) Yes Along with the rest of the system Corporate servers with a package policy
brew Recent Managed by brew No brew upgrade macOS users

Important: don't install Ansible using several methods at once. You would end up with several ansible executables on your PATH and wouldn't know which one runs. If you have done so, check with which -a ansible.

  1. Windows users: WSL2

Windows cannot act as a control node natively. The recommended solution is WSL2 (Windows Subsystem for Linux), which runs a real Linux distribution inside Windows.

In a PowerShell console run as administrator:

wsl --install -d Ubuntu-24.04
  • Installs WSL2 (if it wasn't already) and the Ubuntu 24.04 distribution.
  • When it finishes, reboot if prompted and open "Ubuntu 24.04" from the Start menu to create your Linux user.

From then on, inside the Ubuntu terminal, follow exactly the same steps as in section 3 (pipx).

Tips for WSL2:

  • Work inside the Linux file system (/home/<user>/...) rather than in /mnt/c/...: it's faster and avoids permission problems with SSH keys and with ansible.cfg (you will see this in Module 2).
  • You can edit files with VS Code and its "WSL" extension.

  1. Verifying the installation: ansible --version line by line

Run:

ansible --version

Sample output (pipx installation, user student):

ansible [core 2.18.1]
  config file = None
  configured module search path = ['/home/student/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/student/.local/share/pipx/venvs/ansible/lib/python3.12/site-packages/ansible
  ansible collection location = /home/student/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/student/.local/bin/ansible
  python version = 3.12.3 (main, Nov  6 2024, 18:32:19) [GCC 13.2.0] (/home/student/.local/share/pipx/venvs/ansible/bin/python)
  jinja version = 3.1.4
  libyaml = True
Line Meaning What to check
ansible [core 2.18.1] Version of the ansible-core engine (not of the ansible package) That it is 2.17 or later
config file = None The ansible.cfg file in use. None = none, default values Normal for now; you will configure it in Module 2
configured module search path Folders where Ansible looks for additional custom modules Informational
ansible python module location Where Ansible's code is installed Confirms it comes from the pipx environment and not from somewhere else
ansible collection location Folders where it looks for collections you install Informational
executable location Path of the ansible executable you are using If several methods are installed, this shows which one wins
python version Python version on the control node that runs Ansible That it meets the minimum
jinja version Version of the Jinja2 templating engine (Module 5) Informational
libyaml = True Uses the faster C YAML library True is what you want

To find out the version of the ansible package (the one that includes the collections):

pipx list
venvs are in /home/student/.local/share/pipx/venvs
apps are exposed on your $PATH at /home/student/.local/bin
   package ansible 11.1.0, installed using Python 3.12.3
    - ansible
    - ansible-community
    - ansible-config
    - ansible-console
    - ansible-doc
    - ansible-galaxy
    - ansible-inventory
    - ansible-playbook
    - ansible-pull
    - ansible-test
    - ansible-vault

You can also run ansible-community --version, which shows the ansible package version directly.

  1. Upgrading and uninstalling

Action pipx pip + venv apt / dnf brew
Upgrade pipx upgrade --include-injected ansible pip install -U ansible (environment active) sudo apt upgrade ansible / sudo dnf upgrade ansible brew upgrade ansible
Uninstall pipx uninstall ansible rm -rf ~/venvs/ansible sudo apt remove ansible / sudo dnf remove ansible brew uninstall ansible
  • --include-injected also upgrades the libraries you added with pipx inject.
  • In a team, it's good practice to agree on a common Ansible version so that everyone gets the same results. Later, in Module 7, you will see execution environments, which solve this problem more robustly.

  1. Shell autocompletion (optional)

Ansible supports Tab completion thanks to the argcomplete library. With pipx:

pipx inject --include-apps ansible argcomplete
activate-global-python-argcomplete --user
  • The first line installs argcomplete into Ansible's environment and exposes its helper commands.
  • The second enables global autocompletion for your user (in bash). Open a new terminal for it to take effect.

If you'd rather enable it only for some commands, add this to your ~/.bashrc:

eval "$(register-python-argcomplete ansible)"
eval "$(register-python-argcomplete ansible-playbook)"
eval "$(register-python-argcomplete ansible-doc)"

Try it by typing ansible-doc -- and pressing Tab twice: you will see the available options.

Common Mistakes and Tips

  • ansible: command not found after installing with pipx: you didn't reopen the terminal after pipx ensurepath, or ~/.local/bin is missing from your PATH. Check with echo $PATH.
  • Installing the ansible package with pipx without --include-deps: pipx warns that there are no apps to expose and the commands don't appear. Reinstall with pipx install --include-deps ansible --force.
  • externally-managed-environment error: you are running pip install against the system Python. Use pipx or a venv.
  • Several installations at once: which -a ansible lists every executable; uninstall the extra ones.
  • Mixing up versions: ansible --version shows the ansible-core version (2.x), not the ansible package version (10, 11…).
  • WSL2 working in /mnt/c: slow and with problematic permissions. Work in your Linux $HOME.

Exercises

Exercise 1: Installation and verification

Install Ansible with pipx on your control node and write down: the ansible-core version, the ansible package version, the Python version it uses and the path of the executable.

Exercise 2: Troubleshooting

An Aurora Store colleague sends you this output:

$ ansible --version
ansible 2.9.6
  config file = /etc/ansible/ansible.cfg
  ...
  python version = 3.8.10
$ which -a ansible
/usr/bin/ansible
/home/marta/.local/bin/ansible

What is going on, and what would you recommend?

Exercise 3: Requirements

State whether each statement is true or false and explain why:

  1. Ansible must be installed on web1, web2 and db1.
  2. A Windows 11 laptop can be a control node using WSL2.
  3. db1 needs Python for Ansible to be able to manage it.

Solutions

Exercise 1. Commands:

sudo apt install -y pipx && pipx ensurepath
# reopen the terminal
pipx install --include-deps ansible
ansible --version          # core version, Python and executable path
ansible-community --version  # ansible package version

The executable path should be ~/.local/bin/ansible, and the Python module line should point to ~/.local/share/pipx/venvs/ansible/....

Exercise 2. They have two installations: an old system one (/usr/bin/ansible, Ansible 2.9, badly out of date) and a pipx one (~/.local/bin/ansible). Since /usr/bin comes first in their PATH, the old one runs. Recommendation: uninstall the system one (sudo apt remove ansible) or, at the very least, make sure ~/.local/bin comes first in the PATH; then check again with ansible --version.

Exercise 3.

  1. False: Ansible doesn't use agents; it is only installed on the control node.
  2. True: Windows can't be a control node natively, but it can through a Linux distribution on WSL2.
  3. True: Ansible modules are Python programs that run on the managed node (you will see this in the architecture lesson). Ubuntu 24.04 already includes it.

Conclusion

You now have Ansible installed on your control node, preferably with pipx to keep it isolated and easy to upgrade. You know the difference between ansible and ansible-core, the requirements for each kind of machine, and how to read ansible --version to spot installation problems. But an automation tool needs something to automate: in the next lesson, Setting Up the Practice Lab, you will create Aurora Store's web1, web2 and db1 machines with Vagrant and check that you can reach them over SSH.

© Copyright 2026. All rights reserved