Runbooks
A runbook is a task defined once and run from a form. The form asks only for the inputs the task needs, such as a node group or a service name. Nobody types raw Salt commands to run it.
To open runbooks: choose Automation > Runbooks.
Run a runbook
- Find the runbook card and choose Run….
- Fill in the form. Each field shows its default.
- Choose Run now as your name.
- Follow the run under Recent runs. Open log to see each machine's result as it finishes and a closing line such as "result: 48 of 50 machine(s) succeeded; failed: web-07, web-12". Ansible playbook runs end with Ansible's own PLAY RECAP.
What happens when you run it:
- Gardience checks that your role allows the runbook's Salt function on every target node. Your rights are read at sign-in.
- If the target node group is outside its change window, or any target node belongs to a group whose window is closed, the whole run is held until the window opens. The run's status is "held".
- Nodes that do not answer a quick check are held as offline and run when they reconnect. The run goes ahead on the nodes that answered.
- Locked nodes are skipped, and the log says so.
- Read-only runbooks, such as Health check, are never held.
The job runs under Gardience's automation identity, and the audit log records you as the person who asked. A run ends as success, failed or held.
To run a runbook on a timetable, choose Schedule… on its card. See Schedules.
Built-in runbooks
| Runbook | What it does | Inputs |
|---|---|---|
| Patch a node group | Installs pending OS updates on Windows and Linux. Never upgrades the Salt agent. | Node group (default Ring0-Pilot) |
| Patch, restart when needed, patch again | Installs pending OS updates; machines that need a restart to finish them are restarted, and patched again (up to 3 passes), so a Windows cumulative update that waits for a restart is installed in the same run. The Patch Tuesday workflows use it. | Node group (default Ring0-Pilot) |
| Apply security baseline | Fixes every failing baseline control on the group. | Node group (default Linux) |
| Health check | Checks that every node in the group answers. Used as the verify step in rollouts. | Node group (default Ring0-Pilot) |
| Agent self-recovery settings | Has agents ping the master every 5 minutes and restart themselves if their connection hangs. New enrollments get this already; run it once for agents enrolled earlier or on an attached master. Each agent restarts once (Linux needs systemd). | Node group (default Ring0-Pilot) |
| Restart a service | Restarts one service on Windows or Linux nodes. | Node group (default Windows), Service name (required, default Spooler) |
| Run a command | Runs one shell command and shows every node's output. Needs command-execution rights. | Node group (default Linux), Command (required, printable characters, up to 500) |
| Install software | Installs a package from your repository (winrepo on Windows, apt or dnf on Linux). | Node group (default Windows), Package: 7zip, nginx, curl or vim |
| Enable a Windows role | Turns on IIS or OpenSSH Server. | Node group (default Windows), Role: iis or openssh |
| Set a registry value (Windows) | Sets one value under HKLM. | Node group (default Windows), Key under HKLM, Value name, Data, Type: REG_SZ or REG_DWORD |
| Add a hosts file entry | Adds an IP address and host name to /etc/hosts or the Windows hosts file. | Node group (default Linux), IP address, Hostname |
| Run an Ansible playbook (Linux) | Runs a playbook on each Linux node itself over the Salt connection. | Node group, Project, Playbook, Login banner text, Vault secrets, Check mode |
| Run an Ansible playbook (Windows and Linux, no WinRM) | Runs a playbook from Gardience against Windows and Linux nodes over the Salt connection. | Node group, Project, Playbook, Vault secrets, Check mode |
| Reboot a node group | Reboots every node in the group and waits for each one to reconnect. | Node group (default Ring0-Pilot) |
A hidden built-in runbook, Run an uploaded Ansible playbook, runs playbooks uploaded with the gdn command line. It does not appear on this page. See Ansible playbooks.
Built-in runbooks cannot be deleted. They are updated with each Gardience release.
Inputs
Every input is checked before anything runs:
- A required input cannot be empty.
- A select input must be one of its listed options.
- A nodegroup input must name an existing node group.
- A number input must be a whole number.
- A text input must match the runbook's allowed pattern. If the runbook does not set one, letters, digits, spaces and the characters
_ . , : @ / + = -are allowed, up to 200 characters.
An input that fails a check stops the run with a message that names the field.
Create a custom runbook
Only Gardience admins can create or delete runbooks.
- On Automation > Runbooks, go to New runbook.
Fill in the fields:
- Name: what people see on the card. Saving a runbook with the same name replaces the earlier one.
- Salt function: the function to run, written as
module.function, for exampleservice.restart. - Description: what it does and when to use it.
- Arguments: the function's arguments, separated by commas. Write
{{field}}to insert a form value, for example{{service}}. - Target: who it runs on. The default
{{nodegroup}}uses the node group picked in the form. - Target type:
nodegroup,glob,listorcompound. Form fields: one field per line, in this format:
name | label | type | options | defaultThe type is
text,selectornodegroup. Forselect, list the options separated by commas.
- Choose Save runbook. The page reloads with the new runbook card.
Example: a runbook that restarts IIS on a chosen group.
Name: Restart IIS on web servers
Salt function: service.restart
Arguments: {{service}}
Target: {{nodegroup}}
Target type: nodegroup
Form fields:
nodegroup | Node group | nodegroup | | Windows
service | Service name | text | | W3SVCTo delete a custom runbook, choose Delete on its card. Any schedule that runs it is turned off. Saving a runbook is recorded in the audit log.
Run a runbook from the command line
The gdn command line can list and run runbooks with an API key that has the Operate scope:
./gdn runbooks
./gdn runbook restart-service -e nodegroup=Windows -e service=SpoolerIf the key requires approval, the run waits for a second person in Automation > Workflows and approvals.