← Back to Home
🅰️

Introduction to Ansible

Configuration management and automation for one server or a thousand — no agents required.

11 min read📚DevOps Fundamentals

Ansible automates what you’d otherwise do by hand on servers — installing packages, editing configs, restarting services — and does it consistently across many machines at once. It’s agentless (just SSH), and its files are readable YAML, which is why it’s one of the most popular configuration-management tools in DevOps.


🎯 Learning Objectives

By the end of this lesson you will:


The Problem Ansible Solves

Imagine setting up 20 identical web servers by hand: SSH in, install nginx, copy a config, start the service — 20 times. It’s slow, and easy to make one machine subtly different from the rest (“configuration drift”).

Ansible lets you describe the desired state once and apply it to all 20 servers automatically and repeatably.

💡 Idempotency — the key idea

Ansible tasks are idempotent: running the same playbook twice doesn’t do the work twice. If nginx is already installed, Ansible reports “ok” and moves on. You describe the end state, not the steps — so it’s safe to re-run anytime.


How Ansible Works

text
Control Node (your laptop / a CI runner)
 │  runs ansible, holds playbooks + inventory
 │  connects over SSH  (no agent on targets!)
 ▼
Managed Nodes  ──► web-01, web-02, db-01 ...

Core Vocabulary

Term Meaning
Control node The machine that runs Ansible
Managed node A server Ansible configures (over SSH)
Inventory The list of managed nodes
Module A unit of work (e.g. apt, copy, service)
Task A single call to a module
Playbook A YAML file of tasks describing desired state

Install Ansible

Ansible installs on the control node only:

bash
# Ubuntu / WSL
sudo apt update && sudo apt install -y ansible

# or via pip
pip3 install ansible
bash — 80×24
student@devops:~$ansible --version

⚠ Nothing to install on the servers

Don’t try to install an Ansible “agent” on your target machines — there isn’t one. As long as you can SSH into a server and it has Python, Ansible can manage it.


🧪 Hands-on

📝

Get Ansible Running

  1. Install Ansible on your control machine (laptop or a VM).
  2. Run ansible --version and confirm it prints a version.
  3. In one sentence, write down why Ansible being “agentless” is useful.
  4. List two tasks on a server you’d want to automate with it.

🧠 Knowledge Check

Knowledge Check

What does it mean that Ansible is 'agentless'?

Knowledge Check

What does 'idempotent' mean for an Ansible task?


💼 Interview Preparation

Interview Q&A

How does Ansible differ from tools like Puppet or Chef?


Summary

You understand what Ansible is for, its agentless push model, and its core vocabulary. Next, we tell Ansible which servers to manage with an inventory, and run our first commands against them.

Up Next

Ansible Inventory & Ad-Hoc Commands

You've mastered this lesson. Continue your journey to becoming a DevOps Engineer.

Start Next Lesson