Install Ansible on ubuntu 18.04

Ansible is a configuration management tool, an automation engine that automates software provisioning and application deployment.

Prerequisites :

Ansible Control Node

Ansible Slave Nodes

Step 1 — Installing Ansible

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

Step 2 — Setting Up the Inventory File

To edit the contents of your default Ansible inventory, open the /etc/ansible/hosts file using your text editor of choice, on your Ansible Control Node:

sudo vi /etc/ansible/hosts

Add lines given below

[nodes]
node1 10.0.1.3
node2 10.0.1.4

[all:vars]
ansible_python_interpreter=/usr/bin/python3
  • these node ip may be different in your case

Step 3 — Testing Connection

After setting up the inventory file to include your servers, it’s time to check if Ansible is able to connect to these servers and run commands via SSH

ansible all -m ping -u root

Output should be like this

node1 | SUCCESS => {
    "changed": false, 
    "ping": "pong"
}
node2 | SUCCESS => {
    "changed": false, 
    "ping": "pong"
}