In simple words
- Configuration management: setting up and keeping many servers in the right state (packages, files, services) automatically from code.
- Ansible: a configuration management tool that connects over SSH and runs tasks written in YAML.
- Agentless: nothing extra has to be installed on the servers. Ansible just needs SSH and Python.
- Idempotent: running it again changes nothing if the server is already right.
Big picture
Think of a restaurant chain. Every kitchen must have the same oven settings, the same menu and the same cleaning rules. You could walk to each kitchen and set things up by hand. Or you could write one rule book and send it to every kitchen. Configuration management is the rule book for servers. Ansible is the tool that reads the rule book and makes each server match it.
The problem with doing it by hand
- You log in to a server and type commands. Next month nobody remembers what you typed.
- Server 1 and server 2 end up slightly different. People call this configuration drift.
- Setting up 50 servers takes 50 times as long.
- A broken server is hard to rebuild the same way.
What Ansible is
Ansible is a free tool that configures servers from text files. You describe the state you want, and Ansible makes it true.
| Word | Plain meaning |
|---|---|
| Control node | The machine where you run Ansible (your laptop or a CI server) |
| Managed node | A server that Ansible configures |
| Inventory | The list of managed nodes |
| Module | A small tool for one job, like installing a package |
| Task | One call to a module |
| Playbook | A YAML file with a list of tasks for some servers |
Agentless
Many older tools need a program (an agent) installed on every server. Ansible does not. It connects over SSH (or WinRM for Windows), copies a small script, runs it, and removes it. The only thing a server needs is SSH and Python.
Idempotent: safe to run again
A good Ansible task says "make sure nginx is installed", not "install nginx". If it is already installed, Ansible does nothing. This property is called idempotence. It means you can run a playbook ten times and get the same result.
Ansible and other tools
| Tool | Main job | Style |
|---|---|---|
| Ansible | Configure servers and run tasks | Agentless, YAML |
| Terraform | Create cloud resources | Declarative, state file |
| Puppet and Chef | Configure servers | Agent on each server, own languages |
A common pattern: Terraform creates the servers, then Ansible configures them.
How one run works
- You run
ansible-playbookon the control node. - Ansible reads the inventory to learn which servers to use.
- It connects to each server over SSH.
- For each task, it copies the module to the server and runs it.
- The module checks the current state and changes only what is wrong.
- Ansible removes the module and prints the result.
Files you will meet
| File or folder | What it holds |
|---|---|
ansible.cfg | settings for Ansible |
inventory.ini | the list of servers |
site.yml | a playbook |
group_vars/ and host_vars/ | variables for groups and single servers |
roles/ | reusable packages of tasks |
Install it
python3 -m pip install --user ansibleansible --versionansible [core 2.17.4] config file = None python version = 3.12.4Try your first command. It runs on your own machine, so it needs no inventory:
ansible localhost -m ansible.builtin.pinglocalhost | SUCCESS => { "changed": false, "ping": "pong"}If you see pong, Ansible and Python both work.
Common mistakes
- Thinking Ansible needs an agent. It does not.
- Writing shell commands for everything. Use a module when one exists, because modules are idempotent.
- Forgetting that Python must exist on the managed node.
Summary
- Configuration management keeps many servers the same, from one rule book.
- Ansible is agentless: SSH in, run, leave.
- Playbooks are YAML files of tasks. Tasks are safe to repeat.
CHECK YOUR UNDERSTANDING
3 quick questions
1. What does 'agentless' mean for Ansible?
2. What does idempotent mean?
3. Which pairing is most common?