Ansible Explained: Architecture, Components, Use Cases & Why DevOps Engineers Love It
Let me ask you a simple question.
Do you enjoy repetitive work?
Maybe you do. BUT!!!
Imagine you need to install Nginx on 50 Ubuntu servers. You can probably do it manually.
Now imagine you need to install Nginx on 25 Ubuntu servers, 12 RHEL servers, 10 Fedora servers, and 3 Windows servers.
Still manageable?
Now imagine installing Nginx, Jenkins, and Maven on all of those servers, keeping them configured correctly, updating them regularly, and ensuring every server remains consistent. No, right. i knew it! i was damn sure that you can not do this 3rd scenario. This is time taking process and hard to manage for long time.
That is where automation becomes necessary, and that is exactly where Ansible comes into the picture.
Do you know,
What Problems Does Ansible Solve?
Before automation, system administrators and DevOps engineers often face several challenges:
- Repetitive manual tasks
- Human errors during configuration
- Slow deployments
- Configuration drift between servers
- Difficulty managing large infrastructures
- Time-consuming maintenance
Managing a few servers manually might be possible, but managing dozens or hundreds of servers quickly becomes difficult, right.
Ansible solves these problems by automating infrastructure management in a consistent and repeatable manner.
Agenda
- What is Ansible?
- Why Use Ansible?
- How Ansible Works
- Common Use Cases
- Ansible Architecture
- Important Components
- Conclusion
What is Ansible?
Ansible is an open-source IT automation tool used for:
- Configuration Management
- Application Deployment
- Infrastructure Provisioning
- Orchestration
It allows administrators and DevOps engineers to automate tasks across multiple systems from a central location.
Key Facts About Ansible
- Open-source automation tool
- Developed by Red Hat
- Written in Python
- Uses SSH for communication
- Agentless architecture
In simple words:
Ansible helps you automate repetitive infrastructure tasks so that you can manage multiple systems efficiently and consistently.
Why Use Ansible?
There are many automation tools available, such as Puppet, Chef, and SaltStack.
So why do many organizations choose Ansible?
Because it is simple. It has an Agentless Architecture, so you and your organization can get started much faster than with many other automation tools. Just install Ansible, add your servers to the inventory file, write a playbook, and run it. Tantara! Your automation is done.
Without Ansible:
- Servers are configured manually
- Human errors increase
- Deployments take longer
- Maintaining consistency becomes difficult
With Ansible:
- Faster deployments
- Consistent configurations
- Reduced manual effort
- Easy scalability
- Easier maintenance
One of the biggest reasons behind Ansible’s popularity is its agentless architecture.
( I am saying “Agentless” so many times, but here we go againโฆ )
What is Agentless Architecture?
Agentless means Ansible does not require any dedicated software agent to be installed on target servers.
Ansible simply uses SSH to connect to remote machines and execute tasks.
Ansible Approach
- Install Ansible on one control machine
- Connect to servers using SSH
- Execute tasks
- Disconnect
Agent-Based Tools
Tools like Puppet, Chef, and SaltStack commonly rely on agents running on managed servers.
This means you must install, configure, update, and maintain those agents on every server.
Because Ansible does not require agents, setup and maintenance become much simpler.
How Ansible Works
Ansible follows a straightforward workflow.
- Read the Inventory file
- Identify target servers
- Connect using SSH
- Execute required modules
- Collect results
- Display task status
When a playbook is executed, Ansible temporarily transfers the required module to the target machine, runs it, retrieves the result, and removes the module after execution.
Since communication happens through SSH, there is no need for a permanently running agent on the target servers.
In simple terms:
Ansible connects to servers through SSH, performs the requested tasks, and ensures systems reach the desired state defined in playbooks.
Key Features of Ansible
- Agentless Architecture
No agent installation required on target servers.
- Simple YAML Syntax
Automation tasks are written in easy-to-read YAML files called Playbooks.
Running the same task multiple times produces the same desired result.
- SSH-Based Communication
Secure communication using standard SSH protocols.
- Cross-Platform Support
Supports Linux, Windows, cloud platforms, containers, and network devices.
- Large Module Library
Provides hundreds of built-in modules for common administrative tasks.
Okay, now we are finally at the one of the most important Ansible concepts-
Idempotency
Idempotency is one of the most important concepts in Ansible.
It means:
Running the same task multiple times produces the same result after the desired state has been achieved.
For example:
If Nginx is already installed on a server, Ansible will detect that and avoid installing it again. This prevents unnecessary changes and helps maintain consistent configurations across systems.
Common Use Cases of Ansible
- Configuration Management
Ensures servers remain configured consistently by managing packages, configuration files, and services.
- Application Deployment
Automates application deployments across multiple environments.
- Server Provisioning
Prepares new servers by installing software, creating users, and applying configurations.
- Patch Management
Applies operating system and software updates across multiple servers.
- CI/CD Integration
Integrates with tools like Jenkins, GitLab CI, and GitHub Actions to automate deployments and infrastructure changes.
Ansible Architecture
Ansible follows a simple architecture where a Control Node manages one or more Managed Nodes using SSH.
Control Node
(Ansible Installed)
|
SSH
|
---------------------------------
| | |
Server 1 Server 2 Server 3
Control Node
The machine where Ansible is installed.
It stores:
- Inventory files
- Playbooks
- Roles
- Configuration files
It is responsible for executing automation tasks.
Managed Nodes
These are the target systems managed by Ansible.
Examples:
- Linux servers
- Windows servers
- Cloud instances
- Containers
- Network devices
Inventory
The inventory contains information about the servers that Ansible should manage.
Playbooks
Playbooks are YAML files that define automation workflows.
Modules
Modules perform specific actions such as:
- Installing packages
- Copying files
- Managing users
- Restarting services
SSH Connection
SSH enables communication between the Control Node and Managed Nodes. Because of SSH, no dedicated agent installation is required.
Important Ansible Components
Inventory
The Inventory file contains the list of servers managed by Ansible.
Example:
[web_servers]
web1.example.com
web2.example.com
[db_servers]
db1.example.com
In simple terms:
Inventory tells Ansible which servers to manage.
Modules
Modules are small programs responsible for performing tasks.
Examples:
In simple terms:
Modules tell Ansible what action to perform.
Playbooks
A Playbook is a YAML file containing automation tasks.
Example:
---
- hosts: web_servers
tasks:
- name: Install Nginx
apt:
name: nginx
state: present
In simple terms:
Playbooks tell Ansible what tasks should run and on which servers.
Ansible Configuration File (ansible.cfg)
The configuration file controls Ansible’s behavior.
Example:
[defaults]
inventory = inventory.ini
remote_user = ubuntu
host_key_checking = False
Common settings include:
- Inventory location
- Default remote user
- SSH settings
- Privilege escalation options
In simple terms:
ansible.cfg tells Ansible how it should operate.
Configuration Settings Order
When Ansible looks for configuration settings, it follows this order:
1. $ANSIBLE_CONFIG
2. ./ansible.cfg
3. ~/.ansible.cfg
4. /etc/ansible/ansible.cfg
The first configuration file found is used.
Conclusion
Ansible is one of the most popular automation tools in modern DevOps environments. Its agentless architecture, simple YAML syntax, and powerful automation capabilities make it an excellent choice for configuration management, application deployment, and infrastructure automation.
Whether you are managing 5 servers or 5000 servers, Ansible helps reduce manual effort, improve consistency, and simplify infrastructure management.
And that’s it for this post.
We covered the fundamentals of Ansible, including its architecture, components, use cases, agentless architecture, and the famous concept of Idempotency.
But don’t get too excited, we’re not done yet. There are still many interesting Ansible topics waiting for us, such as Playbooks, Roles, Variables, Vault, Galaxy, Ad-Hoc Commands, and much more.
We’ll cover those in the upcoming posts. Before entering into concepts like Inventory, Roles and Vault and etc, you can test your Ansible Inventory and Ansible Vault practice quesitons :
Post 1. Ansible Vault Quiz
Post 2. 50 Ansible Inventory Questions
Till then, keep automating, keep learning, and try not to SSH into 50 servers manually.
