Our group had a set of machines with GPUs and a few people who needed to run jobs on them. Without a scheduler, sharing them meant asking around and logging into whichever machine looked free. Slurm turns that into a queue: you submit a job, and it runs when resources are free.
The goal was something I could rebuild, not just keep alive. This note is how I set it up, written for anyone with a few machines and a few users.
slurm_inventory.yml controller + compute_nodes groups
configs/slurm.conf single source of truth for the Slurm config
vault/ encrypted: sudo passwords, system UIDs/GIDs, DB credentials
playbooks/ one playbook per step, named by stage and target
Ansible itself is pinned in a uv environment and every playbook is run through uv run ansible-playbook, so the tooling is as reproducible as the cluster.
Every playbook is named <stage><step>-<target>-<action>.yml. The target letter says where it runs: a all hosts, h head node, n compute nodes.
1-a-configure-slurm-users.yml
3a-a-munge-share-keys.yml
4a-h-install-slurm-controller.yml
4b-n-install-slurm-nodes.yml
u3-h-upgrade-slurmdbd.yml
ls sorts the directory into install order, and the target letter tells you before you run anything whether --limit <node> makes sense.
| Stage | What it does |
|---|---|
0 | Node preparation and maintenance: NVIDIA drivers, Apptainer, apt updates, removing Docker and Podman |
1 | munge and slurm system users, with the same UIDs and GIDs on every node (read from the vault) |
2, 3 | MUNGE: install, distribute one key, restart, fix permissions, check versions |
4 | Slurm: prerequisites, build and install on head and nodes, configure slurmctld, slurmdbd with MariaDB, slurmd, push and sync slurm.conf, GRES for GPUs |
5 | Networking and NFS: known hosts, shared home and scratch, data drives exported from the head node |
s | Service management: stop everything, start head, start nodes |
u | Upgrade, u1 to u7 |
There is no single site.yml. Each scenario is an ordered sequence of the playbooks above, written down in the README:
fresh install, full cluster
1-a users 4f-a push slurm.conf s1-h start head
2-a install munge 4c-h configure slurmctld s2-n start nodes
3a-a share munge key 4d-h configure slurmdbd 3d-a verify versions
3c-a munge perms 4e-n configure slurmd
3b-a restart munge 5a-n known hosts
4-0-h prerequisites 5b-n NFS
4a-h build head -e slurm_ver=X.Y.Z
4b-n build nodes -e slurm_ver=X.Y.Z
The same stages, with --limit, give a head-only install or a single-node install. Adding a machine is the node sequence with --limit <node>, not a separate procedure.
Keeping the steps separate costs some typing and buys two things: you can stop between any two steps and look, and you can run any step on one node first.
u1-h back up slurm_acct_db, /etc/slurm, /var/spool/slurmctld, timestamped
u2-n drain wait up to 30 min for running jobs, then fail
u3-h slurmdbd -e slurm_new_ver=X.Y.Z
u4-h slurmctld asserts sinfo --version before finishing
u5-n slurmd --limit <node> first, then the rest
u6-n resume
u7-a verify every node must report slurm_new_ver
Three decisions in there:
The version has no default. slurm_ver and slurm_new_ver must be passed on the command line, and the playbook fails immediately without them. A wrong version installed silently is worse than a missing argument.
u3 starts slurmdbd directly as the slurm user, not through systemd. The database schema migration can outlast systemd's start timeout, and systemd would kill it halfway. Once the log shows the new version running, it hands back to systemd.
u2 does not force. If jobs are still running after 30 minutes it fails and leaves the decision to whoever is running the upgrade.
configs/slurm.conf is edited in the repository and pushed with 4f-a, head node first. If someone edits it on the head node instead, 4f-b syncs it to the compute nodes and saves a copy back to the repository. If the repository copy is lost, an ad hoc fetch from any compute node recovers it.
Anything that changes a node has a playbook that undoes it: 5c-h exports the data drives and 5f-h removes the exports, 5d-n mounts and 5e-n unmounts, 0d-n and 0e-n enable and disable a login path, 0j-n and 0k-n remove Docker and Podman. Reversals run in the opposite order to the installs (nodes before head).
Service management follows the same rule: s0-a stops compute nodes before the head node, and s1-h starts MariaDB, then slurmdbd, then slurmctld, and checks all three are active before returning.
Docker and then Podman were tried and removed. Docker had a licensing problem, and both run a daemon that needs root on the compute nodes. Apptainer has no daemon and needs no root. 0i-n installs it, binds /scratch, and points APPTAINER_CACHEDIR and APPTAINER_TMPDIR at scratch for every user.
The driver update (0l-n) records nvidia-smi before the update, after it, and after the reboot, and appends all three to a timestamped file under /var/log/0l-n-apt-update-gpu-check/ on each node. A driver that breaks across the reboot shows up in the log, not only in the play output, and no run overwrites another.
No monitoring or alerting, no CI, no automated tests of the playbooks. Secure Boot has to be disabled by hand at each node's console before the NVIDIA modules load.