Ansible
My Ansible Notes (Beginner to Advanced) : Repository to learn Ansible from Zero. This repository covers the complete Ansible fundamentals along with examples required for a DevOps Engineer.
Install / Use
/learn @naveensilver/AnsibleREADME
Ansible
-
Ansible is a Configuration management tool.
-
Ansible is managed by System administrator.
System Administrator :
In Every Project, we use multiple machines to setup infrastructure for our application.
All these Machines are managed by System Administrator.
The roles and responsibilities of sys administrator is to manage configuration management for machines manually.
Configuration Management :
-
It is method through which we automate the admin tasks like creating user, installing s/w , adding, updating, deleting, data-backup.. anything that is required for our project.
-
Configuration management tools turns your code into Infrastructure.
-
So, your code would be testable, repeatable and versionable.
-
Infrastructure refers to the composite of -
- Software
- Network
- People
- Process
If we have 100's of machines then Manual Configration Management will be difficult.
Problem with this approach
-
Time consuming
-
chance of getting error
-
Repeatitive task
-
To avoid this Manual Approach, Automation Configuration Management Tools came into Market, those tools are
- Ansible (Trending Tool)
- Chef
- Puppet
Ansible work based on 'Push' Mechanism
Chef & Puppet Tools work based on 'Pull' Mechanism.
Ansible :
• Ansible is one of the DevOps Configuration Management tool which is famous for its simplicity.
• Ansible is open-source software developed by Michael DeHaan and Its Owned by RedHat.
• Ansible is an Open-source IT configuration Management, Deployment & Orchestration Tool.
• Ansible is easy to deploy because it doesn’t use any agents or custom security infrastructure. Which means ansible works by connecting nodes through SSH.
• Ansible is automates the Orchestration service – means it follows master and slave concept
• Ansible uses Playbooks to describes automate the jobs and Playbook uses YAML scripting language which is simple and easy to understand. Which works on Key-Value pair format. (YML/YAML – Yet Another Markup Language)
• Ansible Provides a way to define Infrastructure as code (IAC). Simply means that managing infrastructure by writing code rather than using manual process.
• Ansible is mainly designed for multi-tier deployments.
• Ansible uses the hosts file where one can group the hosts & can control the actions on a specific group in the playbook.
• Ansible GUI [Graphical user interface] is called Ansible-Tower. It was just drag and drop.
• Ansible was written in Python. Dependency of ansible is python.
• Ansible doesn’t require any software to be installed on other machines.
• Ansible’s ability to manage multiple system in parallel and makes well suited for large scale deployment.
• Ansible is widely used in IT industry for managing infrastructure.
• Ansible is used for diff tasks such as software installation and file management, service management etc.
• The Main Components of Ansible are Playbooks, Configuration Management and Deployment.
• Ansible uses a playbooks to automate deploy, manage, build, test and configure anything.
HISTORY:
• Ansible was first developed in Feb 2012 by Michael Dehaan.
• In 2013, Ansible taken over by RedHat.
• Ansible is available for other OS like Oracle Linux, Debian, CentOS, RHEL.
• Over the years, Ansible has added many features like security features, support for cloud providers and improved support for windows systems.
• Now, Ansible is considered one of the leading automation tool in IT industry.
• Ansible tool is used whether the servers are in On-prem or in the cloud.
• Ansible turns your code into infrastructure.
Ansible Features :
-
Ansible manages machines in an Agent-less manner SSH.
-
Ansible Written in Python and Hence provides a lot of python's functionality.
-
YAML based playbooks. (YML is Human and Machine readable)
-
User SSH for secure connections.
-
Follows Push based Architecture for sending configurations.
WHY ANSIBLE :
• Ansible Automate and Simplify - the repetitive, complex operations and long operations.
• Ansible is open source, saves time as well as human efforts & is easy to implement.
• Ansible architecture is easy and effective, it works by connecting to your nodes & pushing small programs to them.
• Ansible is push based architecture & doesn’t need agents running on the client nodes.
• Ansible works over SSH. So, nothing needs to install on client machines and it need only a text editor and command line tools are usually enough to get your work done and other tools like chef/puppet need to install agent on the client machines. When we need to perform a task.
• Ansible is light weight, easy to use and speed deployment compared to other tools.
• Ansible used when you have multiple server which needs to be configure the same setup in all servers.
• While doing one to one server their might be a chance to miss some configuration steps in some servers.
• That’s why we use automation tools
• It follows Describe The Desired State Of The System
ANSIBLE USES :
-
Agentless Architecture: Ansible doesn’t require any extra software on your remote nodes. Which makes it easy set up and use and It helps to keep the installation clean.
-
Open-source: Ansible one of powerful DevOps tool which is open-source.
-
Simple: Ansible uses the simple syntax written in YML called playbooks. YAML is simple and human readable and doesn’t require any coding skills.
-
Ease of use: One can configure and manages the complex infrastructure solutions very easily.
-
Powerful & Flexible: Ansible has powerful features that can enable even the most complex IT workflows.
-
Efficient: No extra software on your server means more resources for your applications.
-
Secure: Ansible uses SSH connection which is secure and encrypted.
-
Configuration Management: used to automate configuration managemet tasks such as provisionig, application deployment and infastructure management.
-
Scalability: Ansible can manage a large number of systems simultaneously, making it ideal for large-scale deployments.
-
Open-source: Free to use and has large community contributors who regularly contribute to its development.
-
Integrate with other tools: Ansible can be integrated with other tools such as Docker, Kubernetes and AWS, which makes it varsatile and easy to use in a variety of environments.
Push vs Pull Based Architecture
-
Puppet and Chef are Pull Based Architecture
- Agents on the other server periodically checks for the configuration information from central server (Master)
-
Ansible is Push Based Architecture
- Central server pusher configuration information on target servers.
What Ansible Can do ?
1) Configuration Management
2) App Deployment
3) Contineous Delivery
Ansible Work-flow / Ansible Architecture

