Are you a beginner to Ansible? This guide will give a brief introduction to Ansible, and other important factors of Ansible automation platform including Ansible architecture, inventory, modules and playbooks.
If you are someone who is trying to understand what ansible is and what are its core features, then this article is for you.
Have you ever been in the position to deploy multiple resources manually in your professional/personal environment?
When I say "resources", it can be anything starting from servers, databases, network devices, web servers, etc. You know the pain of doing everything manually for multiple resources.
As a system administrator, you can happily say those days are long gone. The invention of the automation tools made the life of all system administrators easy.
Not only system administration, but the automation tools are also used by developers to automate their deployment pipelines too. One such automation tool is Ansible!
Today, I am going to walk you through what is ansible and core components involved in ansible.
What is Ansible?
Ansible is an automation tool that can be used in any area of your technology stack like network, database, servers, application deployments, containers, security, cloud, etc.
It plays a major role in the areas of configuration management, Infrastructure as code, orchestration.
Ansible is written in Python, so if you are a python developer then creating custom modules in Ansible is easy.
Ansible was originally created by Michael DeHaan and later acquired by Redhat in 2015. Ansible is open source and Redhat offers a commercial version of ansible too.
The first step in learning ansible is to understand Ansible architecture.
A combination of components like Ansible engine, Inventory, Playbooks, etc., forms the ansible architecture.
Here is the graphical illustration of how Ansible works:
Ansible follows agentless architecture. There is no special piece of software or client process that needs to be installed on all client machines for ansible to communicate and work with.
ssh protocol to communicate with all client nodes and uses whatever port
ssh is listening to on the client nodes. This is customizable too. This way you no need to open any special ports dedicated to ansible.
There are two types of nodes in ansible. If you are wondering what the term
"node" refers to? It’s just a server or workstation.
- Master/Controller Node - Node where you will install ansible software.
- Managed Nodes - Nodes that will be managed by Ansible.
You can call the nodes as master and slave nodes but stick with ansible jargon which is the best practice.
From this point, I will be referring the master node as controller node and slave nodes as managed nodes throughout the article.
Inventory is where you will be providing managed node host/IP information to ansible. The inventory file will be in INI format by default and it also supports
When you submit ansible-playbook or Adhoc commands, ansible engine will parse this inventory file and get a list of hosts that it wants to work with.
Modules are programs that are written in python for a particular task. When you run playbook or Adhoc commands ansible will send this program to all managed nodes.
Let’s take the
apt module for example. The
apt module is for managing packages in Debian and Ubuntu-based systems.
If you submit a playbook to install packages in five managed nodes, then the
apt module will be copied to all the managed nodes and the
apt program will be executed.
You can also create your own modules, but most of the time there will be modules available to satisfy your needs.
Ansible playbooks are blueprints for your task. Playbooks are written in
YAML format. You will create different tasks and Ansible will execute these tasks in managed nodes.
This is just a short introductory article to get the glimpse of what Ansible is and its architecture. For more details, I recommend you to go through the official documents given at the end.
In our upcoming articles, we will dive deep into how to set up and use Ansible in Linux.
- Install And Configure Ansible In Linux
- Automated Ansible Lab Setup With Vagrant And Virtualbox In Linux
- Ansible Inventory And Configuration Files
- Ansible SSH Authentication And Privilege Escalation
- Getting Started With Ansible Ad Hoc Commands
- Getting Started With Ansible Playbooks
- How To Use Debug Module In Ansible Playbooks
- How To Use Variables In Ansible Playbooks
- Explaining Ansible Facts With Examples
- How To Use Handlers In Ansible Playbooks
- How To Use When Conditional Statements In Ansible Playbooks
- How To Use Tags In Ansible Playbooks
- Ansible Register Variable
- How To Use Ansible Vault To Protect Sensitive Playbook Data
- How To Use Ansible To Automate Logical Volume Manager (LVM) In Linux
- Ansible Roles Tutorial For Beginners
- Error Handling In Ansible Playbooks
- Ansible Collections Tutorial
- How To Work With Include And Import In Ansible