Install Ansible on Ubuntu, Fedora, CentOS, macOS and Windows (WSL) in 2026: pip, pipx, and the Python Version Trap

TL;DR

  • Ansible only needs to be installed on the control node, the machine you run ansible from. Managed nodes need Python and SSH, not Ansible (installation guide).
  • Fastest route on Linux and macOS: python3 -m venv ansible-env, ansible-env/bin/pip install ansible, then ansible --version. On 2026-11-03 this gave me Ansible 12.3.0 with ansible-core 2.19.15 and a working ansible localhost -m ping.
  • The trap: pip picks the newest release your Python supports. ansible-core 2.20 and 2.21 need Python 3.12 or newer, 2.22 needs 3.13 or newer, so on Python 3.11 you silently stay on 2.19.
  • Windows: there is no native control node. Install WSL and follow the Linux steps inside it (Windows guide).
  • Not your exact case? If you already have Ansible and need to target one machine, read ansible --limit and hosts; if you want a safe lab first, read Ansible lab on a laptop with Docker.

Table of Content

  1. What you are installing and where
  2. Pick the route
  3. Install with pip in a venv (Linux and macOS)
  4. Install with pipx
  5. Ubuntu and Debian packages
  6. Fedora, CentOS Stream, Rocky and AlmaLinux
  7. macOS
  8. Windows with WSL
  9. Verify with ad-hoc commands
  10. What broke when I ran this
  11. Next steps

1. What you are installing and where

Ansible is agentless. You install it once on the control node, and it talks to managed nodes over SSH (or WinRM for Windows targets). The managed node needs a Python interpreter to run the modules Ansible copies over, with the exception of network modules (installation guide).

Decision chart for choosing an Ansible install route by operating system and Python version
Which Ansible install route should I use

There are two PyPI packages, and the difference matters:

PackageWhat it containsMy install sizeUse it when
ansible-coreThe engine, the ansible* commands and only the ansible.builtin modules73 MB of site-packagesYou want a minimal control node and will pick collections yourself
ansibleansible-core plus the community collection bundle549 MB of site-packages, 101 lines in ansible-galaxy collection listYou want the batteries included for a first install

Both sizes are what I measured in a fresh Python 3.11 venv on 2026-11-03 (Ansible 12.3.0 and ansible-core 2.19.15). If you are following my Ansible full course, install the full ansible package, because later lessons use modules from community collections.

2. Pick the route

Where you run AnsibleRouteCommandSource
UbuntuLaunchpad PPAsudo add-apt-repository --yes --update ppa:ansible/ansible then sudo apt install ansibledistro guide
DebianMain repo, or the Ubuntu PPA for newer versionssee section 5distro guide
FedoraStandard repossudo dnf install ansibledistro guide
CentOS Stream, Rocky, AlmaLinuxEPEL, then the same dnf commandenable EPEL, sudo dnf install ansibledistro guide
Any Linux or macOSpippython3 -m pip install --user ansibleinstallation guide
Any system where pip refusespipxpipx install --include-deps ansibleinstallation guide
WindowsWSL, then a Linux routewsl --installWindows guide

My recommendation: use a venv or pipx everywhere you can. OS packages lag behind, and a venv lets you keep several Ansible versions side by side.

3. Install with pip in a venv (Linux and macOS)

This is the route I used for everything below. The official guide installs with python3 -m pip install --user ansible; a venv does the same job without touching your system Python.

1python3 -m venv ansible-env
2source ansible-env/bin/activate
3pip install ansible
4ansible --version

Here is the real output, from Ansible 12.3.0 on 2026-11-03 (UTC), Python 3.11.18:

 1$ ansible --version
 2ansible [core 2.19.15]
 3  config file = None
 4  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
 5  ansible python module location = /tmp/w/ans/v/lib/python3.11/site-packages/ansible
 6  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
 7  executable location = ./v/bin/ansible
 8  python version = 3.11.18 (main, Oct 26 2026, 15:28:55) [GCC 13.3.0] (/tmp/w/ans/v/bin/python3)
 9  jinja version = 3.1.6
10  pyyaml version = 6.0.3 (with libyaml v0.2.5)