Ansible uses Master-Slave Architecture.
In Which Machine, Ansible is installed that machine is called as Master Node / Control Node or Ansible Server.
The Machines, which are managed by Master node they are called as Host Node / Slave node.
Inside Master Node, we are going to write 'Playbooks' to Automate our configuration Management.
Playbooks are written in YAML [Yet Another Markup Language] Language.
Ansible works by connecting to your nodes and pushing out a small program called 'Ansible Module'
Master Node is connected to Host-Node through SSH and execute the small modules on host's machine and install the software.
After Execution, The Modules will be removed on host machines.
The Master node control the entire execution of the playbook.
The Inventory file provides the list of hosts where ansible modules need to be run.
Ansible requires following three Components to automate the Network Infrastructure,
1) Control Node / Master Node
2) Managed Nodes / Host Node
3) Ansible Playbook
- Control/Master Node :
- The Machine which contains ansible server is called as Control node. It will controll other Host nodes.
- Managed/Host Node :
- The Nodes which are managed or controlled by ansible is called Host Node /Managed Node
- Ansible PlayBook :
-
Ansible will use Playbook to automate configurations in Host Node.
-
Ansible playbooks are expressed in YML format
-
Playbooks are a collection of tasks that will be runs on one or more hosts nodes.
Inventory File
Ansible Inventory hosts file is used to store the IP_Address of Target servers. we can list and group your host server.
The Default location is "/etc/ansible/hosts"
Note: In Inventory file, we can mention Private_IP Address or Hostname also.
Few Important Point about Inventory File
-
Comments begins with '#' character.
-
Blanklines are ignore
-
Group of hosts are delimited by '[header]' elements.
-
You can enter hostname or Ip addresses.
-
A hostname/ip can be a member of multiple groups.
-
Ungrouped hosts are specifying before any group header like below
Sample Inventory File :
#Blank lines are ignore
#Ungrouped hosts are specifying before any group header like below
192.168.122.1 #Private_IP
192.168.122.2
192.168.122.3
[webservers]
192.168.122.1
#192.168.122.2
192.168.122.3
[dbserver]
192.168.122.1
192.168.122.2
silver-db1 #hostname
silver-db2
Chef Work-Flow / Chef Architecture :

-
Work stations - we write cookbooks[ruby] after shared to chef master.
-
Chef server - we install chef and connected to chef client servers.
-
Chef client - we have different Nodes
-
If we Compare Ansible and chef - Ansible is easy to setup and run in any environment [any device]
Difference B/w Ansible, Cheff and puppet :

``STEPS TO
Security Score
Audited on Mar 24, 2026
