Introduction

Ansible is a powerful tool for automating IT tasks, and installing it on Ubuntu 23.10 is a straightforward process. This article will guide you through the steps to install Ansible on a Ubuntu system, based on a real-world example from a remote SSH session.

Prerequisites

Before you begin, ensure that you have:

  • Access to a terminal.
  • Sudo privileges on your Ubuntu system.

In this guide, we’ll connect remotely to an Ubuntu server using SSH. The Ubuntu version we are working with is Ubuntu 23.10.

Step 1: Connecting to the Ubuntu Server

First, establish an SSH connection to your Ubuntu server:

Once connected, you’ll be greeted with the Ubuntu welcome message, confirming that you are running Ubuntu 23.10.

Welcome to Ubuntu 23.10 (GNU/Linux 6.5.0-14-generic aarch64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Tue Jan 23 02:45:47 PM UTC 2024

  System load:  0.03              Processes:               206
  Usage of /:   41.8% of 9.75GB   Users logged in:         0
  Memory usage: 6%                IPv4 address for ens160: 192.168.246.144
  Swap usage:   0%

42 updates can be applied immediately.
To see these additional updates run: apt list --upgradable

Last login: Tue Jan 23 14:40:48 2024
devops@ubuntu:~$

Step 2: Checking for Ansible

Before installing Ansible, it’s a good practice to check if it’s already installed:

ansible

If Ansible is not installed, Ubuntu’s package manager will suggest installing it through apt install ansible-core.

Command 'ansible' not found, but can be installed with:
apt install ansible-core

Step 3: Installing Ansible

Now, proceed with the installation:

  1. Update the package list to ensure you get the latest version available:
sudo apt update
  1. Install Ansible using apt:
sudo apt install ansible

During the installation, you’ll see a list of additional packages that will be installed along with Ansible. These dependencies are necessary for Ansible’s optimal performance.

  1. Confirm the installation by pressing Y when prompted.

The installation process will retrieve and install Ansible along with its dependencies. You’ll see progress as each package is downloaded and installed.

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  ansible-core ieee-data python3-argcomplete python3-distutils python3-dnspython
  python3-jmespath python3-kerberos python3-lib2to3 python3-libcloud python3-lockfile
  python3-netaddr python3-ntlm-auth python3-packaging python3-passlib
  python3-requests-kerberos python3-requests-ntlm python3-requests-toolbelt
  python3-resolvelib python3-selinux python3-simplejson python3-winrm python3-xmltodict
Suggested packages:
  cowsay sshpass python3-trio python3-aioquic python3-h2 python3-httpx python3-httpcore
  python-lockfile-doc ipython3 python-netaddr-docs
The following NEW packages will be installed:
  ansible ansible-core ieee-data python3-argcomplete python3-distutils
  python3-dnspython python3-jmespath python3-kerberos python3-lib2to3 python3-libcloud
  python3-lockfile python3-netaddr python3-ntlm-auth python3-packaging python3-passlib
  python3-requests-kerberos python3-requests-ntlm python3-requests-toolbelt
  python3-resolvelib python3-selinux python3-simplejson python3-winrm python3-xmltodict
0 upgraded, 23 newly installed, 0 to remove and 41 not upgraded.
Need to get 22.2 MB of archives.
After this operation, 302 MB of additional disk space will be used.
Do you want to continue? [Y/n]
Join 50+ hours of courses in our exclusive community

Step 4: Verifying the Installation

After the installation completes, verify that Ansible is installed correctly:

ansible --version

This command will display the installed version of Ansible, along with details about its configuration, module search path, Python version, and more.

ansible [core 2.14.9]
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.11.6 (main, Oct  8 2023, 05:06:43) [GCC 13.2.0] (/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True

Conclusion

You have successfully installed Ansible on Ubuntu 23.10. With Ansible installed, you can begin automating your IT infrastructure, managing configurations, and executing tasks across a network of machines. Whether you’re a system administrator, a DevOps professional, or just exploring infrastructure automation, Ansible offers a wealth of capabilities to streamline and automate your workflows.

Subscribe to the YouTube channel, Medium, and Website, X (formerly Twitter) to not miss the next episode of the Ansible Pilot.

Academy

Learn the Ansible automation technology with some real-life examples in my Udemy 300+ Lessons Video Course.

BUY the Complete Udemy 300+ Lessons Video Course

My book Ansible By Examples: 200+ Automation Examples For Linux and Windows System Administrator and DevOps

BUY the Complete PDF BOOK to easily Copy and Paste the 250+ Ansible code

Want to keep this project going? Please donate

Patreon Buy me a Pizza