Two lines in that block are worth reading. config file = None means no ansible.cfg was found, which is normal on a fresh install. python version tells you which interpreter the control node is using, and that is the line that explains the trap in section 10.

To see both package versions at once:

1$ pip list | grep -i ansible
2ansible      12.3.0
3ansible-core 2.19.15

To upgrade later, add --upgrade to the same command. To install only the engine, use pip install ansible-core (installation guide).

4. Install with pipx

Some distributions mark the system Python as externally managed, so a plain pip install is refused. The official guide's answer is pipx, which gives each application its own venv and puts the commands on your PATH:

1pipx install --include-deps ansible
2pipx upgrade --include-injected ansible

--include-deps is the flag the official guide uses so that the commands from the dependencies, such as ansible-playbook from ansible-core, land on your PATH (installation guide). To add a Python library that a module needs, use pipx inject ansible <package>. I did not run pipx for this post, so I am only quoting the documented commands here; the venv route above is the one I verified.

5. Ubuntu and Debian packages

Ubuntu users get newer builds from the Ansible PPA than from the standard repositories (distro guide):

1sudo apt update
2sudo apt install software-properties-common
3sudo add-apt-repository --yes --update ppa:ansible/ansible
4sudo apt install ansible

Debian can install from its main repository, but the guide warns the version can be outdated. For a newer one you add the Ubuntu PPA by hand, using the Ubuntu codename that matches your release: Debian 13 maps to Ubuntu 24.04 (noble), Debian 12 to 22.04 (jammy) and Debian 11 to 20.04 (focal). The apt-key add approach is deprecated, so store the signing key under /usr/share/keyrings/ as the guide shows.

The old advice of passing --allow-unauthenticated to get past a repository error is something I now avoid. If the PPA does not publish a Release file for your Ubuntu codename, remove it with sudo apt-add-repository --remove ppa:ansible/ansible and use the pip route instead.

6. Fedora, CentOS Stream, Rocky and AlmaLinux

On Fedora both packages live in the standard repositories (distro guide):

1sudo dnf install ansible        # full package
2sudo dnf install ansible-core   # minimal package

On CentOS Stream, AlmaLinux and Rocky Linux enable the community-maintained EPEL repository first, then use the same dnf commands. The old yum install epel-repo and make rpm recipes from older tutorials, including the first version of this post, are no longer what the project documents. If you land on the error Cannot retrieve Metalink for repository: epel, the mirror list could not be reached: check DNS and the proxy settings on the host, and fall back to the pip route.

7. macOS

The official installation guide lists macOS as a supported control node and the install method is the same pip or pipx route as Linux, so run section 3 in Terminal. Homebrew also carries an ansible formula (brew install ansible), which I did not test for this post. If you hit AttributeError: 'module' object has no attribute '_vendor', you are running a very old Python or pip; create a venv with a current python3 and reinstall.

8. Windows with WSL

Windows is not supported as a control node. The Windows guide says Ansible cannot run on Windows as the control node due to API limitations, but you can use the Windows Subsystem for Linux or a container (Windows guide). From an elevated PowerShell:

1wsl --install
2wsl --list --online
3wsl --install -d Ubuntu

Create your Linux user when prompted, then open the Ubuntu shell and follow section 3 or section 5 inside it. Windows machines can still be managed targets: ansible-core supports Windows PowerShell 5.1 on targets out of the box.

9. Verify with ad-hoc commands

The first checks I run on any new control node are the built-in ping module and a couple of harmless commands against the implicit localhost. Output from Ansible 12.3.0 (ansible-core 2.19.15) on 2026-11-03 (UTC):

 1$ ansible localhost -m ping
 2[WARNING]: No inventory was parsed, only implicit localhost is available
 3localhost | SUCCESS => {
 4    "changed": false,
 5    "ping": "pong"
 6}
 7$ ansible localhost -a "uptime"
 8localhost | CHANGED | rc=0 >>
 9 14:12:24 up 2 min,  0 user,  load average: 0.66, 0.23, 0.08
