Lorixen.
EN

Stop hand-configuring servers: Ansible for small teams

Short answer: If your business runs two, three or ten servers and every change is made by someone logging in over SSH and typing commands, the servers slowly drift apart and nobody can rebuild one from scratch. Ansible lets you describe the desired setup, such as packages, users, firewall rules, configuration files and services, in readable playbooks kept in version control, then apply them to every server the same way. It connects over SSH and needs no agent on the servers. Start small: one playbook for your baseline, run in check mode first, and grow from there.

The problem with hand-configured servers

Manual changes work until they don't:

  • One server has a security setting the others lack.
  • Nobody remembers why a configuration line was added.
  • Rebuilding a failed server takes days of guesswork.
  • A new developer can't tell what's "standard".

This is often called configuration drift, and it's common in small businesses where servers were set up over years by different people.

What Ansible is

Ansible's introduction describes it as using human-readable scripts called playbooks, in which you declare the desired state of a system; Ansible ensures the system stays in that state. Playbooks use YAML syntax that reads like documentation, and Ansible is decentralised, using SSH with existing operating system credentials to access remote machines. Its design principles include an agentless architecture.

The getting-started guide names three main components:

  • Control node: the computer where Ansible is installed and where you run commands, such as a developer's laptop or a small admin server.
  • Inventory: a list of managed nodes, logically organised, created on the control node.
  • Managed nodes: the remote servers Ansible controls.

A sensible first playbook

Begin with the basics every server should share:

  1. Packages: install the tools you always need and remove ones you don't.
  2. Users and SSH keys: create admin accounts with keys, and remove former staff.
  3. SSH settings: disable password logins and root login, if that's your policy.
  4. Firewall: allow only the ports each server needs.
  5. Automatic security updates: make sure they're enabled.
  6. Time and logs: time synchronisation and log rotation settings.

Then add role-specific playbooks: web servers, database servers, background workers.

Run safely with check and diff mode

Ansible's documentation on validating tasks describes two modes:

  • Check mode (ansible-playbook site.yml --check) runs the playbook without making changes, reporting what would change.
  • Diff mode (--diff) shows the changes made or, combined with --check, the changes that would be made. You can limit a run to one host.

The documentation warns that diff mode can reveal sensitive information and lets you disable it per task. Always run check and diff against one server before applying changes broadly.

Keep secrets out of plain text

Playbooks often need passwords, API keys or certificates. Ansible Vault, per its documentation, provides a way to encrypt and manage sensitive data such as passwords, including encrypted variables and files. Store vault-encrypted files in version control, and keep the vault password in your password manager, not in the repository.

Put it in version control

Store playbooks and inventory in a Git repository:

  • Every change has an author, date and reason.
  • Changes can be reviewed before they're applied.
  • You can roll back by reapplying an earlier version.
  • New team members can read exactly how servers are built.

Bring existing servers under control gradually

You don't need to rewrite everything at once:

  1. Pick one area, such as SSH users, and write a playbook that matches what's on the servers now.
  2. Run it in check mode to see differences, then decide which version is right.
  3. Apply it, and from then on change that area only through Ansible.
  4. Repeat for the next area.

Within a few months, rebuilding a server becomes "create a fresh machine and run the playbooks".

When Ansible isn't the right tool

  • If you run everything on a managed platform or containers, the platform's own configuration may replace much of this.
  • For creating cloud resources themselves, infrastructure-as-code tools are often used alongside Ansible.
  • For a single, rarely changed server, good written notes may be enough.

Make it a team habit

Tools only help if people use them. Agree that changes to server configuration go through the playbooks, not ad-hoc SSH sessions, except in emergencies, and that any emergency change is written back into a playbook the same week. Review playbook changes the way you review code. Run the full set in check mode on a schedule, for example monthly, to spot drift caused by manual fixes, package updates or someone forgetting the rule. A short readme in the repository explaining how to run the playbooks, where the vault password lives and which inventory groups exist will make the setup usable by whoever joins next, including an outside contractor in a hurry.

An illustrative example

A hypothetical Brighton software studio ran four servers set up by three developers over six years. Each had different SSH users and firewall rules. The studio's developer wrote a baseline playbook for users, SSH settings, firewall rules and automatic updates, ran it with --check --diff against one server, fixed the differences, then applied it to all four. Former contractors' accounts were removed in the same run. When a disk later failed, a replacement server was configured in an afternoon.

FAQ

Do I need to install anything on the servers?

Ansible connects over SSH, with Python typically required on managed nodes. No separate agent is needed.

Is it only for large companies?

No. Even two servers benefit from consistent, documented configuration.

Will running a playbook twice break things?

Well-written tasks describe a desired state, so a second run should change nothing.

Can non-developers read playbooks?

Often, yes. YAML playbooks read much like a checklist of what each server should have, which makes them useful documentation for managers and auditors too.

If your servers have drifted apart and you'd like them documented and consistent, tell us how many you run and where.

Sources

WhatsAppBook a call