Files
ilker f3241671ff hpcod: let the head node configure itself from cloud-init
The tenant playbook ran from the control plane, one SSH round trip per
task, for work that touches nothing but the head node. The template now
carries the automation, and Terraform hands each clone only its own
inventory as cloud-init vendor data; a first-boot unit runs the same
roles locally. The control plane drives Terraform and then watches a
status file instead of driving the provision itself - which is also
what makes this work unchanged against a provider that is not Proxmox.

Vendor data, not user data. Proxmox generates the user data that creates
the login account and installs its keys, and supplying our own would
replace that wholesale and lock the tenant out of its own head node.

Two things this surfaced, both invisible while the playbook ran over
SSH. systemd starts services with no HOME, and wwctl refuses to run
without one - a login shell had been supplying it. And the collections
were installed unpinned, which made the template a moving target; the
install already warned that current ansible.utils does not support the
ansible-core Rocky 9 ships. They are pinned to versions that do.

Node names, MACs and addresses were computed in four places - the VM
resource, two outputs, and now the inventory. They are computed once
and read from there. A MAC derived twice is exactly how a node ends up
PXE booting and never being recognised.

Measured, cold, destroy to a cluster running jobs on both nodes:
terraform 30s, self-configuration 82s, node PXE and Slurm 82s, total
194s against 215s. Less than the earlier estimate of ~60s off the
configure phase, and worth being precise about why: that estimate came
from timing a local run against an already-provisioned host, where most
tasks were no-ops. Cold against cold it is 100s remote to 78s local.
The rest of what the first-boot unit spends is waiting for cloud-init
to finish, which the old flow did not pay because it only waited for
sshd.
2026-09-02 07:16:29 +02:00

42 lines
1.1 KiB
Terraform

# Consumed by the provisioner to build the Ansible inventory.
output "bridge" {
description = "The tenant's isolated bridge."
value = local.bridge
}
output "subnet" {
description = "The tenant's cluster subnet."
value = "${local.subnet}.0/24"
}
output "head" {
description = "Head node facts."
value = {
vm_id = proxmox_virtual_environment_vm.head.vm_id
name = proxmox_virtual_environment_vm.head.name
mgmt_ip = split("/", var.mgmt_ip_cidr)[0]
cluster_ip = "${local.subnet}.1"
mgmt_mac = local.head_mgmt_mac
}
}
output "compute" {
description = "Compute node facts. The MAC/IP pairing is what Warewulf is configured with, so it must match nodes.conf exactly."
value = [
for i, node in local.compute_nodes : merge(node, {
vm_id = var.vmid_base + i + 1
})
]
}
output "ansible_inventory" {
description = "Ready to hand to ansible-playbook -i."
value = {
head_mgmt_ip = split("/", var.mgmt_ip_cidr)[0]
cluster_cidr = "${local.subnet}.0/24"
head_ip = "${local.subnet}.1"
nodes = local.compute_nodes
}
}