Konstantinos Antoniou.

← Projects

Infrastructure as Code: Managing My Home Lab with Ansible

Introduction

Automation became a natural next step once my homelab started growing. With multiple Debian VMs, Docker containers, and two MikroTik routers connecting Site A (home) and Site B (work), manual configuration quickly turned into a chore. I began using Ansible to automate system setup, updates, and configurations across all my nodes.

Ansible’s agentless nature fits perfectly into my environment — no need for complex agents or additional services. I can control everything securely over SSH, managing both Linux systems and network devices in a consistent and reproducible way.


My Use Cases

I use Ansible mainly for three purposes:

  1. System provisioning – Deploying and configuring Debian VMs in Proxmox. After a fresh install, I can run a playbook to set up packages, users, SSH keys, firewall rules, and system preferences automatically.
  2. Service automation – Managing Docker services (Nextcloud, Heimdall, Portainer, etc.) across hosts. Playbooks handle Docker Compose deployments, environment files, and updates.
  3. Network configuration – Using Ansible modules and templates to push configurations to MikroTik routers. I maintain uniform VLANs, VPN routes, and firewall rules across sites without logging into each router manually.

This structure ensures that every part of my infrastructure can be rebuilt or updated predictably, without human error or forgotten settings.


What I’ve Learned

Working with Ansible has taught me valuable DevOps principles:

  • Idempotency – Playbooks describe the desired state. Running them multiple times only enforces that state, never breaks it.
  • Version control – Keeping all playbooks and inventories in Git helps me track changes and roll back configurations when needed.
  • Modularity – Splitting roles and variables allows me to reuse automation logic across different hosts.
  • Documentation through code – Playbooks serve as living documentation. Anyone can understand my infrastructure setup by reading them.

Ansible has become one of the central tools in my DevOps journey, bridging the gap between manual sysadmin work and reproducible, infrastructure-as-code management.


Example Playbooks

Below are some examples from my real setup.

  1. System Update and Maintenance
  2. Update flatpak applications
  3. MikroTik export configuration