This repository provides a minimal, opinionated Terraform configuration to provision virtual machines on Proxmox VE using the Telmate Proxmox provider.
- Declarative Infrastructure: Define your desired VM state in code (
.tffiles) and let Terraform provision and manage them. - Multi-VM Support: A
vmsmap, defined interraform.tfvars, is used withfor_eachto provision multiple VMs from a single configuration. - Secrets Management: Provider credentials are kept out of source control. Use
terraform.tfvars(ignored by Git) for local development or environment variables (TF_VAR_...) for automated environments like CI/CD.
- Proxmox VE: Access to a Proxmox API with an appropriate user and token.
- Terraform: A local install of the Terraform CLI.
- Proxmox Template: A suitable template (preferably configured for cloud-init) for cloning.
-
Configure Credentials: Copy
terraform.tfvars.exampletoterraform.tfvarsand fill in your Proxmox API URL, token ID, and secret. -
Initialize: Run
terraform initto download the required provider plugins. -
Plan: Run
terraform planto see a preview of the resources Terraform will create, modify, or destroy. -
Apply: Run
terraform applyto provision the VMs as defined in your configuration.
variables.tf: Defines the global defaults for provider settings and VM properties (e.g., default cores, memory, disk size).terraform.tfvars: Overrides the global defaults for specific VMs. This is where you'll define the names, nodes, and any custom settings for each VM you want to provision.
Add entries to the vms map in your terraform.tfvars file to define your VMs. Any property not specified will fall back to its default value from variables.tf.
vms = {
web_server = {
name = "web-01"
clone_template = "ubuntu-22.04-template"
cores = 2
memory = 4096
disk_size = "40G"
}
db_server = {
name = "db-01"
clone_template = "debian-11-template"
cores = 4
memory = 8192
disk_size = "100G"
}
}