How to Install Ansible on Ubuntu 26.04 (Ubiquitous Unicorn)
By Luca Berton · Published 2024-01-01 · Category: installation
Step-by-step guide to install Ansible on Ubuntu 26.04 Ubiquitous Unicorn using apt or pip. Includes verification steps and troubleshooting tips.
How to Install Ansible on Ubuntu 26.04 (Ubiquitous Unicorn)
Learn how to install Ansible on Ubuntu 26.04 "Ubiquitous Unicorn" using two methods: the system package manager (apt) and Python's pip package manager.
See also: Ansible apt Module: Install, Remove & Manage Packages on Debian/Ubuntu
Prerequisites
- Ubuntu 26.04 "Ubiquitous Unicorn" installed and updated
- A user account with
sudoprivileges - Internet connection
Method 1: Install Ansible Using apt (Recommended)
Step 1: Update System Packages
sudo apt update && sudo apt upgrade -yStep 2: Install the Software Properties Common Package
sudo apt install -y software-properties-commonStep 3: Add the Ansible PPA
sudo add-apt-repository --yes --update ppa:ansible/ansibleStep 4: Install Ansible
sudo apt install -y ansibleStep 5: Verify the Installation
ansible --versionExpected output:
ansible [core 2.19.x]
config file = None
configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/bin/ansible
python version = 3.14.xMethod 2: Install Ansible Using pip
Step 1: Install Python3 and pip
sudo apt install -y python3 python3-pip python3-venvStep 2: Create a Virtual Environment (Recommended)
python3 -m venv ~/ansible-venv
source ~/ansible-venv/bin/activateStep 3: Install Ansible via pip
pip install ansibleStep 4: Verify the Installation
ansible --versionSee also: Installing Ansible: A Step-by-Step Guide
Verify Ansible Works
Test connectivity to localhost:
ansible localhost -m pingExpected output:
localhost | SUCCESS => {
"changed": false,
"ping": "pong"
}Troubleshooting
Error: "add-apt-repository: command not found"
Install the required package:
sudo apt install -y software-properties-commonError: "externally-managed-environment"
Ubuntu 26.04 uses PEP 668. Use a virtual environment (Method 2) or install via apt (Method 1).
Multiple Python Versions
If you have multiple Python versions installed, set the interpreter explicitly in your ansible.cfg:
[defaults]
interpreter_python = /usr/bin/python3See also: Ansible on Ubuntu 20.04 LTS: Docker CE Installation Complete Guide
Uninstall Ansible
If installed via apt:
sudo apt remove --purge ansible -yIf installed via pip:
pip uninstall ansible ansible-core -yFAQ
What version of Python does Ubuntu 26.04 use?
Ubuntu 26.04 "Ubiquitous Unicorn" ships with Python 3.14.
Can I install ansible-core only?
Yes, use pip install ansible-core for a minimal installation without community collections.
What is the difference between apt and pip installation?
The apt method installs a system-wide package maintained by Ubuntu/PPA. The pip method gives you the latest version and more control, especially useful in virtual environments.
Related Articles
Category: installation