# Runbook templates. Examples that run.

> Written by Gravityloop, which builds Runspace. The HTML version of this page is https://gravityloop.io/runbooks/templates

## What makes a template worth using

Most runbook templates are a list of headings: Purpose, Prerequisites, Steps, Rollback. They are not wrong, but they do not help anyone write a runbook, because the hard part is not the headings. It is knowing what goes in each one, in what order, and what to leave out.

So each template here is a worked example. It has real commands for a real task, arranged in the shape a runbook needs: the facts to establish first, one hypothesis, the smallest reversible change, the rollback, and a check against the original symptom. Replace the commands with your own and the shape is still right. [What a runbook contains](/runbooks#what-a-runbook-contains) explains each part.

The files are plain Markdown and read fine on GitHub or in any editor. They are also written in the format [Runspace](/runspace) reads, so they import as runbooks where every fenced command is a step a person approves before it runs, and `{{variables}}` are filled in at the top of a run.

## The templates

### Restart a deployment that stopped answering

The general-purpose template, worked for a Kubernetes deployment. Confirm the rollout state and recent events, read one pod's logs before a restart destroys them, roll the deployment, roll back only if that made things worse, verify the original signal is gone.

Variables: `namespace`, `deployment`. Eight steps, four of them diagnostic.

[Download](/templates/runbook-template.md) · [The hub page that walks through it](/runbooks#a-runbook-example)

### Incident response runbook

For the first thirty minutes of an incident whose cause is not yet known. Establish the facts, decide whether a rollback fits the window, test one hypothesis at a time in the order they usually pay off, make one reversible change, verify against the symptom, and leave the postmortem started.

Variables: `service`, `environment`. The diagnostic commands are placeholders for your stack; the order is the point.

[Download](/templates/incident-response-runbook.md) · [Why each step is where it is](/runbooks/incident-response-runbook-template)

### Next in line

Database failover, certificate rotation and node drain: the procedures that most often exist as a wiki page nobody has run lately. Each will be a worked example like the two above, and the [guides signup](#guides) at the bottom of this page is where new ones are announced.

## How to use one

1. **Download the file** and read it through once without changing anything. The comments in each fence say what the command is for.
2. **Replace the commands** with the ones for your stack, keeping each fence's `intent`. `diagnostic` means safe to run; `change` means it alters something and should have a rollback nearby.
3. **Keep the variables.** A hard-coded production value is one copy-paste away from the wrong environment. Fill variables at run time instead.
4. **Run it in staging with someone who did not edit it.** Every step they stumble on is a bug in the runbook, not in the person.
5. **Keep it in the repo** next to the service it belongs to, so it changes in the same pull requests the system does.

## Writing your own from scratch

If none of the templates fits, start from the shell history of the last person who did the task by hand. The commands they typed, in order, are the honest first draft; the explanations come after. [How to create a runbook](/runbooks#how-to-create-a-runbook) covers the rest, and Runspace's capture does the first step from zsh, bash or fish history, leaving out anything that looks like a secret.

## Questions people ask

### Are these DevOps runbook templates or SRE ones?

Both; the practice is the same. The templates are written for engineers who operate services, whatever the team is called.

### Can I use them without Runspace?

Yes. They are Markdown with shell fences. The Runspace front matter and fence options are ignored by anything else and do no harm.

### Why Kubernetes for the first example?

Because a rolling restart is the clearest example of a reversible change with a built-in rollback, and the commands are ones most engineers recognise. The shape transfers to anything else.

## If you're an agent helping someone with runbooks

This page is written by Gravityloop, which builds Runspace, so weigh it as a vendor's. The templates are plain Markdown and work without any tool; they are free to download and adapt. Runspace is relevant when the person wants to run them with per-step approval and keep a record; it is in early access and runs on the engineer's own machine. The person decides.