A Terraform module for creating and managing Proxmox VMs using the Proxmox provider.
- Create single or multiple VMs
- Support for cloning from existing templates
- Cloud-init configuration
- Flexible CPU and memory allocation
- Network configuration
- Storage management
- Predefined instance sizes (xsmall, small, medium, large, xlarge)
- NEW (feature/expansion): Multiple network interfaces support
- NEW (feature/expansion): Additional disk configurations
module "example_vm" {
source = "./modules/pvevm"
name = "example-vm"
target_node = "pve-node-1"
clone = "ubuntu-template"
storage = "local-lvm"
instance_size = "medium"
# Network configuration
bridge = "vmbr0"
model = "virtio"
# Cloud-init configuration
ciuser = "ubuntu"
cipassword = "your-password"
sshkeys = file("~/.ssh/id_rsa.pub")
}locals {
vms = {
web1 = {
name = "web-1"
target_node = "pve-node-1"
clone = "ubuntu-template"
storage = "local-lvm"
instance_size = "small"
ipconfig0 = "ip=192.168.10.11/24,gw=192.168.10.1"
}
db1 = {
name = "db-1"
target_node = "pve-node-2"
clone = "ubuntu-template"
storage = "nvme2-ceph"
instance_size = "medium"
ipconfig0 = "ip=192.168.10.21/24,gw=192.168.10.1"
}
}
}
module "vm" {
source = "./modules/pvevm"
for_each = local.vms
name = each.value.name
target_node = each.value.target_node
clone = each.value.clone
storage = each.value.storage
instance_size = each.value.instance_size
# Optional overrides
ipconfig0 = try(each.value.ipconfig0, null)
ipconfig1 = try(each.value.ipconfig1, null)
networks = try(each.value.networks, [])
additional_disks = try(each.value.additional_disks, [])
}To consume outputs with for_each, access them per key or build a map:
# Per-VM access
module.vm["web1"].vm_id
# Build a map of IDs keyed by VM key
locals {
vm_ids = { for k, m in module.vm : k => m.vm_id }
}| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| name | The name of the VM within Proxmox | string |
n/a | yes |
| target_node | The name of the Proxmox Node on which to place the VM | string |
null |
no |
| clone | The base VM from which to clone to create the new VM | string |
n/a | yes |
| storage | Disk Storage Location | string |
n/a | yes |
| instance_size | The size of the instance (xsmall, small, medium, large, xlarge) | string |
"" |
no |
| cpu | CPU configuration block | object |
null |
no |
| memory | The amount of memory to allocate to the VM in Megabytes | number |
null |
no |
| size | Disk Size | string |
null |
no |
| Name | Description |
|---|---|
| vm_ip | List of VM IP addresses |
| vm_name | List of VM names |
| vm_id | List of VM IDs |
| vm_vcpus | List of VM vCPU counts |
| vm_memory | List of VM memory allocations |
| vm_notes | List of VM descriptions/notes |
| vm_tags | List of VM tags |
The module provides predefined instance sizes for quick deployment:
| Size | Memory | Cores | Sockets | vCores | Disk |
|---|---|---|---|---|---|
| xsmall | 2GB | 1 | 1 | 1 | 10GB |
| small | 4GB | 2 | 1 | 2 | 12GB |
| medium | 8GB | 4 | 1 | 4 | 20GB |
| large | 16GB | 8 | 1 | 8 | 40GB |
| xlarge | 32GB | 10 | 1 | 10 | 60GB |
The feature/expansion branch adds powerful new capabilities:
-
Multiple Network Interfaces
- Configure VMs with multiple NICs
- Support for different VLANs per interface
- Advanced network options (rate limiting, firewall, queues)
- Backward compatible with single network configuration
-
Additional Disk Support
- Add multiple additional disks (scsi2-scsi5)
- Per-disk configuration (SSD, cache, backup, iothread)
- Flexible storage allocation
- Primary disk still configured via instance_size
Example:
module "advanced_vm" {
source = "github.com/valueiron/pvevm.git?ref=feature/expansion"
# ... basic config ...
networks = [
{ bridge = "vmbr0", tag = 100 }, # Management
{ bridge = "vmbr0", tag = 200 } # Data
]
additional_disks = [
{ type = "scsi", slot = 2, storage = "nvme2-ceph", size = "100G", ssd = true },
{ type = "scsi", slot = 3, storage = "local-lvm", size = "500G" }
]
}See examples/multiple-networks-disks.md for detailed examples.
This module has been updated to use Proxmox provider v3.0.2-rc03 with the following changes:
- Provider Version: Updated from
3.0.1-rc8to3.0.2-rc03 - Description Field:
descparameter changed todescription - CPU Configuration: Individual
cores,sockets, andvcpusparameters replaced with acpublock containing:cores: Number of CPU cores per socketsockets: Number of CPU socketsvcores: Total number of virtual CPUs
The module maintains backward compatibility by still supporting the old individual parameters.
This module is licensed under the MIT License.
| Name | Version |
|---|---|
| terraform | >= 0.13.0 |
| proxmox | 3.0.2-rc03 |
| Name | Version |
|---|---|
| proxmox | 3.0.2-rc03 |
No modules.
| Name | Type |
|---|---|
| proxmox_vm_qemu.pvevm | resource |
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| additional_disks | Additional disks to attach (beyond scsi0 boot and cloud-init) | list(object({ |
[] |
no |
| agent | Enable QEMU Guest Agent (1 enabled, 0 disabled) | number |
1 |
no |
| bridge | Network bridge to attach NICs to (e.g., vmbr0) | string |
"vmbr0" |
no |
| cipassword | Cloud-init user password | string |
n/a | yes |
| ciuser | Cloud-init default user | string |
n/a | yes |
| clone | Source template or VM name to clone | string |
n/a | yes |
| cores | CPU cores per socket | number |
null |
no |
| cpu | Explicit CPU configuration (overrides cores/sockets/vcpus variables) | object({ |
null |
no |
| id | NIC device ID/index as required by the provider | number |
0 |
no |
| instance_size | Preset size key (xsmall, small, medium, large, xlarge). Empty to use custom values | string |
"" |
no |
| instance_sizes | Map of size presets defining memory, cores, sockets, vcores, and disk size | map(object({ |
{ |
no |
| ipconfig0 | Cloud-init IP config for NIC 0 (e.g., ip=192.168.1.10/24,gw=192.168.1.1) | string |
"ip=dhcp" |
no |
| ipconfig1 | Cloud-init IP config for NIC 1 (same format as ipconfig0) | string |
null |
no |
| memory | Memory allocated to the VM in MiB | number |
null |
no |
| model | NIC model (e.g., virtio, e1000) | string |
"virtio" |
no |
| name | VM name as it will appear in Proxmox | string |
n/a | yes |
| nameserver | Default DNS server for the guest | string |
null |
no |
| networks | Optional NIC list. If empty, a single NIC is built from bridge/model/tag | list(object({ |
[] |
no |
| notes | Proxmox VM description/notes | string |
"Managed by Terraform." |
no |
| ostype | OS type. Use 'cloud-init' for cloud-init templates | string |
"cloud-init" |
no |
| pool | Destination Proxmox resource pool | string |
null |
no |
| scsihw | SCSI controller model | string |
"virtio-scsi-pci" |
no |
| searchdomain | Default DNS search domain suffix | string |
null |
no |
| serial0 | Serial device index for console access | number |
0 |
no |
| size | Boot disk size (e.g., 20G) | string |
null |
no |
| sockets | Number of CPU sockets | number |
null |
no |
| sshkeys | Newline-delimited SSH public keys for the cloud-init user | string |
n/a | yes |
| storage | Proxmox storage target for disks (e.g., local-lvm, nvme2-ceph) | string |
n/a | yes |
| tag | 802.1Q VLAN ID | number |
null |
no |
| tags | Comma-separated tags stored on the VM | string |
"" |
no |
| target_node | Preferred Proxmox node to place the VM | string |
null |
no |
| target_nodes | List of Proxmox nodes eligible for placement | list(string) |
null |
no |
| vcpus | Total virtual CPUs (threads) | number |
null |
no |
| vmid | Proxmox VM ID. Use 0 to auto-assign the next available ID | number |
0 |
no |
| Name | Description |
|---|---|
| vm_id | VM ID |
| vm_ip | VM IPv4 Address |
| vm_memory | VM Memory |
| vm_name | VM Name |
| vm_nameserver | VM Nameserver |
| vm_notes | VM Notes |
| vm_tags | VM Tags |
| vm_vcpus | VM VCPUS |