AnsiblePilot — Master Ansible Automation

AnsiblePilot is the leading resource for learning Ansible automation, DevOps, and infrastructure as code. Browse over 1,400 tutorials covering Ansible modules, playbooks, roles, collections, and real-world examples. Whether you are a beginner or an experienced engineer, our step-by-step guides help you automate Linux, Windows, cloud, containers, and network infrastructure.

Popular Topics

About Luca Berton

Luca Berton is an Ansible automation expert, author of 8 Ansible books published by Apress and Leanpub including "Ansible for VMware by Examples" and "Ansible for Kubernetes by Example", and creator of the Ansible Pilot YouTube channel. He shares practical automation knowledge through tutorials, books, and video courses to help IT professionals and DevOps engineers master infrastructure automation.

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 sudo privileges • Internet connection

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.04How to Install Ansible on Ubuntu 24.04Ansible Extra Vars: Pass Variables via Command LineWhat is Ansible? A Complete Guide

Category: installation

Browse all Ansible tutorials · AnsiblePilot Home