Skip to content

About

Self-hosted homelab as code: Ansible playbooks and Docker Compose stacks deploying sovereign services (Matrix Synapse, Zitadel, Netbird, OpenBao, Gatus) on TrueNAS and a cloud VPS, behind Traefik with Cloudflare DNS.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

Infrastructure

The infrastructure I designed, built and run for my family, entirely as code.
Two servers, about 45 self-hosted services, single sign-on, a mesh VPN, intrusion prevention and full observability: deployed with Ansible, Docker Compose and OpenTofu, tested in CI.

CI Status page Documentation Author

Ansible Docker Compose OpenTofu Traefik TrueNAS Grafana GitHub Actions


This repository is the production infrastructure of my family's digital life (passwords, documents, photos, home automation, chat), hosted on hardware we own rather than in someone else's cloud. I treat it like software: every service, route, DNS record, login, alert and dashboard is a reviewed file, linted and tested in CI, then applied with one command. It is also where I practise what I care about as an engineer: security by default, observability, and automation that is boring to operate.

At a glance

Servers A TrueNAS SCALE home server (ZFS) and a cloud VM, joined by a NetBird mesh VPN
Services About 45: Nextcloud, Vaultwarden, Paperless-ngx, Jellyfin, Home Assistant, Matrix Synapse, Gitea, Open WebUI… (full list)
Deployment 20 Compose stacks from this repository through one shared Ansible role; TrueNAS apps routed by it
Identity Zitadel single sign-on, its organization and OIDC applications provisioned with OpenTofu
Edge Traefik v3, wildcard Let's Encrypt certificates over Cloudflare DNS, CrowdSec, per-client rate limits
Observability VictoriaMetrics, VictoriaLogs and Grafana, alerts to phones, an MCP server for LLM queries
Quality 8 CI jobs, including ones that boot the real stacks; weekly Dependabot updates

Architecture

flowchart LR
    user([Visitors and family]) -->|HTTPS| cloudflare[Cloudflare DNS]
    cloudflare --> lux
    cloudflare --> bxl
    subgraph lux [Cloud VM]
        traefik_lux[Traefik + CrowdSec] --> vpn[NetBird]
        traefik_lux --> vigie[VictoriaMetrics, VictoriaLogs, Grafana]
        traefik_lux --> gatus[Gatus status page]
    end
    subgraph bxl [TrueNAS home server]
        traefik_bxl[Traefik] --> apps[Nextcloud, Vaultwarden, Paperless, Jellyfin, Home Assistant…]
        traefik_bxl --> zitadel[Zitadel SSO]
    end
    vpn <-->|WireGuard mesh| bxl
    vigie -.->|scrapes metrics, receives logs| bxl
Loading

Engineering highlights

  • Tested like application code. CI does not stop at linting: it boots Traefik with its real routes, CrowdSec and its bouncer (and checks that a scanner gets banned and an IPv6 client keeps its own address), and VictoriaMetrics with Grafana, feeding synthetic metrics and checking that every dashboard query is valid and every alert fires when it should. Ansible roles have Molecule scenarios, OpenTofu configurations are validated and tested.
  • Secure by default. Private services only answer the LAN and the VPN; nothing internal is published, metrics and APIs stay on internal Docker networks; containers drop the capabilities they do not need and read the Docker socket through read-only proxies; secrets live in Ansible Vault in a private submodule and the OpenTofu state is encrypted; SSH keys are restricted by source network and forced commands.
  • Identity as code. The whole Zitadel organization (policies, users, OIDC clients for each service) is OpenTofu, and services pick up their client credentials at deploy time.
  • Observable. Host, container, Traefik and CrowdSec metrics, Traefik's access logs, Grafana dashboards and alert rules are all provisioned from this repository; Grafana's MCP server gives an LLM read-only access to them for investigations.
  • Small, repeatable building blocks. Every service is a folder with a playbook and a Compose file, deployed by one shared role that creates folders, writes secrets, starts the stack and publishes its DNS records; toolchains are pinned with uv and mise; deployments also run from Semaphore on the server itself.

Documentation

Everything about how it works and how to operate it is on www.anneraud.fr (in French), written from this repository (source):

Page Answers
Architecture Which server does what, how a request reaches a service, how single sign-on works
Network and DNS How sites, the VPN and Docker networks are addressed and named
Security Which protections a request goes through; operating CrowdSec; secrets and the vault
Deployment How a change goes from this repository to the servers; the automation account; Semaphore
Single sign-on What OpenTofu owns in Zitadel, accounts, connecting a service, TrueNAS apps
Monitoring Gatus and Vigie: metrics, access logs, dashboards, alerts, LogsQL queries
Backups Where data is copied, replication, how to restore
AI assistants MCPHub, the workstations' clients, Grafana's MCP server
Services Every service with its access, host and deployment

Repository layout

inventory/        # hosts, one group per service naming its host, per-host settings
services/<name>/  # one folder per service: deploy.yml (playbook), compose.yml, templates
roles/            # compose_service (every stack), opentofu, zitadel
opentofu/zitadel/ # the Zitadel organization, its users and OIDC applications
hosts/            # host-level playbooks: bootstrap, replication, workstations
dns/              # one playbook per Cloudflare DNS zone
site.yml          # every service, host by host
vault/            # private submodule: Ansible Vault files and the encrypted OpenTofu state
.github/          # CI: lint, Molecule, OpenTofu, and checks that boot the real stacks

Working on it

mise install && mise run setup                 # pinned Ansible, OpenTofu, linters and collections
mise preview site.yml --limit <host>           # what would change, without changing it
mise deploy services/<service>/deploy.yml      # deploy one service
mise vault vault/<service>/vault.yml           # edit a service's secrets
mise lint && mise test                         # the CI checks that need no server

Conventions for changes (and for coding agents) are in AGENTS.md.

License

MIT.

About

Self-hosted homelab as code: Ansible playbooks and Docker Compose stacks deploying sovereign services (Matrix Synapse, Zitadel, Netbird, OpenBao, Gatus) on TrueNAS and a cloud VPS, behind Traefik with Cloudflare DNS.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages