๐ How to Install and Configure Ansible on Linux 6.10 โ Step-by-Step Guide

Managing multiple servers manually can be slow, repetitive, and prone to errors. This is where Ansible helps โ an automation tool that lets you configure and manage servers efficiently.
In this guide, Iโll show you how to install and configure Ansible on Linux 6.10, step by step, including master and slave setup.
โ Prerequisites
One Master Server (Linux 6.10)
One or more Slave Servers (Linux 6.10)
SSH access between master and slaves
Root user access on all servers
๐ ๏ธ Step 1: Set Hostnames
On the Master Server:
hostnamectl set-hostname master
passwd root
On Each Slave Server:
hostnamectl set-hostname slave1 # Change slave1 to your desired name
passwd root
๐ ๏ธ Step 2: Install Python3 and Pip on Master
Ansible requires Python to run. Install Python3 and Pip:
sudo yum install python3 -y
sudo yum install python3-pip -y
python3 --version
pip3 --version
๐ ๏ธ Step 3: Install Ansible on Master
pip3 install --user ansible
ansible --version
๐ ๏ธ Step 4: Setup Ansible Configuration
4.1 Navigate to Ansible directory:
cd /etc/ansible
If the directory does not exist:
sudo mkdir -p /etc/ansible
cd /etc/ansible
Execute below command inside the ansible folder it will create ansible.cfg
ansible-config init --disabled -t all > ansible.cfg
4.3 Edit the configuration file:
sudo nano ansible.cfg
Ensure this line is set:
If it is commented remove the comment
inventory = /etc/ansible/hosts
๐ ๏ธ Step 5: Configure the Inventory File
Check if the hosts file exists:
ls /etc/ansible/hosts
If not, create it:
sudo nano /etc/ansible/hosts
Example content:
[dev]
192.168.1.101
192.168.1.102
[test]
192.168.1.103
Replace these IPs with your actual slave IP addresses.
๐ ๏ธ Step 6: Enable SSH Root Access
Ansible connects to slaves via SSH. Update SSH settings on all servers (master and slaves):
sudo nano /etc/ssh/sshd_config
Set these values:
PermitRootLogin yes
PasswordAuthentication yes
Restart SSH:
sudo systemctl restart sshd
๐ ๏ธ Step 7: Setup SSH Key Authentication from Master
7.1 Generate SSH Key:
ssh-keygen
7.2 Copy the SSH key to each slave:
ssh-copy-id root@<slave_ip>
This enables passwordless SSH access, which Ansible requires.
๐ ๏ธ Step 8: Test Ansible Connection
Run this command on the master:
ansible all -m ping
If everything is set correctly, you should see:
pong
from each slave server.
โ Checks on Slaves
On each slave, make sure the root password is set:
hostnamectl set-hostname slavename
passwd root
nano /etc/ssh/sshd_config
1.PermitRootLogin yes
2.PasswordAuthentication yes
After changeing the password authentication change then restart the sshd.
systemctl restart sshd
Also, confirm the SSH settings again and restart the SSH service:
๐ Conclusion
Thatโs it! You have successfully installed and configured Ansible on Linux 6.10. You are now ready to automate tasks and manage multiple servers easily.
Subscribe to my newsletter
Read articles from Vinuthna directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Vinuthna
Vinuthna
Why Collaborate with Me? ~ Infrastructure as Code (IaC): Skilled in automating infrastructure provisioning with Terraform and Ansible, ensuring consistency, scalability, and repeatability. ~ Containerization & Orchestration: Expert in building, managing, and scaling containerized applications using Docker and Kubernetes clusters. ~ CI/CD Expertise: Proficient in designing and optimizing Jenkins pipelines for seamless code integration, testing, and deployment workflows. ~ Linux Systems Mastery: Strong background in Linux system administration, scripting, performance tuning, and server management. ~ Automation Enthusiast: Adept at automating repetitive tasks and complex workflows with Ansible, shell scripting, and YAML-driven configurations. ~ Problem Solver: Quick to learn emerging technologies, troubleshoot complex issues, and optimize systems for maximum reliability and efficiency. ~ Detail-Oriented: Committed to delivering clean, secure, and high-quality solutions that meet both business and technical goals. Core Competencies ~ DevOps Tools: Jenkins, Docker, Kubernetes, Ansible, Terraform, Git, Bitbucket, YAML ~ Infrastructure as Code: Terraform, Ansible ~ Containerization and Orchestration: Docker, Kubernetes ~ Continuous Integration/Continuous Deployment: Jenkins Pipelines, GitOps workflows ~ Operating Systems: Linux (Ubuntu, CentOS) ~ Scripting: Shell scripting, YAML ~ Monitoring & Logging: (Optional, if you know Prometheus, Grafana, or similar tools.) ~ Project Management: Jira, Slack, Agile Methodologies