Replace SSH upload approach with native proxmox_cloud_init_disk resource for cleaner, more maintainable cloud-init management. Changes: - Use proxmox_cloud_init_disk for all VMs (not just branch-specific ones) - Include SSH keys, network config, and metadata in cloud-init disk - Conditionally include NIXOS_FLAKE_BRANCH for VMs with flake_branch set - Replace ide2 cloudinit disk with cdrom reference to cloud-init disk - Remove built-in cloud-init parameters (ciuser, sshkeys, etc.) - Remove cicustom parameter (no longer needed) - Remove proxmox_host variable (no SSH uploads required) - Remove .gitignore entry for .generated/ directory Benefits: - No SSH access to Proxmox required - All cloud-init config managed in Terraform - Consistent approach for all VMs - Cleaner state management Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
52 lines
1.3 KiB
HCL
52 lines
1.3 KiB
HCL
# Cloud-init configuration for all VMs
|
|
#
|
|
# This file manages cloud-init disks for all VMs using the proxmox_cloud_init_disk resource.
|
|
# VMs with flake_branch set will include NIXOS_FLAKE_BRANCH environment variable.
|
|
|
|
resource "proxmox_cloud_init_disk" "ci" {
|
|
for_each = local.vm_configs
|
|
|
|
name = each.key
|
|
pve_node = each.value.target_node
|
|
storage = each.value.storage
|
|
|
|
# User data includes SSH keys and optionally NIXOS_FLAKE_BRANCH
|
|
user_data = <<-EOT
|
|
#cloud-config
|
|
ssh_authorized_keys:
|
|
- ${each.value.ssh_public_key}
|
|
${each.value.flake_branch != null ? <<-BRANCH
|
|
write_files:
|
|
- path: /etc/environment
|
|
content: |
|
|
NIXOS_FLAKE_BRANCH=${each.value.flake_branch}
|
|
append: true
|
|
BRANCH
|
|
: ""}
|
|
EOT
|
|
|
|
# Network configuration - static IP or DHCP
|
|
network_config = yamlencode({
|
|
version = 1
|
|
config = [{
|
|
type = "physical"
|
|
name = "ens18"
|
|
subnets = each.value.ip != null ? [{
|
|
type = "static"
|
|
address = each.value.ip
|
|
gateway = each.value.gateway
|
|
dns_nameservers = split(" ", each.value.nameservers)
|
|
dns_search = [each.value.search_domain]
|
|
}] : [{
|
|
type = "dhcp"
|
|
}]
|
|
}]
|
|
})
|
|
|
|
# Instance metadata
|
|
meta_data = yamlencode({
|
|
instance_id = sha1(each.key)
|
|
local-hostname = each.key
|
|
})
|
|
}
|