Skip to content

MdShimulMahmud/proxmox-vm-terraform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Proxmox VM Provisioning with Terraform

This repository provides a minimal, opinionated Terraform configuration to provision virtual machines on Proxmox VE using the Telmate Proxmox provider.

Key Concepts

  • Declarative Infrastructure: Define your desired VM state in code (.tf files) and let Terraform provision and manage them.
  • Multi-VM Support: A vms map, defined in terraform.tfvars, is used with for_each to 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.

Requirements

  • 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.

Quickstart

  1. Configure Credentials: Copy terraform.tfvars.example to terraform.tfvars and fill in your Proxmox API URL, token ID, and secret.

  2. Initialize: Run terraform init to download the required provider plugins.

  3. Plan: Run terraform plan to see a preview of the resources Terraform will create, modify, or destroy.

  4. Apply: Run terraform apply to provision the VMs as defined in your configuration.


Configuration Structure

  • 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.

Example: Provisioning Multiple VMs

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"
  }
}

About

This repository provides a minimal, opinionated Terraform configuration to provision virtual machines on Proxmox VE using the Telmate Proxmox provider.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages