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

IT management · 3 min readHow much does IT support cost for a small office in Europe?Per-user, per-device and hourly pricing explained: what drives the monthly price of outsourced IT support for a team of 5 to 50 people, and how to compare offers fairly.Read the articleIT management · 3 min readIn-house IT or managed IT services: an honest cost comparison for 10–50 person companiesWhat an internal IT administrator really costs compared with a managed IT service, what you gain and lose with each option, and when a hybrid model works best.Read the articleDevSecOps · 4 min readSecuring your CI/CD pipeline: the supply-chain risks small teams overlookYour pipeline holds the keys to production. How attackers abuse CI/CD, and ten concrete controls for GitHub Actions and GitLab CI: pinned actions, minimal token permissions, OIDC, protected branches, runner isolation and signed artifacts.Read the article