
What You’ll Accomplish
Runbooks let you create reusable templates for common operations. Instead of typing the same queries or commands repeatedly, you can:- Create parameterized templates stored in Git
- Share approved procedures across your team
- Enforce input validation and safe defaults
- Maintain an audit trail of every execution
How It Works
Example Workflow
- DBA creates a runbook for looking up customer data
- Template stored in
runbooks/customer-lookup.runbook.sql - Support team selects the runbook, enters customer ID
- Query executes with proper validation and audit logging
Quick Start
Prerequisites
To get the most out of this guide, you will need to:- Either create an account in our managed instance or deploy your own hoop.dev instance
- You must be your account administrator to perform the following actions
- A Git repository for storing runbooks
- Git access credentials (SSH key or token)
Step 1: Create a Runbook File
Create a file in your repository with the.runbook.<ext> extension:
runbooks/customer-lookup.runbook.sql
Step 2: Configure Git Integration
In the Web App:- Go to Manage > Runbooks
- Click Configure Repository
- Enter your repository URL and credentials
Step 3: Run the Runbook
- Go to Runbooks in the sidebar
- Select
customer-lookup - Enter the customer ID
- Click Execute
Template Syntax
Runbooks use Go’stext/template syntax. Parameters are defined with {{ .parameter_name }}.
Basic Parameter
Parameter with Validation
Parameter Functions
| Function | Description | Example |
|---|---|---|
description | Help text for the input | description "Customer ID" |
required | Error message if empty | required "This field is required" |
default | Default value if not provided | default "US" |
type | Input type for UI | type "number" |
pattern | Regex validation | pattern "^[0-9]+$" |
options | Dropdown options | options "active" "inactive" |
squote | Wrap value in single quotes | squote |
dquote | Wrap value in double quotes | dquote |
Input Types
| Type | UI Behavior |
|---|---|
text | Standard text input |
number | Numeric input |
email | Email validation |
date | Date picker |
time | Time picker |
select | Dropdown (use with options) |
Example Runbooks
SQL: Customer Lookup
SQL: Update Order Status
Bash: Service Restart
Python: Data Export
Kubernetes: Scale Deployment
Security Features
Input Validation
Usepattern to prevent injection attacks:
Environment Variables
Useasenv to pass values as environment variables instead of inline:
Quoting
Usesquote or dquote to properly quote string values:
File Organization
Recommended repository structure:Naming Convention
Files must end with.runbook.<extension>:
.runbook.sql- SQL queries.runbook.sh- Bash scripts.runbook.py- Python scripts.runbook.rb- Ruby scripts
Integration with Other Features
| Feature | How It Works with Runbooks |
|---|---|
| Access Requests | Runbook execution can require approval |
| Guardrails | Rules apply to runbook-generated queries |
| Live Data Masking | Results are masked automatically |
| Session Recording | All executions are recorded |
| Parallel Mode | Run runbooks across multiple connections |
Troubleshooting
Runbook Not Appearing
Check:- File ends with
.runbook.<ext> - Git repository is configured correctly
- Hoop can access the repository (check credentials)
- Run
hoop admin get runbooksto verify sync
Template Parsing Error
Check:- All
{{ }}brackets are balanced - Function names are spelled correctly
- Pipes
|are used correctly
Parameter Validation Failing
If a parameter fails validation:- Check the
patternregex is correct - Test the regex at regex101.com
- Ensure
requiredvalues are provided
Best Practices
Validate Inputs
Always use
pattern for user inputs to prevent injectionAdd Descriptions
Every parameter should have a clear description
Set Defaults
Provide sensible defaults where appropriate
Version Control
Store runbooks in Git for history and review