Homelab - Using "as-code" - Suggestions?

Ok so I had a drive die in one of my homelab nodes and I lost a few VMs and docker-compose configs. Lesson learnt… I had put off doing it properly as it was working and had evolved over time…

Now I want to redo from scratch basically and use “as-code” to automate my home-lab and have the config stored in git. The data itself is stored on a ZFS pool (I have another pair of drives on their way from Amazon US to setup a second ZFS pool in a different machine for backing up the important non- replaceable data).

So my hardware is:

HP EliteDesk 800 G6 SFF (PVE1) (Medium)
Intel i7-10700
64GB RAM
256GB M.2 SSD
1x 2TB HDD for Proxmox VM Storage.

Dell PowerEdge T630 (PVE2) (Huge)
2x Intel Xeon E5-2620 v4 2.1GHz (2x 8C/16T)
128GB DDR4 ECC (8x 16GB)
1x 120GB SATA SSD
4x 10TB WD Red SATA HDD and 2x 12TB WD Red (running in RAIDZ2) connected to PERC H730P
2x 2TB HDD in ZFS Mirror for Proxmox VM storage
8x 3.5” HDD chassis
NVIDIA RTX 3060 12GB
Intel X520-DA2 Dual SFP+

Lenovo ThinkCentre M720Q 1L PC (PVE3) (Tiny)
Intel i5 8500T
32GB RAM
256GB M.2 SSD
Intel X520-DA2 Dual SFP+

I also have a spare T330 which I could use if needed:
Dell PowerEdge T330
1x Intel Xeon E3-1220 v5 3.00Ghz (4C/4T)
32GB DDR4 ECC (2x 16GB)
8x 3.5” HDD chassis

All 3 nodes are running Proxmox.

These are the services I ran/run:
PiHole running in LXC
Tailscale running in LXC
Home Assistant OS running as VM
TrueNAS running as VM with HDDs passed through to it.
A few VMs running Docker with the following containers spread across them:

  • Jellyfin
  • *ARR suite
  • Pinchflat (replaced TubeArchivist)
  • Mealie
  • Dawarich
  • Actual Budget
  • Audio Bookshelf
  • SearXNG
  • OpenWeb UI and Ollama
  • Uptime-Kuma
  • LibreSpeed
  • Homer
  • Frigate
  • Immesh
  • PaperlessNGX

Now my question is I am seeking advice on the best way to setup my homelab (somewhat from scratch) so that it’s configured using “as code” with the configs in git. Is it just Ansible with the current way I’ve or do I look at Nix? or Cloud-init, Terraform? Also am I best to switch to using the T330 as a physical TrueNAS server rather than running it as VM on the T630 and passing through the drives to the VM? Open to all suggestions as to a better way to setup my homelab so that its not a snowflake…

Yes Ansible is good and you can use it but honestly I find it’s utility for a home lab a little limited. You can see an example here

Ansible is great for keeping a scripted deployment of your server

It’s less good for tracking the ongoing changes you make your self over time

You definitely want to keep your essential reusable configs in a GitLab / Bitbucket for yourself. But more frequently I find myself simply backing up the following locations

/home

/etc

/var

These tend to hold most of your custom configs. Anything you need to deploy into a new server that isn’t scripted is likely to be copy/pasted from these locations in your backup of the old server.

Also of course you’ll want to retain plenty of notes for yourself about your software choices, and things like BIOS changes you made, and documentation and websites you referred to and obtained software and containers from.

Ultimately I’ve found that these backups and notes and saved git items (e.g docker compose yamls) tend to get used far more often than the Ansible. The Ansible is mostly for the “bulk changes” needed for initial server deploy

You’re a little overanalyzing it. Keep it layered and basic:

Terraform is used to provision Proxmox virtual machines (VMs) using cloud-init templates.

inside virtual machines → set up using Ansible

Keep all docker-compose files in git for apps.

It is replicable based on it alone.

If you don’t want a new pastime, skip nix.

And sure, switch TrueNAS to T330 bare metal. There is no actual benefit to using ZFS + passthrough inside a virtual machine.

Reinstalling Proxmox, running Terraform, running Ansible, pulling Docker, and restoring ZFS data is the straightforward objective. finished.