Managing a homelab can feel like navigating a maze of configurations, updates, and potential errors. But what if you could rebuild your entire setup in minutes? This blog introduces a solution that not only streamlines your homelab into an automated environment but also provides a learning experience, helping you better understand server management, automation, and networking.
Real Scenarios
Here are some practical examples of what you can achieve with this setup:
- Jellyfin Streaming: Imagine accessing your entire media library securely via Jellyfin, pre-configured with SSL, directly accessible from anywhere.
- Proxmox Management: Manage your Proxmox dashboard securely using a custom domain like
proxmox.yourdomain.com, with SSL automatically handled by Traefik. - Docker Management: Quickly deploy and manage all your containers in Portainer, accessible at
portainer.yourdomain.com.
Requirements
Note
This project will deploy Ubuntu Virtual Machine packed with commonly self-hosted tools like Docker, Portainer, Media Stack, Traefik, and more. Here’s what you’ll need:
- Proxmox VE: For creating and managing the VM.
- Fresh LXC: Required to run the script mentioned below.
- DNS Server: A properly configured DNS setup for service domains.
- Essentials: A few beers to keep the spirits high! 🍻
Tip
This guide is designed to document my homelab automation process, but it’s flexible enough to help anyone looking to simplify their IT environment. Let’s get started!
Resources
📊 Architecture Diagram: A high-level diagram of what we will implement in this blog
💻 Source Code: meroxdotdev/homelab-as-code
What’s Inside the Repository?
This repository simplifies homelab deployment with everything needed to set up an VM and associated services.
-
Interactive Deployment Script:
- Installs required packages (
git,curl,ansible,packer,terraform). - Clones the repository (supports both public and private setups).
- Runs Packer, Terraform and Ansible for fully automated deployment.
- Installs required packages (
-
Configuration Folders:
ansible: Includes roles for deploying Docker, Portainer, Traefik, and optional NFS mounts.configs/docker: Pre-configured services like getHomepage, Traefik, and media stack.packer: Builds an optimized Ubuntu template for Proxmox, ready for Terraform deployments.terraform: Automates VM creation with networking and storage configurations based on packer template.
Quick Start
Execute the following command:
bash -c "$(curl -fsSL https://raw.githubusercontent.com/meroxdotdev/homelab-as-code/refs/heads/master/deploy_homelab.sh)"Tip
Tip: Run this script on a clean LXC for best results.
Deployment Process
-
Initial Prompts
- First, the script will ask for the repository type (public or private).
- For a private repository, ensure you provide the SSH link (e.g.,
[email protected]:meroxdotdev/homelab.git) instead of HTTPS. - For a public repository, you can directly use this one tutorial-based:
https://github.com/meroxdotdev/homelab-as-code.git
- For a private repository, ensure you provide the SSH link (e.g.,
- If private is selected, the script generates an SSH key and prompts you to add the public key to your repository under Settings → Deploy Keys (e.g., in GitHub).

- First, the script will ask for the repository type (public or private).
-
Confirmation Prompt
- Next, the script asks if you’ve edited the necessary files for deployment.
- Type yes to proceed with the Packer, Terraform and Ansible automation.
- If you type no, review the blog for guidance on editing the required files, then re-run the script after making changes.

- Resources: You will find the downloaded configuration in
/home/homelab/
Navigating the Setup Guides
This homelab automation project involves configuring multiple components. To make this process easier, I’ve broken down the configuration into detailed subposts:
- Ansible Setup - Configure inventory, roles, and optional NFS mounts
- Services Configuration - Set up Homepage, Media Stack, and Traefik
- Infrastructure Setup - Configure Packer and Terraform for VM deployment
- Deployment & Post-Setup - Final deployment steps and verification
Each subpost provides detailed, step-by-step instructions for its respective component. Start with the Ansible setup and work through them sequentially for the best experience.