Skip to Content

Ansible: rebuild a server in a few minutes

A written recipe rather than one person's memory: business continuity within reach of an SME.
November 15, 2026 by
Ansible: rebuild a server in a few minutes

Ansible: rebuild a server without depending on a single person

Field: automation, business continuity, infrastructure

For: SME owners whose IT relies on one or two people, and their IT person

Experience: the Ansible recipe I use to build and restore my own servers

With Ansible, a server is no longer rebuilt from memory: it is rebuilt from a written, reviewed and versioned recipe, in a few minutes once the recipe is ready. For a business owner, it is the end of "the server only Paul knows how to rebuild". Here is how it works, what it changes for your business continuity, and the pitfalls I ran into.

Background

In many SMEs, the server was installed by hand, years ago, by a trusted person. Since then, settings have been added, as needs and emergencies came up. Everything works. But nobody knows exactly what is inside, and the documentation, when it exists, dates from the installation.

The problem: a handcrafted server

A server built by hand is a one-off piece. And a one-off piece cannot be replaced:

  • Someone leaves: if Paul leaves, falls ill or is no longer available, his knowledge goes with him.
  • Disaster: dead disk, hosting outage, attack. Everything has to be redone, under pressure, hoping nothing is forgotten.
  • Inconsistency: two servers that are supposed to be identical never quite are, and failures hide in the differences.
  • Control: it is impossible to say for sure which protections are in place, or since when.

The solution: write the recipe, do not redo it

1. Describe the desired state

Ansible is a free tool that applies a written description to a server: these users, this firewall, this software, these settings. You no longer type commands one by one; you describe the expected result, and Ansible does what is needed. It simply connects to the servers, with nothing to install on them.

2. Split into reusable building blocks

My recipe is split into about ten roles: the admin user and access hardening, the firewall, protection against intrusion attempts, the container engine, security updates, the VPN, monitoring, the web front door, encrypted secrets and backup. Each server enables the roles it needs in a simple settings file.

3. Replay without fear

A well-written Ansible recipe is idempotent: applying it once or ten times gives the same result. So you can replay it to check that a server is still compliant, or to correct a drift, without breaking everything.

4. Check before applying

Ansible can simulate what it would do, and show the differences, without changing anything. On a server already in service, it is the step I never skip.

5. Keep the history

The recipe lives in a version repository: every change is dated, explained and reversible. It is also your documentation, always up to date, since it is what does the work.

What it changes for your business continuity

On the day a server disappears, the recovery plan comes down to three steps: rent or install a new machine, apply the recipe, restore the data from tested backups. Building a server by hand takes several hours, with a risk of forgetting something at every step. With the recipe, once it is ready, it takes about a quarter of an hour, and the result is the same every time. The knowledge is no longer in Paul's head: it is in a file that any competent IT person can read.

What I learned the hard way

  • A fix made by hand will be erased. I had adjusted a backup script directly on a server. The recipe, however, was not up to date: the next run would have overwritten my fix without warning. The rule since then: every change goes through the recipe, never directly on the machine.
  • Some tasks replace, they do not merge. A recipe written for a fresh installation can entirely replace a configuration file on a production server. Before applying it to an existing machine, I generate the files locally and compare them with the real ones.
  • The recipe rebuilds the machine, not the data. Ansible puts the server back in the desired state; it is the backups that bring back your invoices and documents. One without the other is not enough.

Under the hood (for your IT person)

  • Structure: an inventory, a variables file per host, conditional roles enabled by variable, tags to run only part of it (firewall, VPN, monitoring…).
  • Two passes: the first connects with the user provided by the host, creates the admin and removes the default user; the second reconnects as the admin with a dedicated key to deploy the rest.
  • Control: check mode with diff before any deployment on a host in service, and a playbook that renders the templates locally for comparison. A second run that changes nothing is the best idempotency test.
  • Secrets: never in plain text in the repository; encrypted with sops and age, decrypted in memory at boot.
  • Source of truth: the reverse proxy role is authoritative; every change goes through it, otherwise the next run undoes it.
  • Pitfall: the container restart policy is verified by actually restarting the engine, not by reading the configuration.

What I take away

A reproducible server is insurance that costs almost nothing once in place. It makes IT transferable, auditable and rebuildable. For an SME, it is often the best ratio between effort and risk avoided, together with monitoring that warns you in time. It is the tenth, invisible block of the map of an SME taking back control with open source.

Going further

I can write the recipe for your existing servers, test it on a fresh machine, and hand you a recovery plan your team knows how to follow. See Your tools and your data, or book a 20-minute call.

The step-by-step guide

For your IT person, my guide no. 9, deploying a new server with Ansible (CHF 39), provides the full recipe and its files: eleven roles that set up hardened access, firewall, Docker and automatic updates on a fresh machine, plus VPN, monitoring and backup when needed.

Sources

Tags: Ansible, automation, business continuity, disaster recovery, infrastructure as code, server, SME

Open source server monitoring, no subscription
Prometheus, Grafana and Loki: what the owner sees, what the IT person tunes, and the lessons of a real outage.