Installing Ansible on Ubuntu

Quick post to run through Ansible installation on an Ubuntu OS.

· 2 min read
Installing Ansible on Ubuntu

Ansible is an open-source configuration management and automation tool. It allows you to define your infrastructure as code, and automate the provisioning and deployment of applications and services.


  • A running instance of Ubuntu 18.04 or later
  • SSH access to the Ubuntu system
  • Sudo privileges on the Ubuntu system

Step 1: Install Python

Ansible is a Python-based tool, so you'll need to have Python installed on your Ubuntu system. You can check if Python is already installed by running the following command:

python3 --version

If Python is not installed, you can install it using the following command:

sudo apt-get update && sudo apt-get install python3 -y

Step 2: Install Ansible

To install Ansible on Ubuntu, you'll need to add the Ansible repository to your system and then install the ansible package. You can do this using the following commands:

sudo apt-add-repository ppa:ansible/ansible
sudo apt-get update
sudo apt-get install ansible -y

Step 3: Verify Installation

You can verify that Ansible was installed correctly by running the following command, which will print the version number of Ansible:

ansible --version

Step 4: Configure SSH Access

Ansible uses SSH to connect to remote systems, so you'll need to make sure that your Ubuntu system has SSH access to any systems that you want to manage with Ansible. You can check if SSH is already configured by running the following command:

ssh <username>@<remote-host>

If you're able to successfully connect to the remote host, then SSH is properly configured. If not, you'll need to set up SSH key-based authentication between your Ubuntu system and the remote host.

Step 5: Run a Playbook

A playbook is a file containing instructions for Ansible to execute. Here's an example of a simple playbook that prints "Hello, World!" on a remote host:

- hosts: all
    - name: Print hello world
        msg: "Hello, World!"

Save this code to a file called playbook.yml. Then, you can run the playbook using the following command:

ansible-playbook playbook.yml

This will connect to all hosts specified in the playbook (in this case, all hosts), and execute the task defined in the playbook (printing "Hello, World!").

In this blog post, we covered how to install Ansible on an Ubuntu system. With Ansible installed, you can now use it to automate your infrastructure and application deployment tasks.