An installation used to be this one: the deploy scripts and the Ansible defaults carried one site's domain, hypervisor and login, the Proxmox side and the database were set up by hand, and deploying meant copying scripts and a tree of roles beside the binary and keeping them in step with it. The binary now carries the roles, the Terraform module, the schema and the catalogue (embed.go), and installs itself: - hpcod setup: a full-screen installer for administrators. It asks where clusters are built, signs in to Proxmox before asking anything else (root's password once, or tokens), offers nodes and datastores from what Proxmox has, checks every field as it is typed, runs every step with its output live, checks the result and offers a test cluster. -yes runs the same steps from a site file; make deploy uses that. - hpcod verify: each fact checked by using it. - hpcod selftest: the smallest real cluster, by the portal's own path, a job run on it, then taken down. - Closed networks: hpcod serves HTTPS itself from a CA name-constrained to the site's domains, issuing and renewing its own certificate, and answers DNS for the portal and every cluster name. - A simulated Proxmox: Proxmox VE in QEMU on the control plane host, on a private bridge with NAT, for trying it without one. Every step reads back what it changed and is safe to run again. The site's values live in one file; group_vars/all/site.yml is generated from it, and the playbooks refuse to run without it. ci_user and -ssh-user no longer default to a personal account. scripts/B10, B20 and C20 are gone: their work is the setup steps. Proven end to end on a simulated Proxmox (Proxmox VE 9 in a VM on a real host): the install, the Proxmox step by the password path, the head template, verify READY, and a test cluster that ran srun on its compute node and was destroyed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
206 lines
7.8 KiB
Terraform
206 lines
7.8 KiB
Terraform
# A tenant is who owns a cluster. A cluster is one provisioned HPC
|
|
# installation. They are not the same thing, and conflating them was a real
|
|
# defect: one tenant asking for a second cluster while the first was running
|
|
# would have reused its bridge, its subnet, its VM names and - worst - its
|
|
# MAC prefix, which is what Warewulf matches nodes by.
|
|
#
|
|
# So the numbers that must not collide are keyed on the cluster, and the
|
|
# tenant is carried alongside for attribution.
|
|
|
|
variable "cluster_id" {
|
|
description = "Numeric id of this cluster. Drives the bridge, subnet, VMID range, MAC prefix and public name, so it must be unique among clusters that exist at the same time - not among tenants."
|
|
type = number
|
|
validation {
|
|
condition = var.cluster_id >= 1 && var.cluster_id <= 254
|
|
error_message = "cluster_id must be between 1 and 254: it becomes a byte of the MAC address and the third octet of the cluster subnet. That bounds concurrent clusters, not tenants."
|
|
}
|
|
}
|
|
|
|
variable "tenant_id" {
|
|
description = "Who owns this cluster. Used for tags and accounting attribution only - never for addressing, because one tenant may hold several clusters at once."
|
|
type = number
|
|
}
|
|
|
|
variable "tenant_name" {
|
|
description = "Human-readable owner name, used in descriptions and tags only."
|
|
type = string
|
|
}
|
|
|
|
variable "node_name" {
|
|
description = "Proxmox node used for cluster-wide work: uploading the cloud-init snippet, and as the default hypervisor for any VM the placement does not name. This is not where the guests necessarily run - see head_host and compute_hosts."
|
|
type = string
|
|
}
|
|
|
|
# Placement is per VM, not per cluster. A cluster too large for one
|
|
# hypervisor is spread across several, and a cluster that needs a GPU has to
|
|
# land on the machine that has one. The planner works all of that out; until
|
|
# these variables existed there was nowhere to put the answer, so every VM
|
|
# went to node_name and the decision was thrown away.
|
|
|
|
variable "head_host" {
|
|
description = "Hypervisor for the head node. Empty means node_name."
|
|
type = string
|
|
default = ""
|
|
}
|
|
|
|
variable "compute_hosts" {
|
|
description = "Hypervisor for each compute node, in order. Empty means all of them go to node_name; otherwise there must be exactly compute.count entries, because a missing one is a VM nobody decided where to put."
|
|
type = list(string)
|
|
default = []
|
|
}
|
|
|
|
variable "datastore_id" {
|
|
description = "Storage for VM disks."
|
|
type = string
|
|
default = "zfspool"
|
|
}
|
|
|
|
variable "image_file_id" {
|
|
description = "Cloud image to import for the head node, as a Proxmox file id. Ignored when head_template_vmid is set."
|
|
type = string
|
|
default = ""
|
|
}
|
|
|
|
variable "head_template_vmid" {
|
|
description = "VMID of a prebuilt head node template to clone. Cloning skips the twelve minutes of package installation a tenant would otherwise wait through. Leave null to build from the cloud image instead."
|
|
type = number
|
|
default = null
|
|
}
|
|
|
|
variable "mgmt_bridge" {
|
|
description = "Existing bridge carrying the management network, where the head node gets its second NIC."
|
|
type = string
|
|
default = "vmbr0"
|
|
}
|
|
|
|
variable "mgmt_ip_cidr" {
|
|
description = "Head node management address, e.g. 10.0.0.60/24."
|
|
type = string
|
|
}
|
|
|
|
variable "mgmt_gateway" {
|
|
description = "Gateway on the management network."
|
|
type = string
|
|
}
|
|
|
|
variable "vmid_base" {
|
|
description = "First VMID for this cluster. Allocated from a recorded range rather than Proxmox's nextid, which races when two clusters are created at once."
|
|
type = number
|
|
}
|
|
|
|
variable "head" {
|
|
description = "Head node sizing. disk_gb must be at least the template's size, since a clone can grow but not shrink."
|
|
type = object({
|
|
cores = number
|
|
memory_gb = number
|
|
disk_gb = number
|
|
})
|
|
default = {
|
|
cores = 4
|
|
memory_gb = 8
|
|
# Room for the node image chroot and its compiled artefacts - about 6 GB
|
|
# today - plus the container images a tenant pulls for its applications.
|
|
# The head is per-tenant and released when the tenant is destroyed, so
|
|
# this is paid per concurrent tenant rather than permanently.
|
|
disk_gb = 120
|
|
}
|
|
|
|
validation {
|
|
condition = var.head.disk_gb >= 40
|
|
error_message = "head.disk_gb must be >= 40: the head template is 40 GB and a clone cannot shrink."
|
|
}
|
|
}
|
|
|
|
variable "compute" {
|
|
description = "Compute node sizing. memory_gb is what is ALLOCATED - the caller has already added the in-RAM rootfs reserve to the user's usable figure."
|
|
type = object({
|
|
count = number
|
|
cores = number
|
|
memory_gb = number
|
|
})
|
|
}
|
|
|
|
variable "ssh_public_keys" {
|
|
description = "Keys authorised on the head node."
|
|
type = list(string)
|
|
}
|
|
|
|
variable "ci_user" {
|
|
description = "cloud-init user created on the head node. No default: it is the account the control plane archives /home through, so it has to be the one the portal is told (-ssh-user), and both come from CI_USER in deploy/site.env."
|
|
type = string
|
|
}
|
|
|
|
variable "hostpci" {
|
|
description = "PCI devices to pass through, keyed by compute node index (1-based). Values are Proxmox host PCI ids such as 0000:01:00.0, as chosen by placement."
|
|
type = map(list(string))
|
|
default = {}
|
|
}
|
|
|
|
variable "started" {
|
|
description = "Whether to power the compute nodes on. They PXE boot from the head node, so they must stay off until Warewulf is configured."
|
|
type = bool
|
|
default = false
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Cloud-init snippets need a datastore whose content types include "snippets";
|
|
# an image datastore will not take them. Kept separate from datastore_id
|
|
# because the two are rarely the same store.
|
|
variable "snippet_datastore_id" {
|
|
type = string
|
|
default = null
|
|
description = "Datastore holding the cloud-init vendor data snippet. Null disables self-configuration, and the tenant must then be configured from the control plane."
|
|
}
|
|
|
|
# The SDN zone this cluster's vnet is created in. Referenced, never created:
|
|
# it is shared by every cluster on the site, and each Terraform state
|
|
# declaring it would mean several of them claiming the same object.
|
|
variable "sdn_zone" {
|
|
type = string
|
|
description = "Existing Proxmox SDN zone to place the cluster's vnet in."
|
|
}
|
|
|
|
# Only affects whether a VLAN tag is set. A simple zone gives each node its
|
|
# own isolated bridge, which is correct for a single-node site and cannot
|
|
# carry a cluster across two; vlan and vxlan can, and need the tag.
|
|
variable "sdn_zone_type" {
|
|
type = string
|
|
default = "simple"
|
|
validation {
|
|
condition = contains(["simple", "vlan", "vxlan", "evpn"], var.sdn_zone_type)
|
|
error_message = "sdn_zone_type must be one of: simple, vlan, vxlan, evpn."
|
|
}
|
|
}
|
|
|
|
# Application images this cluster should have, already resolved from the
|
|
# catalogue by the control plane. Names and URIs only: the head has no
|
|
# catalogue and needs none, which keeps deciding what an application is a
|
|
# platform concern rather than something every cluster re-derives.
|
|
variable "apps" {
|
|
type = list(object({
|
|
name = string
|
|
image = string
|
|
# optional(), so a cluster.auto.tfvars written before these existed
|
|
# still applies. A rebuild that failed at plan with "attribute
|
|
# sif_sha256 is required" would be this change breaking the clusters
|
|
# it was meant to protect.
|
|
digest = optional(string, "")
|
|
sif_sha256 = optional(string, "")
|
|
# What the head needs to make it runnable rather than merely present.
|
|
version = optional(string, "")
|
|
module = optional(string, "")
|
|
binaries = optional(list(string), [])
|
|
}))
|
|
default = []
|
|
description = "Resolved application images to fetch onto the cluster's shared /opt."
|
|
}
|
|
|
|
variable "control_plane_cert" {
|
|
description = "PEM certificate the cluster's portal will accept as its only client. Empty leaves the portal without a trusted client, which means nothing can reach it."
|
|
type = string
|
|
default = ""
|
|
}
|