Skip to main content

Ansible Installation Guide for Ubuntu 24.04

Introduction​

This guide provides step-by-step instructions for installing Ansible on Ubuntu 24.04 LTS (Noble Numbat). Ansible is an open-source automation tool that simplifies configuration management, application deployment, and task automation.

Prerequisites​

  • Ubuntu 24.04 LTS system
  • User with sudo privileges
  • Internet connection

Installation Methods​

There are several ways to install Ansible on Ubuntu 24.04. This guide covers the three most common methods:

  1. Using APT (recommended)
  2. Using PIP (Python package manager)
  3. Using Ansible PPA

Installing Ansible using APT

# Update package index
sudo apt update

# Install required dependencies
sudo apt install -y software-properties-common

# Install Ansible
sudo apt install -y ansible

Verify the installation:

ansible --version

Basic Configuration​

Creating an Inventory File​

Create a basic inventory file to define your managed hosts:

sudo mkdir -p /etc/ansible
sudo nano /etc/ansible/hosts

Add your hosts to the inventory file:

[webservers]
web1.example.com
web2.example.com

[dbservers]
db1.example.com
db2.example.com

Testing Ansible​

Test Ansible with a simple ping command:

# For all hosts in inventory
ansible all -m ping

# For a specific group
ansible webservers -m ping

Troubleshooting​

Common Issues​

  1. Command not found error:

    • Ensure Ansible is installed correctly
    • Check if the installation path is in your PATH variable
  2. SSH connection issues:

    • Verify SSH keys are set up correctly
    • Check if the target hosts are reachable
  3. Permission denied errors:

    • Ensure your user has sudo privileges
    • Check file permissions for Ansible configuration files

Upgrading Ansible​

To upgrade an existing Ansible installation:

# If installed via APT
sudo apt update
sudo apt upgrade ansible

# If installed via PIP
pip3 install --upgrade ansible

Uninstalling Ansible​

To remove Ansible from your system:

# If installed via APT
sudo apt remove ansible

# If installed via PIP
pip3 uninstall ansible

Additional Resources​

Conclusion​

You have successfully installed Ansible on Ubuntu 24.04. You can now begin automating your infrastructure management tasks.