Files
ilker 84bde89a43 hpcod: boot compute nodes in two stages, not one
The node phase was the largest remaining part of a provision, and the
reason turned out to have nothing to do with the image or the network.

Breaking a single node's boot down: 7.5s of VM POST and iPXE ROM, 3.1s
of DHCP, 3.1s fetching the kernel, 25.6s fetching the image, 11.2s of
the node's own boot, and 0.7s for Slurm to register it. The 25.6s is
370 MB at about 14 MB/s. Fetching that same image from an already
booted node over the same bridge, with an ordinary Linux TCP stack,
took 0.29s at 3.1 GB/s. So the server was not slow and neither was the
bridge: iPXE's HTTP client runs in the boot ROM, and that is where the
time went. Shrinking the image would only have scaled a bad rate.

Warewulf already ships the fix. Its iPXE template offers a two-stage
dracut boot where the firmware fetches only the ~36 MB initramfs and
the booted kernel pulls the image itself. It is not the default on
anything that is not EFI, which is every SeaBIOS guest here, so the
profile has to ask for it. Per node that is 76s to 59s; end to end,
with two nodes, the phase goes 82s to 65s and a provision 194s to 183s.

This needed a fix in the image first. The slimming pass rebuilt the
initramfs without --add wwinit, so the two-stage initramfs had no way
to fetch a root filesystem: the node booted it, failed, and iPXE
rebooted it every 15 seconds. That cost a 280s measurement I first read
as two-stage being slower. The build now adds the module explicitly,
builds --no-hostonly since dracut is running in a container against an
unrelated build host, and fails the build if the module is not in the
result.

The profile write is read back rather than assumed. wwctl exits 0 on
settings it silently ignores - --nettagadd on this same command does
exactly that - and the failure mode here is a node that boots, finds no
root, and reboots forever without saying why.
2026-09-02 13:08:28 +02:00

142 lines
5.4 KiB
YAML