10$ ansible localhost -a "df -h /"
11localhost | CHANGED | rc=0 >>
12Filesystem      Size  Used Avail Use% Mounted on
13/dev/vda        252G  9.6G   29G  25% /

pong means the control node could find a Python interpreter and run a module. The -u root flag from the older version of this post is not needed for localhost; I ran the same command with and without it and got identical results. Note the difference between SUCCESS (nothing changed) and CHANGED (the command ran): the command module always reports CHANGED because Ansible cannot know whether uptime changed anything.

To go beyond localhost, write a small inventory file. This one points at the local machine through the local connection:

1all:
2  hosts:
3    local1:
4      ansible_connection: local
1$ ansible all -i inv.yml -m ping
2[WARNING]: Host 'local1' is using the discovered Python interpreter at '/usr/local/bin/python3.13', but future installation of another Python interpreter could cause a different interpreter to be discovered. See https://docs.ansible.com/ansible-core/2.19/reference_appendices/interpreter_discovery.html for more information.
3local1 | SUCCESS => {
4    "ansible_facts": {
5        "discovered_interpreter_python": "/usr/local/bin/python3.13"
6    },
7    "changed": false,
8    "ping": "pong"
9}

That warning is Ansible telling you it guessed the managed node's Python. Pin it with ansible_python_interpreter in the inventory when you want to silence it. For real servers you also need passwordless SSH keys; I cover that in Ansible SSH keys for server management, and the inventory, hosts and roles layout in Ansible roles, inventory and tasks.

10. What broke when I ran this

Everything below happened on 2026-11-03 while preparing this post.

1. The Python version trap. My venv used Python 3.11.18, and pip install ansible happily installed Ansible 12.3.0 with ansible-core 2.19.15. When I tried to fetch a newer core explicitly, pip refused:

1$ pip download ansible-core==2.21.6 --no-deps
2ERROR: Ignored the following versions that require a different python version: 2.20.0 Requires-Python >=3.12; ... 2.21.6 Requires-Python >=3.12; ... 2.22.0 Requires-Python >=3.13
3ERROR: Could not find a version that satisfies the requirement ansible-core==2.21.6

(I trimmed the middle of that list.) Nothing failed, which is the trap: pip silently resolved the newest release that fits your interpreter, so you can run an old release for months without noticing. The fix is to check the python version line in ansible --version and, if you want a current release, create the venv with Python 3.12 or newer. The support matrix lists control node Python 3.12 to 3.14 for ansible-core 2.20 and 2.21, and 3.13 to 3.15 for 2.22 (release and maintenance). Each ansible-core release supports the three most recent Python versions, and by the same table ansible-core 2.19, the one I got, has security fixes only until 18 May 2026 and reaches end of life in November 2026 (this month, as I write), so I would not start a new project on it.

2. ssh is not part of Ansible. When I pointed the default SSH connection at an unreachable name from a machine without an OpenSSH client, the failure was not a network error at all:

1[ERROR]: Task failed: Unable to execute ssh command line on a controller: [Errno 2] No such file or directory: b'ssh'
2Origin: <adhoc 'ping' task>

Ansible shells out to the ssh binary, so install openssh-client on the control node before you test against remote hosts.

3. The empty-inventory warning is not an error. [WARNING]: No inventory was parsed, only implicit localhost is available appears on every run without -i. It is harmless for a smoke test, but if you see Could not match supplied host pattern, ignoring for a host you expected, your inventory file is not being read: check the -i path.

4. Deprecated flags. I used -o for one-line output, and ansible-core 2.19.15 printed a deprecation warning that the flag will be removed in 2.23. Old tutorials, including mine, still show it.

Cost and trade-off: the ansible-core 2.19.15 wheel I downloaded is 2.4 MB (2,427,065 bytes) and the 73 MB figure is after its dependencies are installed, while the full ansible package lands at 549 MB, roughly 7.5 times larger. If you only run ansible.builtin modules, take ansible-core and add collections with ansible-galaxy collection install.

11. Next steps

Once ansible --version and the ping work, watch the companion video or pick a path: the video index lists every Ansible lesson, and the Ansible full course takes you from this install to production roles. Package details are on PyPI.

Did this save you a debugging session? Stay in the loop -