Skip to main content
Homelab as Code: Packer + Terraform + Ansible
Overview

Homelab as Code: Packer + Terraform + Ansible

2 min read (5 min read total)
4 subposts

This project automates a full homelab deployment — Packer builds the VM template, Terraform provisions it on Proxmox, and Ansible handles everything inside: Docker, Portainer, Traefik, and optional services like a media stack and Homepage dashboard.

Requirements

Note

This project deploys an Ubuntu VM with Docker, Portainer, Media Stack, Traefik, and more. You’ll need:

  1. Proxmox VE for VM management
  2. A fresh LXC to run the deploy script
  3. A DNS server configured for your service domains

Architecture and Source Code

Homelab Architecture Diagram

Source: meroxdotdev/homelab-as-code

What’s in the Repository

The repo covers everything needed to go from zero to a running VM with services:

  • Deploy script — installs dependencies (git, curl, ansible, packer, terraform), clones the repo, and runs the full pipeline
  • ansible/ — roles for Docker, Portainer, Traefik, and optional NFS mounts
  • configs/docker/ — pre-configured services: Homepage, Traefik, media stack
  • packer/ — builds an optimized Ubuntu template for Proxmox
  • terraform/ — VM provisioning with networking and storage, based on the Packer template

Quick Start

Run this on a clean LXC:

Terminal window
bash -c "$(curl -fsSL https://raw.githubusercontent.com/meroxdotdev/homelab-as-code/refs/heads/master/deploy_homelab.sh)"

What the Script Does

The script first asks whether your repository is public or private. For private repos, it generates an SSH key and prompts you to add it as a deploy key in your repo settings. For the public tutorial repo, use https://github.com/meroxdotdev/homelab-as-code.git directly.

Initial Prompt

Next, it asks whether you’ve already edited the required config files. Type yes to proceed with the Packer → Terraform → Ansible pipeline, or no to exit and review the guides below first.

Edit Confirmation Prompt

Downloaded config files land in /home/homelab/.

Configuration Guides

The setup is split across four subposts — go through them in order before running the script:

  1. Ansible Setup — inventory, roles, optional NFS mounts
  2. Services Configuration — Homepage, Media Stack, Traefik
  3. Infrastructure Setup — Packer and Terraform
  4. Deployment & Verification — final steps and checks

Share this post

Related Posts

Loading comments...