Files
ilkerandClaude Opus 5.5 772579648c hpcod: one binary installs, checks and tests the control plane
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>
2026-11-16 18:20:04 +01:00

162 lines
6.3 KiB
YAML

---
# Build the golden head node: everything a tenant head node needs installed,
# and nothing that identifies a tenant.
#
# The split matters. Anything installed here is paid for once, at build time.
# Anything left to site.yml is paid for by every tenant, while a user waits.
#
# ansible-playbook -i inventory/golden.yml golden.yml
- name: Install the head node software stack
hosts: golden
become: true
gather_facts: true
# compute_nodes is required by site.yml but meaningless for a template, so
# the install-tagged tasks are run without it.
vars:
compute_nodes: []
# The template carries this directory, site.yml included, into every head
# node built from it - so a template baked without the site's values
# produces clusters that fail on first boot, one at a time, after the
# machines are already up. Refused here instead, at build time.
pre_tasks:
- name: Refuse to bake a template without the site's own values
ansible.builtin.assert:
that:
- node_image_uri | default('') | length > 0
- registry_host | default('') | length > 0
- ondemand_public_domain | default('') | length > 0
- ondemand_desktop_image | default('') | length > 0
fail_msg: >-
group_vars/all/site.yml is missing or incomplete. Generate it from
the site with `hpcod setup`, then build again.
tags: [always]
tasks:
# Included without "apply", deliberately. "apply: tags: [install]" adds the
# tag to every task in the role instead of selecting the tagged ones, so
# the whole role runs - including tenant configuration that has no meaning
# on a template. The selection is made by --tags install on the command
# line, which the build script passes.
- name: Base system
ansible.builtin.include_role:
name: common
tags: [install]
- name: Warewulf
ansible.builtin.include_role:
name: warewulf
tags: [install]
- name: OpenHPC, Slurm and MUNGE
ansible.builtin.include_role:
name: slurm
tags: [install]
# Import the node image here too. It is the same ~1 GB whichever host
# fetches it, so fetching it once at build time removes it from every
# tenant's critical path. The tenant's node_image role then finds it
# already present and does nothing.
- name: Node image
ansible.builtin.include_role:
name: node_image
tags: [install]
# The portal's own software: Apache, Ruby, Node and OnDemand itself. A
# large install, and precisely the kind that belongs in a template rather
# than on every tenant's critical path.
# Only its install half runs here: apptainer into the template, no
# images - those are per cluster and the template has no list.
- name: Application runtime
ansible.builtin.include_role:
name: apps
tags: [install]
- name: User-facing portal
ansible.builtin.include_role:
name: ondemand
tags: [install]
# Last, because it copies the playbook directory into the template: run it
# after the roles above so the copy is of the tree that just built this.
- name: Self-configuration runtime
ansible.builtin.include_role:
name: selfconfig
tags: [install]
- name: Strip every trace of this build from the image
hosts: golden
become: true
gather_facts: false
tags: [always]
tasks:
# A MUNGE key baked into the template would be shared by every tenant
# cloned from it, which means any tenant could authenticate to any other
# tenant's Slurm. It is regenerated per tenant by the slurm role.
- name: Remove the MUNGE key
ansible.builtin.file:
path: /etc/munge/munge.key
state: absent
# nodes.conf is deliberately NOT removed. Its contents are tenant-specific,
# but the file itself must exist: without it "wwctl configure --all" cannot
# build the host overlay and dhcpd refuses to start. The golden run never
# adds a node, so what the template carries is the package default.
- name: Remove host identity and per-tenant secrets
ansible.builtin.file:
path: "{{ item }}"
state: absent
loop:
- /root/.ssh/cluster
- /root/.ssh/cluster.pub
# The registry pull credential. A tenant has no use for it - the image
# it would fetch is already in this template - and leaving it here
# ships a credential, however narrow, to every tenant that is ever
# cloned from this. A control-plane run that genuinely needs to pull
# writes it again from the environment.
- /root/.docker/config.json
- /var/lib/warewulf/overlays/hpc
# Only the overlays, not all of provision/. That directory holds two
# unlike things: provision/overlays/<node>/ carries this tenant's MUNGE
# key and SSH keys and must not survive into a template, while
# provision/images/ is the compiled node image - 1.2 GB that is byte
# for byte the same for every tenant and holds no secret. Deleting both
# made each tenant spend ~28s recompressing an image it could have
# inherited; it was the single slowest task in the whole provision.
- /var/lib/warewulf/provision/overlays
- name: Remove SSH host keys so each clone generates its own
ansible.builtin.shell: rm -f /etc/ssh/ssh_host_*
changed_when: true
# An identical machine-id across clones breaks anything keyed on it, and
# systemd will regenerate it on first boot when the file is empty.
- name: Blank the machine id
ansible.builtin.copy:
content: ""
dest: /etc/machine-id
mode: "0444"
- name: Make cloud-init run again on the clone
ansible.builtin.command: cloud-init clean --logs --seed
changed_when: true
- name: Clear caches, logs and history
ansible.builtin.shell: |
dnf clean all
rm -rf /var/log/journal/* /var/log/dnf* /var/log/hawkey*
rm -f /root/.bash_history /home/*/.bash_history
truncate -s0 /var/log/wtmp /var/log/lastlog 2>/dev/null || true
changed_when: true
- name: Report
ansible.builtin.debug:
msg: >-
Golden image ready. Shut down and convert to a Proxmox template;
the tenant playbook will regenerate the MUNGE key, SSH host keys
and machine id on first boot.