How to Install Ansible in Ubuntu 22.04 LTS (Jammy Jellyfish)

Hello techies, as we know that Ansible is the most popular automation and configuration tool available for all Linux distributions. Ansible is free and opensource software which is used to configure mange remote Linux and Windows hosts.

One of the benefits of using Ansible as automation tool is that we don’t need to install any agent on remote systems which we want to manage via ansible. It works on ssh protocol (or port 22).

In this guide, we will cover to install ansible in Ubuntu 220.04 LTS (Jammy Jellyfish) system. For the demonstration, we are using following lab

  • Ubuntu 22.04 as Ansible Control Node (
  • Rocky Linux 8 as Managed Host (
  • sysadm as sudo user with admin privileges.

Without any further delay, let’s begin with ansible installation.

1 ) Update System Package Cache

Run beneath command to make system package cache up to date,

$ sudo apt update

2) Install Ansible with Apt Command

Ansible and its dependencies are available in the default package repositories of Ubuntu 22.04. So, its installation is straight forward.

Run following command to verify available Ansible version

$ sudo apt-cache policy ansible


Execute following apt command to install ansible.

$ sudo apt install -y ansible

Once Ansible is installed, verify its version by running

$ ansible --version


3) Test Ansible Installation

To test Ansible installation, we will try to manage remote host (Rocky Linux 8 – But before that first generate ssh keys for sysadm user and the copy the ssh keys to remote host so that ansible machine can communicate to remote Linux machine using ssh keys.

$ ssh-keygen
$ ssh-copy-id sysadm@


On remote Linux system, also create the following file with beneath contents

$ echo "sysadm ALL=(ALL) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/sysadm

In Ansible machine (Ubuntu 22.04), create ansible configuration file in present working directory with following content

$ vi ansible.cfg
inventory = ./inventory
host_key_checking = false
remote_user = sysadm
ask_pass = False


Save & exit the file.

Create an inventory file with following content.

$ vi inventory

Save & close the file.

Now we are all set to test ansible installation, first verify the connectivity via ping pong test, run

$ ansible lab -m ping


Great, above confirms that our ansible machine can communicate to remote linux system. Let’s create a demo playbook which will install nfs server.

$ vi demo.yaml
- name: Install NFS server on Rocky Linux
  hosts: lab
  - name: Install nfs-utils pkg
      name: nfs-utils
      state: installed

Save & close the file.

Run the play using beneath ansible command

$ ansible-playbook demo.yaml


Above output shows that ansible playbook has been executed successfully, let’s verify whether nfs-utils package is installed on remote system using ansible ad-hoc command,

$ ansible lab -m shell -a 'rpm -qa | grep -i nfs-utils'



Perfect, above output confirms that nfs-utils package is installed on remote rocky linux machine.

That’s all from this guide. Please do share your queries and feedback on below comments section.

Also Read: How to Setup Chroot SFTP Server in Linux

Leave a Comment

3 × five =