Homelab · Operations

Ansible for the Homelab: Configuration as Files

Every homelab has a machine that was set up by hand, late at night, through a sequence of commands nobody wrote down. It works — until it doesn’t, and rebuilding it means archaeology. Ansible is the tool that ends that pattern. You describe the state you want — these packages installed, this user present, this service running, this configuration file exactly so — in plain YAML files called playbooks, and Ansible makes your machines match, over SSH, with nothing installed on the targets. This guide covers what it does well in a home lab, how to start without boiling the ocean, and the version note that matters this month.

Published Nov 21, 2026

The idea: describe the state, not the steps

Most server setup is written as a sequence of commands: install this, edit that, restart the other. Commands describe steps, and steps rot — run them twice and half of them fail or duplicate something, because they assume a starting point. Ansible playbooks describe an end state instead. A task that says “the Docker package is installed” is satisfied whether the package was missing or already there; run the playbook a second time and it changes nothing, which is a property called idempotence and the reason Ansible configuration can be re-applied safely after every change. Your playbooks live in a folder, ideally in git, and that folder becomes the answer to the question “how is this machine set up?” — an answer you can read, diff, and hand to a fresh machine.

The mechanics are deliberately plain. Ansible runs on one control machine — your laptop is fine — and connects to targets over SSH using an inventory file that lists your hosts and groups them: the Docker hosts, the Proxmox nodes, the Raspberry Pis. Tasks are grouped into playbooks for a purpose (“baseline every server”, “deploy the media stack host”) and into roles when a bundle of tasks deserves reuse. There is no agent to install and no database to feed; if you can SSH to a machine, Ansible can manage it. The current release is ansible-core 2.22 (November 2026), which added automatic masking of secrets in its output. One date to know: the older 2.19 line reaches end of life on November 30, 2026, so a control machine still pinned to 2.19 should be moved up as part of reading this guide, not after it.

What it is genuinely good for at home

The highest-value homelab playbook is the boring one: the baseline. Every machine gets the same admin user with your SSH key, password login disabled, the firewall on with the same default posture, unattended security updates configured, time synchronization on, and your standard set of diagnostic tools installed. Written once, applied to everything, it removes the slow drift where each box is a slightly different snowflake with a slightly different forgotten weakness. The second classic is rebuilding the Docker host: Docker installed, your Compose projects’ directories created, sysctl and permissions set the way your stacks expect — so the machine that dies on a Friday can be replaced by a fresh install plus one playbook run plus your backups, instead of a weekend of remembering.

Beyond the baseline, Ansible earns its keep anywhere the same change must land on several machines at once: rotating a key, pushing a corrected configuration file, updating every Pi’s packages and reporting which ones need a reboot. Templating is the quiet superpower — configuration files are generated from Jinja templates with per-host variables, so the monitoring agent’s config, the backup client’s schedule, and the reverse proxy’s settings are all rendered from one source of truth with the host’s own values filled in. When a value changes, you edit it once and re-run; the lab converges. That is the moment a homelab starts feeling operated rather than accumulated.

Starting without boiling the ocean

The failure mode of new Ansible users is ambition: a grand repository that will model the entire lab, abandoned by week two. Start smaller. Pick one machine you understand and one playbook that does the baseline — user, keys, updates, a handful of packages. Run it, run it again to watch it change nothing, and read the output until it is boring. Then add the second machine. Structure can stay flat for a long time: an inventory, a few playbooks, variables in plain files. Roles, vault-encrypted secrets, and Galaxy collections are there when a real need shows up; Ansible Vault in particular matters once playbooks hold anything sensitive, because a git repository full of plaintext passwords is a liability wearing a productivity costume.

Two boundaries keep Ansible in its lane. It is not a monitoring tool — it will not notice a service died at 3 a.m.; that is the monitoring stack’s job, and Ansible’s role is making sure the monitoring agent is installed everywhere. And it is not the best tool for the inside of your Docker stacks: Compose already describes a stack’s state declaratively, so let Compose own containers while Ansible owns the hosts underneath them — the operating system, the users, the Docker installation itself, the directories and the backups plumbing. Drawn that way, the two tools stop competing and start composing, which is the shape most well-run home labs end up in: Ansible gets a bare machine to “ready”, Compose takes it from “ready” to “running your services”, and a rebuild becomes a procedure instead of a project.

The habit that makes it pay off

