Why I Built a 30-Test Automated Quality Gate (pytest + testinfra) for My Own Homelab
Avoiding the "artisanal server" trap
Anyone operating production data platforms knows the artisanal server anti-pattern: manual package installs, ad-hoc firewall tweaks, untracked containers, and six months later nobody can reproduce the stack cleanly.
When building my personal lab for Data Engineering, Automation, and Local Applied GenAI, I treated it with the exact same architectural rigor expected in enterprise environments — locking down the foundation before deploying workloads.
Architecture decisions backed by ADRs
Every layer was designed incrementally with an explicit Definition of Done and versioned Architecture Decision Records (ADRs):
- Isolation by default: dedicated virtual network (
KVM/libvirt+cloud-init), zero router port-forwarding, and private Let's Encrypt HTTPS over a WireGuard mesh VPN (Tailscale + Caddy). - Idempotent automation: OS hardening (key-only SSH, UFW default deny), Docker Engine with log rotation and isolated address pools, reverse proxy, backups, and workloads are managed by Ansible roles required to converge with
changed=0. - Strict container boundaries: every core image uses pinned semantic tags (never
:latest), and published ports bind strictly to127.0.0.1to prevent Docker's iptables rules from bypassing host firewall policies. - Backups only count after a real restore: client-side encrypted
resticsnapshots using least-privilege OAuth (drive.file), consistent logicalpg_dumpalldumps before snapshots, live Telegram failure alerts, and an end-to-end restore verified byte-for-byte with SHA-256.
The differentiator: executable verification
Drawing from my background in Software Engineering and test automation, I built a deterministic Python (pytest + testinfra) test suite across three layers:
static(< 1 s): prevents committing.envfiles or private keys, runsshellcheck,yamllint, and Ansible syntax checks, and enforces pinned tags +127.0.0.1bindings across all Compose files.core(live positive & negative checks): asserts effectivesshd -Thardening, TLS certificate expiry, healthy containers,pgvectoravailability in PostgreSQL, recent backup freshness (< 48h), and negative network assertions proving internal ports (5432,5678,8090,8443) reject traffic outside the secure interface.drift: runsansible-playbook --checkand fails automatically if manual out-of-band changes introduce configuration drift.
Next step: Data + Applied GenAI + Graphs
With a verified foundation in place, the workload tier now runs PostgreSQL 17 + pgvector and n8n, powering local-first data pipelines for job market analytics, skill co-occurrence graphs, and on-demand GPU LLM experiments.
Reliable infrastructure is never accidental — it comes from explicit contracts, idempotent automation, and continuous verification.