hostname works

This commit is contained in:
counterweight 2025-11-02 01:48:07 +01:00
parent d4782d00cc
commit 9d43c19189
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
3 changed files with 25 additions and 24 deletions

View file

@ -9,9 +9,9 @@ resource "proxmox_vm_qemu" "vm" {
target_node = var.proxmox_node
vmid = try(each.value.vmid, null)
onboot = true
agent = 1
clone = var.template_name
onboot = true
agent = 1
clone = var.template_name
full_clone = true
vga {
type = "serial0"
@ -22,7 +22,7 @@ resource "proxmox_vm_qemu" "vm" {
cores = each.value.cores
type = "host"
}
memory = each.value.memory_mb
memory = each.value.memory_mb
scsihw = "virtio-scsi-pci"
boot = "c"
@ -42,18 +42,20 @@ resource "proxmox_vm_qemu" "vm" {
}
# Cloud-init: user, ssh keys, IP, and custom snippet for qemu-guest-agent
# Note: Using 'local' storage for snippets (not ZFS) as ZFS storage doesn't properly support snippet paths
ciuser = var.cloud_init_user
sshkeys = var.ssh_authorized_keys
# Note: Using vendor-data snippet (instead of user-data) allows Proxmox to automatically
# set the hostname from the VM name. User info is set separately via ciuser/sshkeys.
# Using 'local' storage for snippets (not ZFS) as ZFS storage doesn't properly support snippet paths
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"
cicustom = "vendor=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"
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
}

View file

@ -48,13 +48,13 @@ variable "ssh_authorized_keys" {
variable "vms" {
description = "Map of VMs to create"
type = map(object({
name = string
vmid = optional(number)
cores = number
memory_mb = number
disk_size_gb = number
vlan_tag = optional(number)
ipconfig0 = optional(string) # e.g. "ip=dhcp" or "ip=192.168.1.50/24,gw=192.168.1.1"
name = string
vmid = optional(number)
cores = number
memory_mb = number
disk_size_gb = number
vlan_tag = optional(number)
ipconfig0 = optional(string) # e.g. "ip=dhcp" or "ip=192.168.1.50/24,gw=192.168.1.1"
}))
default = {}
}