Skip to content

Getting Started

MuriloChianfa edited this page Aug 25, 2024 · 6 revisions

First of all, we need a fresh Proxmox installation, and the first step is to setup the terraform user.

1) Into the Proxmox shell as root:

pveum user add terraform@pve --password terraform
pveum aclmod / -user terraform@pve -role Terraform
pveum role modify Terraform -privs "Datastore.AllocateSpace Datastore.AllocateTemplate 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.Migrate VM.Monitor VM.PowerMgmt SDN.Use"
pveum user token add terraform@pve terraform-token --privsep=0

2) Now we need to create our cloud-init image:

apt update && apt install libguestfs-tools -y
mkdir cloud-init-images && cd cloud-init-images
wget https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-generic-amd64.qcow2
virt-customize -a debian-12-generic-amd64.qcow2 --install qemu-guest-agent --install resolvconf --install systemd-resolved --update --run-command 'mkdir -p /etc/network/interfaces.d' --run-command 'echo "auto ens18" >> /etc/network/interfaces.d/ens18' --run-command 'echo "iface ens18 inet manual" >> /etc/network/interfaces.d/ens18'

3) Setting up our debian template

qm create 9999 --name "debian12-cloudinit-template" --memory 1024 --net0 virtio,bridge=vmbr0
qm importdisk 9999 debian-12-generic-amd64.qcow2 nvme-lvm -format qcow2
qm set 9999 --scsihw virtio-scsi-pci --scsi0 nvme-lvm:vm-9999-disk-0
qm resize 9999 scsi0 10G
qm set 9999 --ide2 nvme-lvm:cloudinit
qm set 9999 --boot c --bootdisk scsi0
qm set 9999 --agent enabled=1
qm template 9999

4) Adding new VLANS into the Proxmox

First Create all VLANs inside the Proxmox Network environment

vlans

After this, make sure of u're natting these VLANs for outside communications

vlans-configuration

Your nat table would be like this

nat-table

We're ready to use the terraform in the next section Using Terraform.