What is Ansible?

If you're new to automation and configuration management, Ansible is one of the best tools to start with. It’s agentless, uses YAML, and it's designed to be simple, powerful, and efficient. Whether you’re managing a few servers or deploying applications to hundreds, Ansible has got you covered.

I'm Luca Berton, and welcome to today’s episode of Ansible Pilot.

Why use Ansible?

Here are some key reasons Ansible is loved by system administrators and DevOps engineers:

* No agents required – everything works over SSH or WinRM.

* Simple YAML syntax – great for beginners.

* Powerful modules – support for system packages, services, files, cloud, and more.

* Idempotency – run your playbook multiple times without side effects.

* Extensibility – build roles, collections, and plugins as your infrastructure grows.

Key Components of Ansible

Let’s break down Ansible into its most important building blocks:

* Inventory: A file (usually hosts) listing the machines you want to manage.

* Modules: Pre-built units of work – think of them like commands (ping, copy, yum, etc.).

* Playbooks: YAML files where you define your automation tasks.

* Tasks: Individual units of work within a playbook.

* Roles: Reusable collections of tasks, files, vars, and more.

* Collections: Namespaced bundles of roles, modules, and plugins.

Prerequisites

* A control node (Linux/macOS with Python 3.x).

* Managed nodes (Linux or Windows).

* SSH access to Linux targets, or WinRM setup for Windows.

Your First Ansible Playbook

Let’s walk through a very basic playbook to install Apache on a group of web servers.

* install_apache.yml

``yaml

---

  • name: Install Apache Web Server

hosts: webservers

become: true

tasks:

- name: Install Apache

ansible.builtin.yum:

name: httpd

state: present

- name: Start Apache

ansible.builtin.service:

name: httpd

state: started

enabled: true

`

Run the Playbook

`bash

ansible-playbook -i inventory.ini install_apache.yml

`

Where inventory.ini might look like:

`ini

[webservers]

192.168.1.10

192.168.1.11

`

Best Practices

* Use roles and collections to organize large projects.

* Keep inventories dynamic when working with cloud providers.

* Secure secrets using Ansible Vault.

* Use gather_facts: false` if facts aren't needed – it speeds up execution.

Conclusion

That’s your first step into the world of Ansible! You’ve learned what Ansible is, how it works, and how to write your first playbook. Start simple, iterate fast, and scale confidently.