Install Ansible on Ubuntu [20.04]

This article demonstrates How to Install and Configure Ansible on Ubuntu 20.04

Ansible on Ubuntu [20.04]

Ansible architecture

How Ansible Work

Prerequisites

Installing Ansible

sudo apt-add-repository ppa:ansible/ansiblesudo apt updatesudo apt install ansible

Add remote host to Inventory File

sudo vim /etc/ansible/hosts
[masters]
master ansible_host=host_ip_1 ansible_user=ansibleuser

[workers]
worker1 ansible_host=host_ip_2 ansible_user=ansibleuser
worker2 ansible_host=host_ip_3 ansible_user=ansibleuser
worker3 ansible_host=host_ip_4 ansible_user=ansibleuser

[all:vars]
ansible_python_interpreter=/usr/bin/python3
ansible-inventory --list -y
all:
children:
masters:
hosts:
master:
ansible_host: host_ip_1
ansible_python_interpreter: /usr/bin/python3
ansible_user: ansibleuser
ungrouped: {}
workers:
hosts:
worker1:
ansible_host: host_ip_2
ansible_python_interpreter: /usr/bin/python3
ansible_user: ansibleuser
worker2:
ansible_host: host_ip_3
ansible_python_interpreter: /usr/bin/python3
ansible_user: ansibleuser
worker3:
ansible_host: host_ip_4
ansible_python_interpreter: /usr/bin/python3
ansible_user: ansibleuser

Test connection

ansible all -m ping -u root
worker3 | SUCCESS => {
"changed": false,
"ping": "pong"
}
worker1 | SUCCESS => {
"changed": false,
"ping": "pong"
}
worker2 | SUCCESS => {
"changed": false,
"ping": "pong"
}
master | SUCCESS => {
"changed": false,
"ping": "pong"
}

Technically savvy, results-driven and goal-focused professional with years of experience, abilities and skill as a technical leader.