How to Install Ansible on Ubuntu 20.04

Install Ansible on Ubuntu 20.04

In this article, we will have explained the necessary steps to install and configure Ansible on Ubuntu 20.04 LTS. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

Ansible is a free and open-source Configuration and automation tool for UNIX like operating system. It is written in python and similar to Chef or Puppet but there is one difference and advantage of Ansible is that we don’t need to install any agent on the nodes. It uses SSH for making communication to its nodes.

Install Ansible on Ubuntu 20.04

Step 1. First, before you start installing any package on your Ubuntu server, we always recommend making sure that all system packages are updated.

Step 2. Install Ansible on Ubuntu system.

You can simply install ansible by executing the command below:

Once the installation is finished, check the Ansible version using the following command:

Step 3. Setup Ansible Inventory.

By default, the Ansible has an inventory configuration file on the ‘/etc/ansible’ directory. Also, you can create a custom inventory file for your environment, and call it with the ‘-i’ option on the ansible command:

Once done, you can check the inventory using the following command:

Step 4. Test Ansible Connection.

We will test to ping all hosts and make sure all hosts replying with the pong message:

You will get an output similar to the one below:

That’s all you need to do to install Ansible on Ubuntu 20.04 Focal Fossa. I hope you find this quick tip helpful. If you have questions or suggestions, feel free to leave a comment below.