Day 1: Ansible Installation and SSH Connection Setup

Table of contents
- Ansible Installation on Master Node:
- Architecture:
- Access the master node:
- Generate SSH key pairs:
- Display the public key:
- Access the child node:
- Edit the authorized_keys file:
- SSH into the master node from the child node:
- Update the child node:
- Install Ansible on the master node:
- Verify the Ansible installation:
- Configuring SSH Connections in Ansible:
- Edit the inventory file:
- Define groups and add child nodes' IPs or hostnames:
- Test the SSH connection to all nodes:
- Additional Reference:

Ansible Installation on Master Node:
Architecture:
Access the master node:
Copy codecd ~/.ssh
Generate SSH key pairs:
ssh-keygen
Display the public key:
cat id_rsa.pub
Copy the displayed key (id_rsa.pub) and paste it on the child node.
Access the child node:
cd ~/.ssh
Edit the authorized_keys file:
vi authorized_keys
Paste the master node's public key into the authorized_keys file.
SSH into the master node from the child node:
ssh username@child_node_ip
Update the child node:
sudo apt -y update
Install Ansible on the master node:
sudo apt install software-properties-common sudo apt-add-repository --yes --update ppa:ansible/ansible sudo apt install ansible
Verify the Ansible installation:
ansible --version
Configuring SSH Connections in Ansible:
Navigate to the Ansible configuration directory:
cd /etc/ansible
Edit the inventory file:
vi hosts
Define groups and add child nodes' IPs or hostnames:
[group_name] child_node_ip_or_hostname
Save and exit the file.
Test the SSH connection to all nodes:
ansible group_name -m ping
Display the inventory in YAML format:
ansible-inventory --list --yaml
Additional Reference:
- Ansible Installation Guide:https://docs.ansible.com/ansible/latest/installation_guide/installation_distros.html#installing-ansible-on-ubuntu
This comprehensive guide covers the installation of Ansible on both the master and child nodes, setting up SSH connections, and verifying the setup. Replace group_name
, child_node
, child_node_ip
, and your_username
with your actual details. This ensures a seamless and secure Ansible configuration for effective server management.
Subscribe to my newsletter
Read articles from AQIB HAFEEZ directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

AQIB HAFEEZ
AQIB HAFEEZ
DevOps Engineer, Linux, Git, GitHub, GitLab, CI/CD pipelines, Jenkins, Docker, Kubernetes, Ansible & AWS. Practical experience in these DevOps tools enhances my passion for streamlined workflows, automated processes, and holistic development solutions. Proficient in digital and Facebook marketing, aiming to merge technical acumen with marketing finesse.