Introduction
Welcome to Day 55 of my #90DaysOfDevOps journey! Today, we're diving into Configuration Management with Ansible, a powerful tool that's essential for modern DevOps practices. I'll share my hands-on experience setting up Ansible on AWS EC2 instances.
Task Overview
Our goals for today:
Install Ansible on an EC2 instance (Master Node)
Configure the hosts file
Set up worker nodes and establish connectivity
Implementation Steps
1. Installing Ansible
After launching our EC2 instance, I installed Ansible using the following commands:
sudo apt-add-repository ppa:ansible/ansible
sudo apt update
sudo apt install ansible
Here's what the successful installation looks like:
Ansible installation showing various Python dependencies being configured
As we can see, Ansible installed successfully with version [core 2.17.7] and all required dependencies.
2. Configuring the Hosts File
Next, I configured the Ansible inventory file:
[webservers]
node1 ansible_host=<your EC2 Private IP>
node2 ansible_host=<your EC2 Private IP>
[all:vars]
ansible_ssh_private_key_file=/home/ubuntu/.ssh/key.pem
ansible_user=ubuntu
Here's the verification of our inventory setup:
Ansible inventory configuration showing successful node setup and initial ping test
3. AWS EC2 Setup
I set up multiple EC2 instances for this configuration:
AWS Console showing our Ansible master and worker nodes
Key points from the EC2 setup:
ansible1 (Master Node): Running with public IP 52.201.227.157
ansible2 (Worker Node): Running with proper security groups
Both instances are t2.micro, perfect for our testing setup
Key Observations
Installation Process
Multiple Python dependencies were automatically handled
Ansible core 2.17.7 was successfully installed
All required packages were properly configured
Inventory Setup
Successfully configured two nodes
Used private IP addresses for better security
Proper SSH key configuration in place
Connectivity Test
Initial SSH fingerprint verification required
Successful ping response from node1
Python interpreter automatically discovered on remote hosts
Technical Details
From our setup, we can see:
Ansible Configuration
ansible [core 2.17.7] config file = /etc/ansible/ansible.cfg python version = 3.12.3
Node Configuration
Master Node Private IP: 172.31.85.116
Worker Node Private IP: 172.31.85.223
Both running on Ubuntu with proper SSH access
Challenges Faced
SSH Key Management
Had to properly set up key permissions
Required correct path configuration in hosts file
First Connection Issues
Needed to handle SSH fingerprint verification
Resolved Python interpreter warnings
Next Steps
After this successful setup, we can:
Create and implement playbooks
Set up configuration management policies
Automate routine tasks
Implement infrastructure as code
Learning Outcomes
This hands-on experience taught me:
Proper Ansible installation and configuration
AWS EC2 instance management
Network security considerations
SSH key management
Inventory file configuration
Key Takeaways
Always verify installations with
ansible --version
Use private IPs for internal communication
Properly manage SSH keys and permissions
Document and verify inventory configurations
Connect & Share
Found this helpful? Let's connect! Share your Ansible experiences in the comments below.
#90DaysOfDevOps #DevOps #Ansible #AWS #TechLearning #ConfigurationManagement #Trainwithsubham
Happy Learning! Keep pushing forward on your DevOps journey!