Ansible’s return on investment arrives the first time you follow one rule without exception: never change a managed machine by hand. The temptation is constant — a quick SSH session, one small edit, done. But that edit is now invisible, and the next playbook run either overwrites it silently or, worse, doesn’t, leaving the machine diverged from its description in a way nobody knows about. The rule turns the playbook repository into the lab’s memory: every change is a commit, every machine’s setup is reproducible, and the 2 a.m. rebuild is a command you have already run in daylight. Keep the repository backed up with the rest of the lab’s important files, run playbooks with --check when you want a dry run that reports what would change, and let the lab grow the way it should — one described, repeatable, boring machine at a time.

A first playbook, in plain terms

Concretely, the starter setup is three small files. The inventory lists your machines under a group name — three lines for three servers — with the SSH user Ansible should connect as. The baseline playbook names that group and lists tasks in the order a careful human would do them: create the admin user and install your public key; disable password authentication for SSH once key login is proven; ensure the firewall is enabled with SSH allowed; turn on unattended security updates; install the standard toolset; set the timezone and confirm time sync. Each task is a short YAML block naming a built-in module — user, authorized_key, apt, service, template — and the state it should reach. Run it with one command, watch it report changed for what it fixed and ok for what already matched, then run it again and watch a column of ok: that second run is the entire philosophy, demonstrated. When a task is wrong, it is wrong in a file you can read, fix, and re-apply — the opposite of the hand-built machine, whose wrongness lives wherever you happened to type it in February.

Knowing what to leave alone

Judgment about scope is the senior skill here. Ansible is a poor fit for one-off interactive work — partitioning a disk while you think, debugging a live fault, anything where the next step depends on what the screen says. It is also the wrong owner for state that another system already describes well: Compose owns containers, your hypervisor owns VM definitions, and your backup tool owns its schedules. Ansible’s territory is the substrate all of those stand on, plus the glue — the directories, users, mounts and settings that every rebuild needs and no other tool claims. Labs get into trouble when two systems both believe they own the same file; the fix is the boring one of deciding, in writing, which layer owns what. Draw that map early, keep the playbooks inside it, and Ansible stays what it should be: the reason a new machine joins the lab already knowing the house rules.

Where the files live, and the backup question

The playbook repository deserves the same seriousness as the data it describes. Keep it in git, keep the git repository backed up with the rest of the lab’s important files — the 3-2-1 backup guide on this site is the standard to meet — and treat the vault password that unlocks its secrets with the respect due to a master key, because that is functionally what it is. A repository you can restore plus backups you can restore from equals a lab you can rebuild on replacement hardware in an afternoon, and that sentence is the entire return on the Ansible investment, paid out on the worst day rather than the best ones. Everything before that day is practice.

Official documentation and references

Frequently asked questions

Do I need to install anything on the machines Ansible manages?

No agent, no. Ansible connects over SSH and uses the Python already present on virtually every Linux target. The software lives on one control machine — your laptop or a small utility host — and current ansible-core is the 2.22 line as of November 2026. Note that ansible-core 2.19 reaches end of life on November 30, 2026, so an older control install should be upgraded.

How is Ansible different from Docker Compose?

They describe different layers. Compose describes containers: which images, networks, volumes and environment a stack runs with. Ansible describes machines: users, packages, files, services and settings on the hosts themselves. Most home labs use both — Ansible prepares and maintains the Docker hosts, Compose runs what lives on them.

Is Ansible overkill for three machines?

For the machines themselves, arguably. For the rebuilds, no. The value is not managing three machines today; it is that the fourth machine — or the replacement for the one that died — takes an afternoon of unattended playbook runs instead of a weekend of remembering what you did in March. If you have ever rebuilt a server from screenshots of your own terminal history, you are the audience.

Where do passwords and keys live in a playbook repository?

Encrypted, or not in the repository at all. Ansible Vault encrypts sensitive variables with a password so they can sit safely in git, and anything truly precious can stay in your password manager and be supplied at run time. The rule that matters: a playbook repository is shared, backed up and copied around, so treat anything in it as readable by whoever holds the repo — and encrypt accordingly.

Can Ansible manage network gear and Windows machines?

Much of it, yes, with different connection methods — many switches and routers have Ansible modules, and Windows targets are managed over WinRM. The homelab core case in this guide is Linux servers over SSH, which is where Ansible is strongest and where a first installation should start.

Related guides