Files
werewulf/hpcod/ansible/site.yml
T
ilkerandClaude Opus 5 ecbc951c59 hpcod: a cluster portal now needs a control plane session, which it did not
Taking the cluster's own login away and letting the proxy sign in with a
certificate did not make the portal private. It made it public: the proxy
sat outside the control plane's authentication on purpose, back when the
cluster had a password of its own to fall back on. I found it by fetching
c001's dashboard from the internet with no session and getting it.

The proxy now asks before it opens a connection: a valid session, and the
cluster has to belong to whoever is asking, or be reached by an
administrator. A browser is sent to sign in, an API client gets 401, and
nothing is proxied either way.

The check runs before the registry is consulted, so a signed-out caller
gets the same answer for a cluster that exists and one that does not.

Also tagged the roles in site.yml. Changing the portal meant re-running
everything, which rebuilds the node image - four minutes and a risk taken
for nothing. Dynamic includes need "apply" for the tag to reach the
role's own tasks; a tag on the include alone only decides whether the
include runs.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-21 13:27:04 +02:00

110 lines
3.7 KiB
YAML

---
# Configure one tenant HPC cluster on the head node Terraform created.
#
# Order matters and is not arbitrary:
# common - hostname, packages, firewall, forwarding
# warewulf - install, point at the tenant subnet, start provisioning
# node_image - the rootfs the compute nodes will boot
# slurm - OpenHPC, MUNGE, the hpc overlay carrying config to nodes
# warewulf_nodes- register the MAC/IP pairs and build overlays
#
# slurm runs before warewulf_nodes because the overlay it creates has to exist
# before the final overlay build, otherwise the nodes boot without slurm.conf
# or the MUNGE key and come up unable to join the cluster.
- name: Provision the tenant head node
hosts: head
become: true
# Facts are gathered after the wait below, not before it: gathering opens a
# connection, and at this point in a provision there may not be one yet.
gather_facts: false
pre_tasks:
# Terraform returns as soon as Proxmox has started the VM, but cloud-init
# has not yet written the authorised keys, so the first connection is
# refused. Without this gate the playbook fails with a bare "Permission
# denied" that reads like a wrong key rather than a race.
- name: Wait for the head node to accept SSH
ansible.builtin.wait_for_connection:
timeout: 300
sleep: 5
- name: Gather facts
ansible.builtin.setup:
- name: Fail early if the inventory is missing the tenant's fabric
ansible.builtin.assert:
that:
- compute_nodes is defined
- compute_nodes | length > 0
- cluster_id is defined
- cluster_cidr is defined
- head_cluster_ip is defined
- dhcp_range_start is defined
- dhcp_range_end is defined
fail_msg: >-
The inventory must supply the tenant's own addresses and node list.
These have no defaults on purpose: a default would override the
inventory rather than fall back to it. compute_nodes in particular
must come from the Terraform output, because Warewulf matches nodes
by MAC - a guessed one produces a cluster that never boots.
# Tagged so one part can be re-run on its own. Re-running everything to
# change the portal would rebuild the node image too - four minutes and
# a risk taken for nothing.
roles:
- { role: common, tags: [common] }
- { role: warewulf, tags: [warewulf] }
- { role: node_image, tags: [node_image] }
tasks:
- name: Slurm and OpenHPC
ansible.builtin.include_role:
name: slurm
apply:
tags: [slurm]
tags: [slurm]
- name: Register the compute nodes
ansible.builtin.include_role:
name: warewulf_nodes
apply:
tags: [nodes]
tags: [nodes]
# After the scheduler exists, because the portal's cluster definition
# discovers the Slurm binaries and asks slurmctld what it is called.
# Before the portal, so a user who logs in finds the software already
# there rather than arriving during their first session.
- name: Application images
ansible.builtin.include_role:
name: apps
apply:
tags: [apps]
tags: [apps]
- name: User-facing portal
ansible.builtin.include_role:
name: ondemand
apply:
tags: [ondemand]
tags: [ondemand]
- name: Verify the head node
ansible.builtin.include_role:
name: verify
apply:
tags: [verify]
tags: [verify]
- name: Verify the whole cluster once the nodes are up
hosts: head
become: true
gather_facts: false
tags: [cluster, never]
tasks:
- name: Cluster checks
ansible.builtin.include_role:
name: verify
tasks_from: cluster