Installing Ansible on Ubuntu 22.04#

Ansible is a great tool for automating tasks on multiple servers. It is easy to learn and use and it is very powerful. Ansible is written in Python and it uses SSH to connect to the servers or devices you want to manage like routers, switches, etc. There needs to be a central server where Ansible is installed and from there you can manage all your servers or devices.

In this post, we will create that central server and install Ansible on Ubuntu 22.04 from the official Ubuntu repositories or from the Ansible PPA repositories depending on your needs. The first step is to update the system to the latest packages so that we can install Ansible from the official Ubuntu repositories.

Update Ubuntu 22.04 to the latest packages#
$ sudo apt update
$ sudo apt upgrade -y

Note

Ubuntu 22.04 comes with Ansible 2.10 but for a more recent version, you can add the Ansible PPA to your system.

Add Ansible PPA to Ubuntu 22.04#
$ sudo apt install -y software-properties-common
$ sudo add-apt-repository --yes --update ppa:ansible/ansible

To use the Ansible PPA, you need to install the software-properties-common package which provides the add-apt-repository command.

The next step is to install Ansible on Ubuntu 22.04 and we can do that with the following command so that we can manage our servers or devices. The Ansible package will install all the dependencies needed to run Ansible on Ubuntu 22.04, but in some cases you might need to install additional packages depending on your needs.

Install Ansible on Ubuntu 22.04#
$ sudo apt install -y ansible

Now that Ansible is installed on Ubuntu 22.04, we can check the version of Ansible to make sure that it is installed correctly.

Check Ansible version#
$ ansible --version
ansible [core 2.14.6]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/sysadmin/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /home/vivek/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.10.6 (main, May 29 2023, 11:10:38) [GCC 11.3.0] (/usr/bin/python3)
  jinja version = 3.0.3
  libyaml = True

As you can see, Ansible is installed on Ubuntu 22.04 and we can start using it to manage our servers or devices.