Files
werewulf/scripts/A20-ipa-nfs-home.sh
ilker 29bd39c135 Warewulf HPC test cluster: provisioning, identity, docs and overlay UI
A complete, verified HPC lab on Proxmox (hv01) with its own isolated subnet,
central identity and a web console for overlay management.

Infrastructure
- vmbr6: L2-only cluster fabric, deliberately without an address on the
  hypervisor so Warewulf owns DHCP/TFTP/PXE for the whole subnet.
- head01 (VM 300): Warewulf 4.7.0, dnsmasq-free DHCP/TFTP/iPXE chain,
  Slurm controller, MUNGE, NAT gateway, /opt exported read-only.
- wwnode1-4 (VM 301-304): diskless, PXE-booted, rootfs unpacked into RAM.
- idm1 (VM 305): FreeIPA (LDAP/Kerberos/Dogtag CA/DNS) plus the NFS home
  server. Dual-homed on purpose: idm1.hpc.local resolves to the cluster
  fabric so Kerberos and NFS never traverse head01's masquerade.

Stack
Rocky Linux 9.8, OpenHPC 3, Slurm 25.11.4, OpenMPI 5.0.7, FreeIPA 4.13.1.

Stateless domain join
Nodes are rebuilt in RAM every boot, so ipa-client-install cannot be used.
Enrolment happens once and is distributed through Warewulf overlays: shared
config as templates rendered per node via {{.Id}}, and a separate keytab per
node so wwnode1 cannot impersonate wwnode2.

Overlay web UI (webui/)
A Go service on the head node serving a browser interface over the Warewulf
REST API. It exists as a server rather than a static page because the API is
root-equivalent and bound to loopback; the service holds the credentials and
proxies same-origin, so the browser never sees one. Published behind Caddy
with bcrypt logins, server-side sessions and per-user/per-IP lockout.

Documentation
README plus docs/01-10 covering architecture, installation, Warewulf,
identity, storage, Slurm/MPI, operations, troubleshooting and reference,
with a 22-page PDF edition. Section 08 records twelve concrete failures hit
during the build, including a wwctl flag that fails silently.

No credentials are stored here. Every secret lives on the servers; the
documentation refers only to its path.
2026-08-29 09:07:51 +02:00

90 lines
3.0 KiB
Bash
Executable File

#!/bin/bash
# idm1: NFS home server + IPA users + cluster DNS records
set -euo pipefail
. /root/.ipa-credentials
DOMAIN=hpc.local
export_dir=/export/home
echo "==> kinit admin"
echo "${IPA_ADMIN_PASSWORD}" | kinit admin
echo "==> cluster DNS records"
add_a() { # name ip
ipa dnsrecord-add ${DOMAIN}. "$1" --a-rec="$2" >/dev/null 2>&1 || \
ipa dnsrecord-mod ${DOMAIN}. "$1" --a-rec="$2" >/dev/null 2>&1 || true
echo " $1.${DOMAIN} -> $2"
}
add_a head01 10.10.10.1
add_a wwnode1 10.10.10.11
add_a wwnode2 10.10.10.12
add_a wwnode3 10.10.10.13
add_a wwnode4 10.10.10.14
add_a idm1-mgmt 10.0.0.31
add_a head01-mgmt 10.0.0.30
echo "==> reverse DNS (10.10.10.0/24)"
add_ptr() { # last-octet fqdn
ipa dnsrecord-add 10.10.10.in-addr.arpa. "$1" --ptr-rec="$2." >/dev/null 2>&1 || true
}
add_ptr 1 head01.${DOMAIN}
add_ptr 5 idm1.${DOMAIN}
add_ptr 11 wwnode1.${DOMAIN}
add_ptr 12 wwnode2.${DOMAIN}
add_ptr 13 wwnode3.${DOMAIN}
add_ptr 14 wwnode4.${DOMAIN}
echo "==> NFS home directory"
mkdir -p ${export_dir}
chmod 0755 ${export_dir}
cat > /etc/exports <<EOF
# Cluster fabric (vmbr6): nodes and head01 mount from here.
# no_root_squash: lets pam_oddjob_mkhomedir create homes on first login.
${export_dir} 10.10.10.0/24(rw,sync,no_subtree_check,no_root_squash)
EOF
echo "==> NFSv4 idmap domain"
sed -i "s/^#\?Domain =.*/Domain = ${DOMAIN}/" /etc/idmapd.conf
grep -q "^Domain" /etc/idmapd.conf || echo "Domain = ${DOMAIN}" >> /etc/idmapd.conf
systemctl enable --now nfs-server rpcbind
exportfs -ra
exportfs -v
echo "==> IPA group and users"
ipa group-add hpcusers --desc="HPC cluster users" >/dev/null 2>&1 || true
mkuser() { # login firstname lastname
local u="$1" f="$2" l="$3"
if ! ipa user-show "$u" >/dev/null 2>&1; then
local pw
pw=$(head -c 40 /dev/urandom | base64 | tr -dc 'A-Za-z0-9' | cut -c1-16)
echo "$pw" | ipa user-add "$u" --first="$f" --last="$l" \
--homedir="/home/$u" --shell=/bin/bash --password >/dev/null
# clear the forced first-login password change (lab convenience)
printf '%s\n%s\n%s\n' "$pw" "$pw" "$pw" | kpasswd "$u" >/dev/null 2>&1 || true
echo "IPA_USER_${u}_PASSWORD=${pw}" >> /root/.ipa-credentials
echo " + $u (password stored in /root/.ipa-credentials)"
else
echo " = $u already exists"
fi
ipa group-add-member hpcusers --users="$u" >/dev/null 2>&1 || true
# pre-create the home directory with the IPA uid/gid
local uid gid
# NOTE: --raw returns attribute names in LOWERCASE (uidnumber/gidnumber).
uid=$(ipa user-show "$u" --all --raw | awk '/uidnumber:/ {print $2}')
gid=$(ipa user-show "$u" --all --raw | awk '/gidnumber:/ {print $2}')
install -d -m 0700 -o "$uid" -g "$gid" "${export_dir}/$u"
}
# NOTE: do NOT create "ilker" - cloud-init makes a local ilker (uid 1000) on
# every host. Since nsswitch resolves files before sss, the same name would map
# to different uids per host and corrupt NFS home ownership.
mkuser hpcuser HPC User
mkuser testuser Test User
echo "==> result"
ipa group-show hpcusers
ls -la ${export_dir}
echo "IPA NFS/HOME OK"