This is an example for using the proxmox/vm
module and the required variables. Get the release ID from the releases page.
module "<NAME>" {
# Required Variables
source = "git::https://github.com/shakir85/terraform_modules.git//proxmox/vm?ref=<RELEADE_ID>"
proxmox_node_name = ""
disk_name = ""
ssh_public_key_path = ""
username = ""
hostname = ""
timezone = ""
cloud_image_info = ["STORAGE_POOL", "CLOUD_IMAGE_FILE_NAME"]
disk_size = ""
# Optional Variables (default values presented below)
description = "Managed by Terraform"
tags = ["terraform"]
cores = 1
sockets = 1
memory = 512
temp_user_password = "changeme" # You'll be asked to change this password upon your first login
See provider's docs: bpg/proxmox before change the below optional vars
disk_interface = "scsi0"
network_interface = "vmbr0"
cpu_type = "qemu64"
}
# Print any output block from the main module
output "module_outputs" {
value = module.<NAME>
}
The following requirements are needed by this module:
The following providers are used by this module:
No modules.
The following resources are used by this module:
- proxmox_virtual_environment_file.cloud_config (resource)
- proxmox_virtual_environment_vm.vm_resource (resource)
- random_string.random_cloud_init_id (resource)
- local_file.ssh_public_key (data source)
The following input variables are required:
Description: A list of strings as the following:
index 0 for storage pool (disk) name where the cloud image iso, img, qcow... etc is stored.
index 1 for cloud-image file name (it must end with .img
extension)
For example: cloud_image_info: ["local-lvm", "debian-12-generic.qcow2.img"]
.
Type: list(string)
Description: Proxmox storage pool (disk name) where the VM's disk should be stored. The disk must support the Snippet storage type as it will be used for other resources.
Type: string
Description: Disk size in Gigabytes
Type: string
Description: VM hostname.
Type: string
Description: Proxmox node name. In a single-node environment, it's typically: pve
Type: string
Description: Path to the local public key to be added to the default user's .ssh/authorized_keys
file.
Type: string
Description: Timezone to be configured via timedatectl
in cloud-init template.
Type: string
Description: Default user. This will be a sudo user and have SSH login access.
Type: string
The following input variables are optional (have default values):
Description: The number of CPU cores.
Type: number
Default: 1
Description: The emulated CPU type. Some VMs need certain types of CPUs. See available values in the provider docs.
Type: string
Default: "qemu64"
Description: VM resource description.
Type: string
Default: "Managed by Terraform"
Description: Storage disk interface. Default value: scsi0
.
Type: string
Default: "scsi0"
Description: Whether to enable the QEMU guest agent. The qemu-guest-agent
must be installed and running. Read the 'Qemu guest agent' section in bpg/proxmox docs first.
Type: bool
Default: false
Description: The dedicated memory in megabytes
Type: number
Default: 512
Description: Default node's network device bridge. Default value: vmbr0
.
Type: string
Default: "vmbr0"
Description: The number of CPU sockets.
Type: number
Default: 1
Description: List of strings for tags. For example: ['terraform', 'ubuntu'].
Type: list(string)
Default:
[
"terraform"
]
Description: Temorary login password. Upon the first login, a prompt to change the password will be presented.
Type: string
Default: "changeme"
The following outputs are exported:
Description: Prints the temporary login password defined by var.temp_user_password
. Check the variable's default value above. You'll be required to change it on your first login.