Power the Proxmox cluster off and on
Use this runbook for a planned power-off of the whole rack, for the power-on afterwards, and for the cleanup after a power cut. For one node, use the Proxmox node maintenance mode instead.
Nobody has run this procedure end to end on the real cluster. The playbook has run there only as a dry run. The first planned power-off is the test. Do it with time to spare and a console on the rack, and expect to fix this runbook afterwards.
Why the order matters
- A node that loses quorum while an HA daemon holds its watchdog resets itself after 60 seconds, then boots again in the middle of the power-off. HA must let go of every watchdog before the first node goes off.
datacenter.cfgsetsshutdown_policy=migrate. With HA armed, shutting a node down first migrates its HA guests to nodes that are about to go off too.- DNS for the lab is a BIND pod on k3s at
10.0.20.103. It is the only resolver the nodes have. Once k3s stops, names stop resolving, so every step here uses IP addresses. - The NAS at
192.168.1.4serves thefast_unsafeandisosstorages and holds the PBS datastore. The nodes mount it, so it goes off last and comes on first.
What depends on what
| Guest or box | Needs | Needed by |
|---|---|---|
NAS nebula, 192.168.1.4 |
Power and the LAN switch | The nodes' fast_unsafe and isos storages, the PBS datastore, the disk of pdm (116), k3s volumes on NFS, Garage |
| pfSense (103, PVE2) | PVE2 | Every guest on a VLAN. k3s and Talos reach the NAS through it. Nodes, PBS, the NAS and the Docker host share 192.168.1.0/24 and talk without it. |
| k3s (410 to 419) | pfSense, the NAS | DNS for nodes and guests, OpenBao, Mimir, Loki, Traefik. See k3s dependencies. |
| Talos staging (420, 421) | k3s for DNS, secrets, logs and metrics | Nothing in production |
| PBS (100, PVE) | The NAS for its datastore | Scheduled backups |
| HA guests 102, 105, 108, 116 | Their preferred nodes PVE2 and PVE4, and the NAS for 116 | Docker, Home Assistant, Bitwarden, Proxmox Datacenter Manager |
Before you start
- Run the playbook from a machine on
192.168.1.0/24with root SSH keys for the five nodes. The playbook refuses to start if it reaches a node through a router. - You can run it from a guest of the cluster, such as
VSCodeServer, guest 110 on PVE4. The playbook detects that. It leaves that guest running, powers its node off last, and lets the node's own shutdown stop it. From a laptop it treats guest 110 like any other guest. - Bitwarden (108) goes off. Have the Bitwarden cloud vault or the offsite bundle at hand if you need a credential while the rack is down.
- Pick a time with no backup running. The playbook stops if a backup, migration or restore task is active or a guest is locked.
- Decide whether the NAS goes off too. See the NAS.
Power off
- Print the plan. It reads the live cluster and changes nothing.
Read every line. It names each guest, its node, how it will be stopped, and the order of the nodes.
- Run it. It prints the same plan, runs the pre-checks, and asks you to type the cluster name.
- Watch the run. When it ends, every node has stopped answering ping. If the control machine is a guest, its node powers off one minute after the last message.
- Power the NAS off if it is part of the outage. Then the switches and the rest of the rack.
The run leaves HA disarmed. That is on purpose. Power on arms it again.
What the playbook does
| Order | Step | Why |
|---|---|---|
| 1 | Pre-checks | Stops before any change if the cluster is not in a state it can power off cleanly. |
| 2 | ha-manager crm-command disarm-ha ignore |
Releases every HA watchdog and hands the HA guests back to qm. |
| 3 | Watchdog check on every node | Proves that no node can reset itself. See the proof. |
| 4 | Stage apps, every guest that no later stage names |
Nothing else needs them. They stop while DNS and the network still work. |
| 5 | Stages talos-workers, then talos-control-plane |
Talos staging reads DNS, secrets, logs and metrics from k3s. A worker leaves cleanly only while its control plane answers. |
| 6 | Stages k3s-workers, k3s-storage, k3s-control-plane |
k3s runs DNS, so it outlasts every other workload. Storage nodes outlast the workers that mount their volumes. The API and etcd go last. |
| 7 | Stage backup, PBS (100) |
After the guests it backs up, before the NAS that holds its datastore. |
| 8 | Stage router, pfSense (103) |
Every guest on a VLAN needs it until that guest is off. |
| 9 | Nodes, one at a time, PVE5, PVE3, PVE4, PVE2, PVE | PVE5 and PVE3 hold no HA guest and leave three votes behind, so the cluster keeps quorum until the third node goes. From there on quorum is lost, which is safe only because of step 3. |
| 10 | The NAS, by hand | The nodes mount it. A node that shuts down with a dead NFS server waits on the unmount. |
The playbook runs its cluster commands on the last node of step 9. If the
control machine is a guest, its node moves to the end. From VSCodeServer
the node order is PVE5, PVE3, PVE2, PVE, PVE4.
A stage finishes on every node before the next one starts. Inside a stage the
guests stop in parallel. Guests with a working QEMU guest agent get an agent
shutdown. pfSense (103) and pdm (116) have no agent and get the ACPI power
button. The container jellyfin (114) gets pct shutdown. The plan prints the
method for each guest.
The playbook picks a guest's stage from its VM ID or its Proxmox tags. The
k3s and Talos stages match the tags that OpenTofu sets, such as k3s_master
and talos_worker, so a new node lands in the right stage without an edit. A
new guest that must outlast the apps needs an entry in
ansible/roles/proxmox_shutdown/defaults/main.yml.
The playbook does not drain k3s or scale applications down. It shuts the VMs down in order and lets each guest OS stop its services.
How the playbook proves no watchdog can fire
A watchdog resets a node only while an HA daemon on that node holds it. The playbook checks two things, and powers nothing off until both hold.
- HA reports
fencing disarmed. The playbook sendsdisarm-ha ignoreand waits up to 180 seconds for that state. Until then it stops no guest. /run/watchdog-mux.activedoes not exist on the node.watchdog-muxcreates that directory when an HA daemon opens the watchdog and removes it when the last one closes it cleanly. The check runs on each node and does not depend on quorum.
The playbook runs the second check on every node before the first guest stops, and again on each node just before that node powers off. If the directory exists, the run stops and names the node. Before the first node goes off it also checks that no guest is running anywhere.
While HA is disarmed, a node that shuts down does not apply
shutdown_policy=migrate. Its LRM exits and the node powers off.
When the run stops
Every stop prints what failed and what to do. Run the same command again after you fix the cause. The playbook reads the cluster again and skips what is already off.
| Message | What it means | What to do |
|---|---|---|
| Tasks are still running, or locked guests | A backup, migration or restore is active | Wait for it, or clear a stale lock with qm unlock <id>, then run again. |
| HA is still working on a service | A service is migrating, recovering or in error |
Wait until ha-manager status shows it started. For error, set the service to disabled, fix the guest, then set it to started. |
| A node did not answer and HA is not disarmed | A node is off or unreachable before the run | Power it on, or add -e proxmox_shutdown_allow_offline_nodes=true if it is off on purpose. |
| HA did not reach "disarmed" | The disarm is deferred or the CRM is stuck | Nothing was stopped. Check ha-manager status. Run again, or give up with ha-manager crm-command arm-ha. |
| A node still holds the HA watchdog | The proof failed | Nothing more is stopped. Check journalctl -u pve-ha-lrm -u pve-ha-crm -u watchdog-mux on that node. |
| A guest is still running after its timeout | The guest ignored the shutdown request | Later stages and the nodes are untouched. Look at its console. Run again, or add -e proxmox_shutdown_force_stop=true to hard-stop guests that time out. |
| A guest is still running after every stage | Someone started a guest during the run | No node was powered off. Run again to stop it. |
| A node still answers ping | The node hangs in its own shutdown | The remaining nodes stay on. Look at its console for a stop job that waits on a mount. Run again when it is off. |
A hard stop is the same as pulling the guest's power cord. Use it when the alternative is a dead UPS battery, not as the default.
Timeouts are 300 seconds per guest, 600 for the k3s stages, 180 for the
disarm and 300 for each node. Change them in the role defaults or with -e.
Run it unattended
A UPS hook or a scheduled job has no terminal to type into. Pass both flags:
task proxmox:shutdown -- \
-e proxmox_shutdown_assume_yes=true \
-e proxmox_shutdown_force_stop=true
Without proxmox_shutdown_assume_yes and without a terminal, the run aborts
before it changes anything.
The NAS
The playbook does not power the NAS off. With
-e proxmox_shutdown_include_nas=true it adds the NAS to the printed order and
reminds you at the end. Power it off from the TrueNAS UI after the last node
is off.
To automate it, the playbook needs a way to call the TrueNAS shutdown, either
an API key or an SSH key for a user that may run midclt call system.shutdown.
The credential would live in OpenBao. The control machine must also outlast
the nodes, which a guest on the cluster cannot do.
Back out
After the disarm and before the nodes go off, you can stop the run with Ctrl+C and undo it. Start the guests that were stopped, in the reverse of the stage order, then arm HA:
By hand
Use this only if the playbook cannot run. Use IP addresses for SSH.
- On any node, disarm HA and wait for
fencing disarmed:
- On every node, check that this prints
released. If it printsheld, stop.
- Stop the guests in the stage order from the table above. Run each command
on the node that hosts the guest.
qm listandpct listshow what is left.
- Repeat the check from step 2 on each node, then power the nodes off in
order: PVE5 (
192.168.1.25), PVE3 (.20), PVE4 (.21), PVE2 (.22), PVE (.24).
Power on
VSCodeServer is a guest, so it is not there for the first steps. Use a
laptop on the LAN or a node console. Until DNS is back, use IP addresses.
- Power on the switches, then the NAS. Wait until it serves NFS:
Do not start the nodes before this answers. PBS mounts its datastore from
the NAS, and the nodes mount fast_unsafe and isos from it.
- Power on the five nodes. No guest starts until three nodes are up and the cluster has quorum, so the order matters little. If you start them one at a time, begin with PVE2 for pfSense and PVE for PBS. On any node:
Go on when it shows Quorate: Yes and five votes.
- Let the guests start. Every guest that was running has
onbootset. pfSense starts first on PVE2, and HA is still disarmed, so the HA guests start like the others. Wait for the router and for DNS:
DNS answers only after k3s is up and its BIND pod has mounted its configuration from the NAS.
- Check the storages on every node.
fast_unsafe,isosandpbsare defined by name. Each node resolves those names from/etc/hosts, which Ansible manages, so they turnactiveonce the NAS and PBS answer, before DNS is back.
- Arm HA once all five nodes are up and the storages are active:
HA starts any of its guests that are not running. pdm (116) is the likely
one. Its disk is on fast_unsafe, which is not active yet when the node
first tries to start it. If you arm HA while a node is still off, HA treats
that node as failed and recovers its guests elsewhere.
- Check that the lab is healthy:
| Check | Command | Healthy |
|---|---|---|
| Quorum | pvecm status |
Quorate: Yes, five votes |
| HA | ha-manager status |
fencing armed, services 102, 105, 108 and 116 started |
| Storage | pvesm status on every node |
Every storage active |
| Replication | pvesr status |
No job with a fail count. No job exists today. |
| Backups | pvesm list pbs on a node |
Lists backups, so PBS answers and its datastore is mounted |
| Guests | qm list and pct list on every node |
Every guest from the plan is running |
| k3s | kubectl get nodes and kubectl get pods -A |
Ten nodes Ready, no pod stuck in Pending or CrashLoopBackOff |
| Talos staging | The standard health gate | Passes |
A pod that started before its NFS volume or its database was ready can stay broken. Delete it and let its controller start it again.
After a power cut
After a cut the nodes come back in whatever order their firmware allows, HA is still armed, and the NAS can be the last box up.
- Leave the nodes alone while they boot. A node that comes up alone waits for quorum and starts no guest. An HA node that gains quorum and loses it again while others are still booting can reset itself. That is the watchdog doing its job. Do not power-cycle it.
- Wait for
pvecm statusto showQuorate: Yes. Power on any node that stayed off. - Read
ha-manager status. If PVE2 or PVE4 stays off for about two minutes, HA recovers its guests on another node. Wait until no service is infenceorrecovery. For a service inerror, runha-manager set vm:<id> --state disabled, fix the guest, then set it tostarted. - Check the NAS, then the storages with
pvesm statuson every node. Guests that started before the NAS was up have failed or run without their data. Restart PBS (100) if its datastore is missing. Startpdm(116) if it is stopped. - Work through the health table in Power on.
- If the power is still unstable, do not wait for the next cut. Run
task proxmox:shutdownand power the rack on when the supply is steady.
References
- Proxmox VE HA manager: "Disarming HA for Cluster Maintenance", "Fencing & Watchdog Status", "Shutdown Policy" and "Error Recovery"
- Proxmox VE cluster manager
- k3s platform dependencies
- Homelab Ansible