Chapter #16: Understand Core Components of Ansible
In this article, you’ll learn the core components of Ansible, including control nodes, managed nodes, inventory files, playbooks, modules, and variables.

These are the core building blocks for everything you'll automate with Ansible in the RHCE course. If you haven’t gone through them yet, we strongly recommend starting there first.
It’ll give you the solid foundation you need to fully understand and apply the automation concepts covered in the chapters ahead.
Ansible is a free and open‑source automation platform by Red Hat that enables you to manage and control multiple servers from one central location.
It’s especially ideal when you have multiple and repetitive tasks that need to be performed. So instead of logging into each of these remote nodes and carrying out your tasks, you can comfortably do so from a central location and manage your servers.
This is beneficial when you want to maintain consistency in application deployment, reduce human error, and automate repetitive and somewhat mundane tasks.
Of course, there are other alternatives to Ansible such as Puppet, Chef, and Salt. However, Ansible is mostly preferred because it is easy to use and simple to learn.
Why is it simple to learn, you might ask? This is because Ansible uses YAML (“YAML Ain’t Markup Language”) in its playbooks and configuration files, YAML is human‑readable and quite easy to follow.
Ansible uses the SSH protocol to communicate with remote servers, unlike other automation platforms that require you to install an agent on remote nodes.
Before we get started with Ansible, it’s important that you get acquainted with some basic terminologies so that you don’t get lost or confused as we move forward.
Control Node & Managed Nodes
- Control Node: The machine where Ansible is installed and from which you run your playbooks (usually one of your admin workstations or a dedicated automation server).
- Managed Nodes: The remote hosts you’re configuring. These only need Python and SSH enabled, no extra agent software.
Inventory
An inventory is a text file that contains a list of servers or nodes that you are managing and configuring. Usually, the servers are listed based on their hostnames or IP addresses.
An inventory file can contain remote systems defined by their IP addresses as shown:
10.200.50.50
10.200.50.51
10.200.50.52
Alternatively, they can be listed according to groups. In the example below, we have servers placed under two groups - web servers and databases.
This way they can be referenced by group name instead of IP address, which further simplifies operations.
[webservers]
10.200.50.60
10.200.50.61
[databases]
10.200.50.70
10.200.50.71
You can have multiple groups with multiple servers in a large production environment.
Ad‑hoc Commands
Need to run a one‑off task (e.g., reboot all web servers)? Use an ad‑hoc command:
ansible webservers -m reboot -b
Ad‑hoc commands are quick, single‑line operations that don’t require a full playbook, great for rapid troubleshooting.
Playbook
A playbook is a set of configuration‑management scripts that define how tasks are to be executed on remote hosts or a group of host machines. The scripts or instructions are written in YAML format.
For instance, you can have a playbook file to install the Apache web server and call it httpd.yml
.
To create the playbook run:
touch playbook_name.yml
For example, to create a playbook called httpd
, run:
touch httpd.yml
A YAML file begins with three hyphens. Inside the file, add the following instructions:
---
- name: Install and start Apache web server
hosts: webservers
tasks:
- name: Install Apache
yum:
name: httpd
state: latest
- name: Ensure httpd is running
service:
name: httpd
state: started
The above playbook installs Apache on remote systems defined as webservers in the inventory file. After installation, Ansible checks that the Apache service is started and running.