Skip to content

windows_reboot

Experimental. Reboots a Windows host when created and whenever triggers change, then waits for it to come back. With only_if_pending it reboots only when Windows is waiting for one. Removing it does nothing.

Experimental. Windows support is new, and this module may change between releases.

Use windows_reboot when a change needs a restart before the next step can run. No other Windows module reboots a host by itself, so reboots always show in the plan.

Reboot whenever a value changes:

step "restart" {
windows_reboot {
triggers = { feature = "web-server" }
timeout = "15m"
}
}

Reboot only when Windows is waiting for one:

step "restart_if_needed" {
windows_reboot {
only_if_pending = true
}
}
Name Type Required Description
only_if_pending bool No Reboot only when Windows reports a reboot is pending, and plan one whenever a refresh finds that, so a reboot a failed run missed still happens.
timeout string No How long to wait for the host to come back. Defaults to “10m”.
triggers map of string No Reboot again whenever any of these values change.

Conn3x sets these; reference them as conn3x_windows_reboot.<circuit>__<step>["<host>"].<name>.

Name Type Description
boot_id string The host’s boot ID after the last apply.
pending bool With only_if_pending, whether a reboot was pending at the last refresh.
revision string Changes each time Conn3x changes this on the host. Handlers watch it.

A step lowers to the conn3x_windows_reboot resource, one instance per host, and connects with its circuit’s ssh block.

Rebooting. Conn3x reads the boot ID from the registry, runs shutdown.exe /r /t 5, reconnects, and finishes once the boot ID has changed. It fails if that takes longer than timeout, which defaults to "10m". A plain reboot comes back in about 25 seconds, a domain controller in about 75.

only_if_pending. A refresh checks the markers Windows leaves when it wants a restart: component servicing, Windows Update, pending file renames and a changed computer name. If it finds one, the plan shows a reboot, so one that a failed run missed still happens.

Up is not ready. sshd answers before everything else has started. Follow a reboot with windows_wait_for on whatever the next step needs.

Deleting a windows_reboot step does nothing on the host.