Today marked a major step in my DevOps journey: I finally dove into Ansible.
As a cloud computing student, I've managed servers manually before, but I knew that to scale, I needed to learn Configuration Management. Here is a breakdown of what I learned today, moving from theory to actually deploying a web server on AWS.
What is Configuration Management?
I learned that configuration management is essentially maintaining computer systems and software in a desired, consistent state. Instead of manually updating 50 servers one by one, you write the configuration once and push it to all of them.Agent vs. Agentless
One of the first things I clarified was the difference between tools like Chef/Puppet and Ansible.
Agent-based (Chef/Puppet): You have to install software (an agent) on every target server to manage it.
Agentless (Ansible): This is what makes Ansible so cool. It uses SSH to connect to servers. If you can SSH into a server, you can manage it with Ansible. No extra installations required on the target nodes!
- The Inventory File (inventory.ini) Ansible needs to know where to run commands. This happens in the inventory.ini file. I learned how to group servers so I can target specific environments.
inventory.ini
[webservers]
ubuntu@54.13.23.32
ubuntu@35.24.245.23
[dbservers]
ubuntu@172.23.24.3
- Passwordless Authentication (The Key to Automation) Since Ansible uses SSH, entering a password for every command would be a nightmare. I set up passwordless authentication using SSH keys:
Generated keys on my VirtualBox Ubuntu machine (Control Node).
Used ssh-copy-id -i key.pem user@ip_address to copy my public key to the AWS EC2 instance.
Now, Ansible can "talk" to the AWS server without manual intervention.
- Ansible Ad-Hoc Commands Before writing full playbooks, I learned about Ad-Hoc commands. These are quick, one-line commands to do something simple.
Ping all servers: ansible all -m ping
Check disk space: ansible webservers -a "df -h"
- The Project: Installing Apache on EC2 For the practical part of my day, I connected my local Ubuntu machine (running on VirtualBox) to an AWS EC2 instance.
Using an ad-hoc command, I updated the package index and installed the Apache web server remotely. Seeing that default Apache page load on the public IP of my EC2 instance was a huge win!
What's Next?
I touched very briefly on Playbooks today. I know they are used for configuring large numbers of instances and complex workflows, so that is my goal for tomorrow.
Have you used Ansible? Let me know your favorite ad-hoc command in the comments!
linkedin :https://www.linkedin.com/in/dasari-jayanth-b32ab9367/
github :https://github.com/JayanthDasari7?tab=repositories
medium :https://medium.com/@jayanthkumardasari786/day-12-my-first-day-with-ansible-mastering-inventory-and-ad-hoc-commands-subtitle-a-look-into-6fe9618cd555
Top comments (0)