Introduction
Ansible is an open-source automation tool that simplifies IT operations such as configuration management, application deployment, and task automation. In this guide, we’ll walk through how to:
- Install Ansible on an Ubuntu Control Node
- Set up an Ubuntu Target Node
- Establish passwordless SSH connectivity
- Run your first Ansible command
Key Features:
- Agentless: Ansible does not require any agent software to be installed on the nodes it manages. It uses SSH for communication.
- Easy to Learn: Ansible uses a simple syntax written in YAML called playbooks.
- Idempotency: Ansible ensures that changes are applied only when necessary, making it safe to run multiple times without causing unintended effects.
- Extensible: Ansible modules can be written in any language that can return JSON.
- Scalable: Ansible can manage small environments to large-scale deployments.
Python must be installed on both the control node and the managed (target) nodes before you install and use Ansible.
Step 1: Install Ansible on the Control Node
🔹 1. Update Your System
sudo apt update
sudo apt upgrade -y
🔹 2. Add Ansible Repository
sudo apt install software-properties-common -y
sudo add-apt-repository --yes --update ppa:ansible/ansible
🔹 3. Install Ansible
sudo apt install ansible -y
🔹 4. Verify Installation
ansible –version

Step 2: Set Up SSH Access to the Target Node
Ansible connects to target machines using SSH. For this, we’ll set up key-based authentication.
🔹 1. Generate an SSH Key on the Control Node
ssh-keygen

Keep pressing Enter to accept default options. This creates:
- Private key:
~/.ssh/id_rsa
- Public key:
~/.ssh/id_rsa.pub
🔹 2. Copy the SSH Key to the Target Node
$ ssh-copy-id username@target_node_ip
Example:
$ ssh-copy-id ubuntu@192.168.1.8
🔹 3. Test SSH Connection
$ ssh ubuntu@192.168.1.8

📁 Step 3: Configure the Ansible Inventory File
🔹 1. Open Inventory File
$ sudo nano /etc/ansible/hosts
🔹 2. Add Target Node Entry
[target_nodes]
192.168.1.20 ansible_user=ubuntu

🧪 Step 4: Test Ansible Connection to the Target Node
$ ansible target_nodes -m ping
output:
192.168.1.8 | SUCCESS => {
"changed": false,
"ping": "pong"
}
- Jenkins Monitoring with Prometheus and Grafana - July 21, 2025
- Cursor AI: Why use Cursor AI? - July 9, 2025
- Grafana Setup - June 30, 2025