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 withsudo privileges
• Internet connection
Method 1: Install Ansible Using apt (Recommended)
Step 1: Update System Packages
sudo apt update && sudo apt upgrade -y
Step 2: Install the Software Properties Common Package
sudo apt install -y software-properties-common
Step 3: Add the Ansible PPA
sudo add-apt-repository --yes --update ppa:ansible/ansible
Step 4: Install Ansible
sudo apt install -y ansible
Step 5: Verify the Installation
ansible --version
Expected 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.x
See also: Installing Ansible: A Step-by-Step Guide
Method 2: Install Ansible Using pip
Step 1: Install Python3 and pip
sudo apt install -y python3 python3-pip python3-venv
Step 2: Create a Virtual Environment (Recommended)
python3 -m venv ~/ansible-venv
source ~/ansible-venv/bin/activate
Step 3: Install Ansible via pip
pip install ansible
Step 4: Verify the Installation
ansible --version
Verify Ansible Works
Test connectivity to localhost:
ansible localhost -m ping
Expected output:
localhost | SUCCESS => {
"changed": false,
"ping": "pong"
}
See also: Ansible on Ubuntu 20.04 LTS: Docker CE Installation Complete Guide
Troubleshooting
Error: "add-apt-repository: command not found"
Install the required package:
sudo apt install -y software-properties-common
Error: "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/python3
Uninstall Ansible
If installed via apt:
sudo apt remove --purge ansible -y
If installed via pip:
pip uninstall ansible ansible-core -y
FAQ
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
• How to Install Ansible on Ubuntu 25.04 • How to Install Ansible on Ubuntu 24.04 • Ansible Extra Vars: Pass Variables via Command Line • What is Ansible? A Complete GuideCategory: installation