---
# Warewulf installation and configuration.
# Ported from scripts/20-warewulf-install.sh and 30-warewulf-configure.sh.
- name: Check whether Warewulf is already installed
ansible.builtin.command: rpm -q warewulf
register: warewulf_installed
failed_when: false
changed_when: false
tags: [install]
# There is no Warewulf package in Rocky or EPEL, so the official GitHub RPMs
# are used directly.
- name: Install Warewulf from the official RPMs
when: warewulf_installed.rc != 0
ansible.builtin.dnf:
name:
- "https://github.com/warewulf/warewulf/releases/download/v{{ warewulf_version }}/warewulf-{{ warewulf_version }}-1.el9.x86_64.rpm"
- "https://github.com/warewulf/warewulf/releases/download/v{{ warewulf_version }}/warewulf-dracut-{{ warewulf_version }}-1.el9.noarch.rpm"
state: present
disable_gpg_check: true
tags: [install]
- name: Point warewulf.conf at the tenant fabric
ansible.builtin.replace:
path: /etc/warewulf/warewulf.conf
regexp: "{{ item.re }}"
replace: "{{ item.to }}"
loop:
- { re: '^ipaddr:.*$', to: 'ipaddr: {{ head_cluster_ip }}' }
- { re: '^netmask:.*$', to: 'netmask: {{ cluster_netmask }}' }
- { re: '^network:.*$', to: 'network: {{ cluster_cidr | ansible.utils.ipaddr("network") }}' }
notify: restart warewulfd
- name: Set the DHCP pool
ansible.builtin.replace:
path: /etc/warewulf/warewulf.conf
regexp: '^(\s*)range {{ item.k }}:.*$'
replace: '\1range {{ item.k }}: {{ item.v }}'
loop:
- { k: start, v: "{{ dhcp_range_start }}" }
- { k: end, v: "{{ dhcp_range_end }}" }
notify: restart warewulfd
# cloud-init leaves a forced-command wrapper in root's authorized_keys telling
# you to log in as the unprivileged user. The ssh.authorized_keys overlay
# copies that file verbatim to every node, which locks root out of all of them.
- name: Strip cloud-init's forced-command wrapper from root's authorized_keys
ansible.builtin.shell: |
set -euo pipefail
f=/root/.ssh/authorized_keys
if grep -q 'command=' "$f" 2>/dev/null; then
cp "$f" "$f".cloudinit.bak
grep -o 'ssh-[a-z0-9-]* [A-Za-z0-9+/=]* .*$' "$f".cloudinit.bak > "$f"
chmod 600 "$f"
echo changed
fi
register: warewulf_authkeys
changed_when: "'changed' in warewulf_authkeys.stdout"
- name: Create the head-to-node cluster key
ansible.builtin.command: ssh-keygen -t ed25519 -N "" -f /root/.ssh/cluster -q
args:
creates: /root/.ssh/cluster
- name: Append the cluster public key to authorized_keys
ansible.builtin.shell: |
set -euo pipefail
grep -qf /root/.ssh/cluster.pub /root/.ssh/authorized_keys 2>/dev/null && exit 0
cat /root/.ssh/cluster.pub >> /root/.ssh/authorized_keys
echo changed
register: warewulf_clusterkey
changed_when: "'changed' in warewulf_clusterkey.stdout"
- name: SSH config for reaching nodes as root
ansible.builtin.copy:
dest: /root/.ssh/config
owner: root
mode: "0600"
content: |
Host * {{ cluster_cidr | ansible.utils.ipaddr('network') | regex_replace('\.0$', '.*') }}
IdentityFile /root/.ssh/cluster
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
LogLevel ERROR
# Warewulf needs this file to exist before it can build the host overlay, and
# a missing one surfaces as dhcpd failing to start rather than as a missing
# file. Cheap to guarantee, expensive to diagnose.
- name: Ensure nodes.conf exists
ansible.builtin.copy:
content: "nodeprofiles:\n default: {}\nnodes: {}\n"
dest: /etc/warewulf/nodes.conf
owner: root
group: root
mode: "0644"
force: false
- name: Configure dhcpd, tftp, nfs, ssh keys and the hostfile
ansible.builtin.command: wwctl configure --all
register: warewulf_configure
changed_when: true
- name: Enable the provisioning services
ansible.builtin.systemd:
name: "{{ item }}"
enabled: true
state: started
loop: [warewulfd, dhcpd, tftp.socket, nfs-server]
# Two-stage boot, and it is worth saying why, because the default is the other
# one. iPXE's HTTP client runs in the boot ROM and moves about 14 MB/s: the
# same image fetched from a booted node over the same bridge measured 3.1 GB/s,
# so what was slow was never the network or the server, it was the firmware. In
# single-stage boot iPXE carries the whole ~370 MB image and spends ~26s on it.
# Two-stage has it fetch only the ~36 MB dracut initramfs, and the kernel then
# pulls the image with a real TCP stack. Measured here: 76s to 59s per node.
#
# The stock iPXE template picks single-stage on anything that is not EFI, which
# is every SeaBIOS guest on this hypervisor, so it has to be asked for.
#
# After the services are up, not before: wwctl reloads warewulfd as part of
# writing the profile and fails outright if it is not running yet.
- name: Boot compute nodes in two stages
ansible.builtin.command: >
wwctl profile set --yes default
--tagadd IPXEMenuEntry=dracut
--root tmpfs
changed_when: true
# wwctl exits 0 on settings it silently ignores - --nettagadd on this same
# command does exactly that - so the value is read back rather than assumed.
# Getting it wrong costs a node that boots, finds no root filesystem, and
# reboots every 15 seconds without ever saying why.
- name: Confirm the boot method was actually set
ansible.builtin.command: wwctl profile list -a default
register: warewulf_profile
changed_when: false
failed_when: >-
'IPXEMenuEntry' not in warewulf_profile.stdout
or 'dracut' not in warewulf_profile.stdout