2025-06-25 19:32:38 +02:00
2025-06-17 20:02:00 +02:00
2025-06-09 11:58:11 +02:00

iac-homelab

Description

This repository contains Infrastructure as Code (IaC) configurations for a home lab environment. It includes Terraform scripts for provisioning infrastructure resources and Ansible playbooks for configuring those resources.

Usage

Prerequisites

  • Terraform installed on your machine
  • Ansible installed on your machine
  • Proxmox VE installed on homelab

Proxmox Role and User

The Proxmox role is responsible for configuring Proxmox VE on the homelab. It includes tasks for setting up the Proxmox VE cluster, creating virtual machines, and configuring storage.

Following the least privilege principle, the role creates a dedicated user account with limited permissions for managing the Proxmox VE cluster.

pveum role add TerraformProv -privs "Datastore.Allocate Datastore.AllocateSpace Datastore.Audit Pool.Allocate Sys.Audit Sys.Console Sys.Modify VM.Allocate VM.Audit VM.Clone VM.Config.CDROM VM.Config.Cloudinit VM.Config.CPU VM.Config.Disk VM.Config.HWType VM.Config.Memory VM.Config.Network VM.Config.Options VM.Console VM.Migrate VM.Monitor VM.PowerMgmt SDN.Use"

Create a dedicated user account with limited permissions for managing the Proxmox VE cluster.

pveum user add terraform@pve --password <password>
pveum acl modify / -user terraform@pve -role TerraformProv

Generate API keys for the Proxmox VE cluster.

pveum user token add terraform@pve terraform -expire 0 -privsep 0 -comment "Terraform token"

Provisioning Infrastructure

  1. Clone this repository to your local machine.
  2. Navigate to the terraform/prod directory.
  3. Run terraform init to initialize the Terraform environment.
  4. Run terraform plan to preview the infrastructure changes.
  5. Run terraform apply to apply the infrastructure changes.

Configuring Infrastructure

  1. Navigate to the ansible directory.
  2. Run ansible-playbook playbooks/setup_dns_server.yml to set up the DNS server. (Or ansible-playbook playbooks/update_dns_records.yml to update DNS records).
Description
This repository contains Infrastructure as Code (IaC) configurations for a home lab environment.
Readme 209 KiB
Languages
HCL 100%