This project is a learning exercise in Infrastructure as Code, aka GitOps, using Proxmox, Packer, and Terraform to deploy a homelab environment with minimal overhead.
Packer is utilized to build both a cloud-init template for deploying virtual machines and CT templates for deploying LXC containers. The Packer plugin for Proxmox from Hashicorp is used to build the vm template, while distrobuilder is used in tandem to create the CT templates.
Once templates are built, Terraform can be used to deploy a live environment in moments via the Telmate Proxmox provider. This environment will include lxc containers running samba to share data and pi-hole to provide dns, and a docker virtual machine to run additional containers.
Various packages are included in the generated images, such as bat, btop, eza, ncdu, neovim, nnn, starship, tldr, and lazydocker (vm only).
- Host
- Install ProxmoxVE
- Run Proxmox VE Post Install script
- Create an API token with appropriate access
- Add SSH public key(s) to authorized_keys
- Configure storage
- Local
- Ensure local environment has Packer and Terraform installed
/packer- Copy template.pkrvars.hcl to secrets.auto.pkrvars.hcl and populate values
- Update http/user-data with your public ssh key and desired nonroot_user (Default is 'ubuntu')
- If changing default nonroot user, be sure to update /distrobuilder/ubuntu.yaml as well.
- Initialize Packer and run
packer build .to create container and VM templates
/terraform- Copy template.tfvars to secrets.auto.tfvars and populate values
- Initialize Terraform and run
terraform applyto deploy to target Proxmox node - SSH into the samba container to run
sudo passwd ubuntuandsudo smbpasswd -a ubuntu, completing samba user setup- Substitute your own nonroot_user value as needed
As configured, the project expects the following folder structure on the host:
-
/data-pool/container-data- This folder will be used for lxc and docker data
/pihole/setupVars.conf- This file is used for automated pi-hole setup
/share-data- This folder will be shared to the network
- Update README.md
- Known issue: Group permissions should be smb-share
- Docker integrations (portainer, lazydocker)
- Add aliases and configuration for installed packages (.bashrc, starship.toml, etc)
- Add variable descriptions and constraints
- Explore dynamic values for distrobuilder and packer user-data
- Investigate adding Ansible to reduce provisioning complexity