Install Ansible on Ubuntu: Complete Guide (22.04, 24.04, 26.04 LTS)
By Luca Berton · Published 2024-01-01 · Category: installation
How to install Ansible on Ubuntu 22.04, 24.04, and 26.04 LTS. Step-by-step installation via apt PPA, pip, and pipx. Configure inventory, test connection, troubleshoot common errors.
Install Ansible on Ubuntu: Complete Guide (22.04, 24.04, 26.04 LTS)
This guide covers every method to install Ansible on Ubuntu, from the quick apt install to the recommended pip/pipx approach for the latest version. Works for Ubuntu 22.04 Jammy, 24.04 Noble, 25.10, and 26.04 LTS.
Quick Install (apt — Fastest Method)
Check the installed version:
Note: The apt repository version may be older than the latest release. For the newest Ansible version, use pip or the PPA method below.
Method 1: Install via PPA (Recommended for apt Users)
The official Ansible PPA provides newer versions than the default Ubuntu repository:
Verify the installation:
Method 2: Install via pip (Recommended for Latest Version)
pip gives you the latest Ansible release and better version control:
Install a Specific Version
Upgrade to Latest Version
Method 3: Install via pipx (Isolated Environment)
pipx installs Ansible in an isolated environment — cleanest option for system-wide use:
Method 4: Install ansible-core Only (Minimal)
If you only need core Ansible without bundled collections:
This installs ansible-playbook, ansible-galaxy, and other core tools but without the 85+ bundled collections.
Post-Installation Setup
1. Configure Inventory
Create your first inventory file:
2. Create ansible.cfg
3. Test the Connection
Expected output:
4. Set Up SSH Keys
Ubuntu Version-Specific Notes
Ubuntu 22.04 LTS (Jammy) • Default apt: Ansible 2.10.x (old) • PPA: Latest stable release • Python 3.10 included • Recommended: Use PPA or pip for current version
Ubuntu 24.04 LTS (Noble) • Default apt: Ansible 9.x • Python 3.12 included • Note: Some pip installs may need --break-system-packages flag or use pipx/venv
Ubuntu 26.04 LTS (Plucky) • Default apt: Ansible 10.x • Python 3.13 included • Recommended: pipx for clean installation
Install Ansible Collections
After installing Ansible, you may need additional collections:
Troubleshooting
"ansible: command not found"
"No module named 'ansible'"
"externally-managed-environment" error (Ubuntu 24.04+)
Permission denied on remote hosts
Uninstall Ansible
FAQ
What is the best way to install Ansible on Ubuntu?
For most users, pipx install ansible or installing in a Python virtual environment gives the latest version with clean isolation. For simplicity, sudo apt install ansible works but may provide an older version.
Can I install Ansible without root on Ubuntu?
Yes. Use python3 -m pip install --user ansible to install in your home directory, or pipx install ansible which also doesn't require root. Only the apt method needs sudo.
What Python version does Ansible need on Ubuntu?
Ansible requires Python 3.10 or newer on the control node. Ubuntu 22.04+ includes Python 3.10+. For managed hosts, Python 3.6+ is sufficient.
Should I install ansible or ansible-core?
Install ansible (the full package) for most use cases — it includes ansible-core plus 85+ collections. Install ansible-core only if you want a minimal installation and will manage collections separately.
How do I update Ansible on Ubuntu?
For apt: sudo apt update && sudo apt upgrade ansible. For pip: pip install --upgrade ansible. For pipx: pipx upgrade ansible.
Conclusion
Install Ansible on Ubuntu with pipx for the cleanest setup, pip in a virtual environment for version control, or apt with the PPA for the latest stable release. After installation, create your inventory file, configure SSH keys, and test with ansible localhost -m ping.
Related Articles • Install Ansible: Complete Guide for Every OS • Install Ansible on Debian 12 Bookworm • Install Ansible on macOS with Homebrew • ansible.cfg Configuration File Guide • Ansible Inventory File: Complete Guide
Category: installation