bootstrap: implement automated VM bootstrap mechanism for Phase 3
Add systemd service that automatically bootstraps freshly deployed VMs with their host-specific NixOS configuration from the flake repository. Changes: - hosts/template2/bootstrap.nix: New systemd oneshot service that: - Runs after cloud-init completes (ensures hostname is set) - Reads hostname from hostnamectl (set by cloud-init from Terraform) - Checks network connectivity via HTTPS (curl) - Runs nixos-rebuild boot with flake URL - Reboots on success, fails gracefully with clear errors on failure - hosts/template2/configuration.nix: Configure cloud-init datasource - Changed from NoCloud to ConfigDrive (used by Proxmox) - Allows cloud-init to receive config from Proxmox - hosts/template2/default.nix: Import bootstrap.nix module - terraform/vms.tf: Add cloud-init disk to VMs - Configure disks.ide.ide2.cloudinit block - Removed invalid cloudinit_cdrom_storage parameter - Enables Proxmox to inject cloud-init configuration - TODO.md: Mark Phase 3 as completed This eliminates the manual nixos-rebuild step from the deployment workflow. VMs now automatically pull and apply their configuration on first boot. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -24,6 +24,7 @@ locals {
|
||||
|
||||
# Example Minimal VM using all defaults (uncomment to deploy):
|
||||
# "minimal-vm" = {}
|
||||
# "bootstrap-verify-test" = {}
|
||||
}
|
||||
|
||||
# Compute VM configurations with defaults applied
|
||||
@@ -86,6 +87,13 @@ resource "proxmox_vm_qemu" "vm" {
|
||||
}
|
||||
}
|
||||
}
|
||||
ide {
|
||||
ide2 {
|
||||
cloudinit {
|
||||
storage = each.value.storage
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Start on boot
|
||||
|
||||
Reference in New Issue
Block a user