68 lines
1.0 KiB
Terraform
68 lines
1.0 KiB
Terraform
resource "proxmox_virtual_environment_vm" "vm" {
|
|
name = var.vm_name
|
|
node_name = "proxmox"
|
|
vm_id = var.vm_id
|
|
|
|
clone {
|
|
vm_id = 9001 # debian-12-cloud template
|
|
full = true
|
|
}
|
|
|
|
agent {
|
|
enabled = true
|
|
}
|
|
|
|
cpu {
|
|
cores = var.vm_cores
|
|
type = "x86-64-v2-AES"
|
|
}
|
|
|
|
memory {
|
|
dedicated = var.vm_memory
|
|
}
|
|
|
|
scsi_hardware = "virtio-scsi-single"
|
|
|
|
disk {
|
|
datastore_id = "local-lvm"
|
|
interface = "scsi0"
|
|
size = var.vm_disk_size
|
|
discard = "on"
|
|
iothread = true
|
|
}
|
|
|
|
network_device {
|
|
bridge = "vmbr0"
|
|
model = "virtio"
|
|
}
|
|
|
|
operating_system {
|
|
type = "l26"
|
|
}
|
|
|
|
initialization {
|
|
datastore_id = "local-lvm"
|
|
|
|
ip_config {
|
|
ipv4 {
|
|
address = "dhcp"
|
|
}
|
|
}
|
|
|
|
user_account {
|
|
username = "debian"
|
|
keys = [var.ssh_public_key]
|
|
}
|
|
}
|
|
|
|
lifecycle {
|
|
ignore_changes = [
|
|
initialization[0].user_account[0].password,
|
|
]
|
|
}
|
|
}
|
|
|
|
output "vm_ipv4_address" {
|
|
value = proxmox_virtual_environment_vm.vm.ipv4_addresses
|
|
}
|