Skip to content

valueiron/pvevm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Proxmox VM Terraform Module

A Terraform module for creating and managing Proxmox VMs using the Proxmox provider.

Features

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

Requirements

Provider Configuration

Usage

Basic Example

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

Inputs

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

Outputs

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

Instance Sizes

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

Recent Changes

v3.0.2-rc03 Upgrade

This module has been updated to use Proxmox provider v3.0.2-rc03 with the following changes:

  1. Provider Version: Updated from 3.0.1-rc8 to 3.0.2-rc03
  2. Description Field: desc parameter changed to description
  3. CPU Configuration: Individual cores, sockets, and vcpus parameters replaced with a cpu block containing:
    • cores: Number of CPU cores per socket
    • sockets: Number of CPU sockets
    • vcores: Total number of virtual CPUs

The module maintains backward compatibility by still supporting the old individual parameters.

License

This module is licensed under the MIT License.

Requirements

Name Version
terraform >= 0.13.0
proxmox 3.0.2-rc03

Providers

Name Version
proxmox 3.0.2-rc03

Modules

No modules.

Resources

Name Type
proxmox_vm_qemu.pvevm resource

Inputs

Name Description Type Default Required
agent Qemu Guest Agent Enabled or not enabled=1 number 1 no
bridge Map of tags to add to the VM. Stored as JSON in the Notes field in Proxmox. string "vmbr0" no
cipassword Override the default cloud-init user's password string n/a yes
ciuser Override the default cloud-init user for provisioning string n/a yes
clone The base VM from which to clone to create the new VM string n/a yes
connection Provisioner connection settings map(string)
{
"agent": true,
"type": "ssh"
}
no
cores The number of CPU cores per CPU socket to allocate to the VM number null no
cpu CPU configuration block
object({
cores = number
sockets = number
vcores = number
})
null no
disks VM disk config list(map(string))
[
{}
]
no
gateway Gateway IP Address string "" no
id New required field proxmox number 0 no
instance_count Instance Count number 1 no
instance_size The size of the instance (small, medium, large). If empty, custom values must be provided. string "" no
instance_sizes Map of instance sizes with predefined settings
map(object({
memory = number
cores = number
sockets = number
vcores = number
size = string
}))
{
"large": {
"cores": 8,
"memory": 16384,
"size": "40G",
"sockets": 1,
"vcores": 8
},
"medium": {
"cores": 4,
"memory": 8192,
"size": "20G",
"sockets": 1,
"vcores": 4
},
"small": {
"cores": 2,
"memory": 4096,
"size": "12G",
"sockets": 1,
"vcores": 2
},
"xlarge": {
"cores": 10,
"memory": 32768,
"size": "60G",
"sockets": 1,
"vcores": 10
},
"xsmall": {
"cores": 1,
"memory": 2048,
"size": "10G",
"sockets": 1,
"vcores": 1
}
}
no
ip_addresses List of IP addresses with cidr notation list(string) [] no
ipconfig0 The first IP address to assign to the guest. Format: [gw=] [,gw6=] [,ip=<IPv4Format/CIDR>] [,ip6=<IPv6Format/CIDR>] string "ip=dhcp" no
ipconfig1 The second IP address to assign to the guest. Same format as ipconfig0 string null no
ipconfig2 The third IP address to assign to the guest. Same format as ipconfig0 string null no
memory The amount of memory to allocate to the VM in Megabytes number null no
model Network Model string "virtio" no
name The name of the VM within Proxmox string n/a yes
nameserver Sets default DNS server for guest string null no
networks VM network adapter config list(map(string))
[
{}
]
no
notes VM notes field that maps to desc string "Managed by Terraform." no
ostype The OS Type string "cloud-init" no
pool The destination resource pool for the new VM string null no
proxmox_api_token_id API Token string n/a yes
proxmox_api_token_secret API Secret string n/a yes
proxmox_api_url Full Proxmox API URL string n/a yes
proxmox_tls_insecure Allow Insecure TLS bool true no
scsihw scsi hardware type string "virtio-scsi-pci" no
searchdomain Sets default DNS search domain suffix string null no
serial0 serial device in order for console device to work number 0 no
size Disk Size string null no
sockets The number of CPU sockets to allocate to the VM number null no
sshkeys Newline delimited list of SSH public keys to add to authorized keys file for the cloud-init user string n/a yes
storage Disk Storage Location string n/a yes
tag Vlan ID number null no
tags tags comma seperated string "" no
target_node The name of the Proxmox Node on which to place the VM string null no
target_nodes The name of the Proxmox Node on which to place the VM list(string) null no
vcpus The number of vCPU to allocate to the VM number null no
vmid The vm id of the VM within Proxmox. Default is next available number 0 no

Outputs

Name Description
vm_id VM IDS
vm_ip VM IP Addresses
vm_memory VM Memory
vm_name VM NAMES
vm_nameserver VM Nameservers
vm_notes VM Notes
vm_tags VM Tags
vm_vcpus VM VCPUS

About

Terraform Module for proxmox using Telmate/terraform-provider-proxmox

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages