All articles

DevOps · 12 October 2026 · 2 min read

Infrastructure as code with Terraform and Ansible: a practical introduction for small companies

Ask yourself one question: if your main server disappeared tonight, how long would it take to build an identical one? If the answer starts with “well, first we would need to remember how it was set up”, infrastructure as code is for you.

The idea

Infrastructure as code (IaC) means describing servers, networks and their configuration in text files instead of clicking through web consoles. The files live in Git, changes are reviewed, and the same files can rebuild the environment at any time. Your infrastructure gets a history, documentation and an undo button.

Terraform: creating the infrastructure

Terraform describes what should exist in your cloud or virtualisation platform: virtual machines, networks, firewall rules, DNS records, storage buckets. You write the desired state, Terraform compares it with reality and shows a plan of changes before applying them. It works with AWS, Azure, Google Cloud, Hetzner, DigitalOcean, Cloudflare and hundreds of other providers.

resource "aws_lightsail_instance" "web" {
  name              = "web-1"
  availability_zone = "eu-central-1a"
  blueprint_id      = "ubuntu_24_04"
  bundle_id         = "small_3_0"
}

OpenTofu is an open-source fork of Terraform with the same language, a good option if licensing matters to you.

Ansible: configuring what runs on it

Ansible describes how a server should be configured: packages, users, SSH settings, firewall, Docker, application files. It connects over SSH, needs no agent and applies the same playbook to one server or a hundred. Running it again changes only what drifted from the desired state.

- hosts: web
  become: true
  tasks:
    - name: Install Docker
      apt:
        name: docker.io
        state: present
        update_cache: true

How they work together

  1. Terraform creates the server, network and DNS.
  2. Ansible installs and configures the software.
  3. Your CI/CD pipeline deploys the application.

All three are code in a repository. A new environment for testing, or a replacement after a disaster, becomes a matter of running a few commands.

A realistic first project

Do not try to convert everything at once. A good first step for a small company:

This usually fits into 20 to 40 engineer hours and immediately reduces the risk of “nobody knows how this server was built”.

When it is not worth it

If you run only SaaS tools and no servers, IaC brings little. If you have one server that rarely changes, a well-written document and good backups may be enough for now. IaC pays off as soon as you have several environments, frequent changes or a business that cannot wait days for a rebuild.

Infrastructure as code is part of our DevOps Growth plan. Combined with CI/CD, it turns your infrastructure into something you can rebuild in minutes.

More articles

Infrastructure · 2 min readThe 3-2-1 backup rule in practice: how to know your backups will actually restoreA practical guide to the 3-2-1 backup rule for small businesses, immutable copies against ransomware and a simple quarterly restore test you can run yourself.Read the articleDevOps · 2 min readWhat a CI/CD pipeline is and when a small team needs DevOpsA clear explanation of CI/CD for business owners and small development teams: what it automates, what it costs, and the signs that it is time to invest in DevOps.Read the articleSecurity · 2 min readPatch management for small businesses: how to keep systems updated without breaking themA practical patch management process for small companies: what to update, how often, how to test and how to handle urgent security fixes without disrupting work.Read the article