Add automated workflow for building and deploying NixOS VMs on Proxmox including template2 host configuration, Ansible playbook for image building/deployment, and OpenTofu configuration for VM provisioning with cloud-init. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
91 lines
1.7 KiB
HCL
91 lines
1.7 KiB
HCL
# Example VM configuration - clone from template
|
|
# Before using this, you need to:
|
|
# 1. Upload the NixOS image to Proxmox
|
|
# 2. Restore it as a template VM (e.g., ID 9000)
|
|
# 3. Update the variables below
|
|
|
|
variable "target_node" {
|
|
description = "Proxmox node to deploy to"
|
|
type = string
|
|
default = "pve1"
|
|
}
|
|
|
|
variable "template_name" {
|
|
description = "Template VM name to clone from"
|
|
type = string
|
|
default = "nixos-25.11.20260128.fa83fd8"
|
|
}
|
|
|
|
variable "ssh_public_key" {
|
|
description = "SSH public key for root user"
|
|
type = string
|
|
default = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAwfb2jpKrBnCw28aevnH8HbE5YbcMXpdaVv2KmueDu6 torjus@gunter"
|
|
}
|
|
|
|
# Example test VM
|
|
resource "proxmox_vm_qemu" "test_vm" {
|
|
name = "nixos-test-tofu"
|
|
target_node = var.target_node
|
|
|
|
# Clone from template
|
|
clone = var.template_name
|
|
|
|
# Full clone (not linked)
|
|
full_clone = true
|
|
|
|
# Boot configuration
|
|
boot = "order=virtio0"
|
|
scsihw = "virtio-scsi-single"
|
|
|
|
# VM settings
|
|
cpu {
|
|
cores = 2
|
|
}
|
|
memory = 2048
|
|
|
|
# Network
|
|
network {
|
|
id = 0
|
|
model = "virtio"
|
|
bridge = "vmbr0"
|
|
tag = 13
|
|
}
|
|
|
|
# Disk settings
|
|
disks {
|
|
virtio {
|
|
virtio0 {
|
|
disk {
|
|
size = "20G"
|
|
storage = "local-zfs"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
# Start on boot
|
|
start_at_node_boot = true
|
|
|
|
# Agent
|
|
agent = 1
|
|
|
|
# Cloud-init configuration
|
|
ciuser = "root"
|
|
sshkeys = var.ssh_public_key
|
|
ipconfig0 = "ip=dhcp"
|
|
nameserver = "10.69.13.5 10.69.13.6"
|
|
searchdomain = "home.2rjus.net"
|
|
|
|
# Skip IPv6 since we don't use it
|
|
skip_ipv6 = true
|
|
|
|
rng {
|
|
source = "/dev/urandom"
|
|
period = 1000
|
|
}
|
|
}
|
|
|
|
output "test_vm_ip" {
|
|
value = proxmox_vm_qemu.test_vm.default_ipv4_address
|
|
}
|