tf defined vms
This commit is contained in:
parent
6f42e43efb
commit
4d8e641466
7 changed files with 261 additions and 0 deletions
67
tofu/nodito/main.tf
Normal file
67
tofu/nodito/main.tf
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
locals {
|
||||
default_ipconfig0 = "ip=dhcp"
|
||||
}
|
||||
|
||||
resource "proxmox_vm_qemu" "vm" {
|
||||
for_each = var.vms
|
||||
|
||||
name = each.value.name
|
||||
target_node = var.proxmox_node
|
||||
vmid = try(each.value.vmid, null)
|
||||
|
||||
onboot = true
|
||||
agent = 1
|
||||
clone = var.template_name
|
||||
full_clone = true
|
||||
vga {
|
||||
type = "serial0"
|
||||
}
|
||||
|
||||
cpu {
|
||||
sockets = 1
|
||||
cores = each.value.cores
|
||||
type = "host"
|
||||
}
|
||||
memory = each.value.memory_mb
|
||||
|
||||
scsihw = "virtio-scsi-pci"
|
||||
boot = "c"
|
||||
bootdisk = "scsi0"
|
||||
|
||||
serial {
|
||||
id = 0
|
||||
type = "socket"
|
||||
}
|
||||
|
||||
# Network: bridge vmbr0, optional VLAN tag
|
||||
network {
|
||||
id = 0
|
||||
model = "virtio"
|
||||
bridge = "vmbr0"
|
||||
tag = try(each.value.vlan_tag, 0)
|
||||
}
|
||||
|
||||
# Cloud-init: user, ssh keys, IP, and custom snippet for qemu-guest-agent
|
||||
ciuser = var.cloud_init_user
|
||||
sshkeys = var.ssh_authorized_keys
|
||||
ipconfig0 = try(each.value.ipconfig0, local.default_ipconfig0)
|
||||
cicustom = "user=local:snippets/user-data-qemu-agent.yaml"
|
||||
|
||||
# Disk on ZFS storage
|
||||
disk {
|
||||
slot = "scsi0"
|
||||
type = "disk"
|
||||
storage = var.zfs_storage_name
|
||||
size = "${each.value.disk_size_gb}G"
|
||||
# optional flags like iothread/ssd/discard differ by provider versions; keep minimal
|
||||
}
|
||||
|
||||
# Cloud-init CD-ROM so ipconfig0/sshkeys apply
|
||||
disk {
|
||||
slot = "ide2"
|
||||
type = "cloudinit"
|
||||
storage = var.zfs_storage_name
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue