SRC: https://registry.terraform.io/providers/Telmate/proxmox/latest
root@proxmox:~# pveum role modify terraform_role -privs “Datastore.AllocateSpace
Datastore.AllocateTemplate Datastore.Audit Pool.Allocate Sys.Audit Sys.Console Sys.Mod
ify VM.Allocate VM.Audit VM.Clone VM.Config.CDROM VM.Config.Cloudinit VM.Config.CPU VM
.Config.Disk VM.Config.HWType VM.Config.Memory VM.Config.Network VM.Config.Options VM.
Migrate VM.PowerMgmt SDN.Use”curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add –
sudo apt-add-repository “deb [arch=$(dpkg –print-architecture)] https://apt.releases.hashicorp.com $(lsb_release -cs) main”
sudo apt update
sudo apt install terraformSRC: https://registry.terraform.io/providers/Telmate/proxmox/latest/docs/resources/vm_qemu
[Main.tf]
terraform {
required_providers {
proxmox = {
source = “Telmate/proxmox”
version = “3.0.2-rc05”
}
}
}provider “proxmox” {
pm_api_url = “https://192.168.0.xxx:8006/api2/json”
pm_user = “terraform”
pm_api_token_id = “terraform@pve!terraformAPI”
pm_api_token_secret = “19ca604a-xxxx”
#pm_password = “NotMyPazzsword”
pm_tls_insecure = true
pm_debug = true
}resource “proxmox_vm_qemu” “my_vm” {
name = “my-vm”
target_node = “threadripper”
clone = “UbuntuWorkstation1”
cores = 2
memory = 2048
disk {
storage = “local-zfs”
type = “disk”
slot = “scsi0”
size = “32G”
}
}user@user-Standard-PC-i440FX-PIIX-1996:~$ nano main.tf
user@user-Standard-PC-i440FX-PIIX-1996:~$ terraform init
Initializing the backend…
Initializing provider plugins…
- Finding telmate/proxmox versions matching “3.0.2-rc05″…
- Installing telmate/proxmox v3.0.2-rc05…
- Installed telmate/proxmox v3.0.2-rc05 (self-signed, key ID A9EBBE091B35AFCE)
Partner and community providers are signed by their developers.
If you’d like to know more about provider signing, you can read about it here:
https://developer.hashicorp.com/terraform/cli/plugins/signing
Terraform has created a lock file .terraform.lock.hcl to record the provider
selections it made above. Include this file in your version control repository
so that Terraform can guarantee to make the same selections by default when
you run “terraform init” in the future.Terraform has been successfully initialized!
user@user-Standard-PC-i440FX-PIIX-1996:~$ terraform plan
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the
following symbols:
- create
Terraform will perform the following actions:
# proxmox_vm_qemu.my_vm will be created
- resource “proxmox_vm_qemu” “my_vm” {
- additional_wait = 5
- agent = 0
- agent_timeout = 90
- automatic_reboot = true
- automatic_reboot_severity = “error”
- balloon = 0
- bios = “seabios”
- boot = (known after apply)
- bootdisk = (known after apply)
… user@user-Standard-PC-i440FX-PIIX-1996:~$ terraform apply
proxmox_vm_qemu.my_vm: Creating…
proxmox_vm_qemu.my_vm: Still creating… [00m10s elapsed]
proxmox_vm_qemu.my_vm: Still creating… [00m20s elapsed]
proxmox_vm_qemu.my_vm: Creation complete after 29s [id=threadripper/qemu/155]
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.