|
| 1 | +# Runbook |
| 2 | + |
| 3 | +## Summary |
| 4 | + |
| 5 | +Runbook is a commandline tool that guides users in an opinionated approach to creating dynamic runbooks. |
| 6 | + |
| 7 | +In this context, a runbook is a mixture of markdown and executable code that contains the steps needed for successful operational executions such as server maintenance, database management, or creating a weekly report. |
| 8 | + |
| 9 | +### When would you use this? |
| 10 | +1. When you want quick to write tools that can't be entirely automated, but want the safey of auditable tools. |
| 11 | +2. When your tooling needs to adjust rapidly and contain prepared rollback procedures. |
| 12 | +3. When this is a semi-custom situation that doesn't warrant building dedicated and expensive tooling |
| 13 | +4. When you've grown out of shell scripts but aren't ready to build it in Golang or Rust |
| 14 | + |
| 15 | +### Runbook Best Practices |
| 16 | +1. Include a Summary/Purpose, Step descriptions, Warning signs, Verification Steps and Execution Steps in their natural order |
| 17 | +2. Non-mutative actions can be included anyhere |
| 18 | +3. Mutative actions (destroy a server or force a failover) must use the `confirm` flag |
| 19 | +4. Write pre-check steps before mutation steps in order to increase safety of the procedure |
| 20 | +5. Runbooks for critical operations should be run by pairs of staff members |
| 21 | + 1. One to execute the book |
| 22 | + 2. A second to validate and perform safety checks |
| 23 | + |
| 24 | +## CLI |
| 25 | + |
| 26 | +```sh |
| 27 | +$RUNBOOK_HELP |
| 28 | +``` |
| 29 | + |
| 30 | +Shell completion is included via click library and enabled as follows [link](https://click.palletsprojects.com/en/8.1.x/shell-completion/#enabling-completion) |
| 31 | + |
| 32 | +``` |
| 33 | +# Bash |
| 34 | +# Add this to ~/.bashrc: |
| 35 | +eval "$(_RUNBOOK_COMPLETE=bash_source runbook)" |
| 36 | + |
| 37 | +# Zsh |
| 38 | +# Add this to ~/.zshrc: |
| 39 | +eval "$(_RUNBOOK_COMPLETE=zsh_source runbook)" |
| 40 | + |
| 41 | +# Fish |
| 42 | +# Add this to ~/.config/fish/completions/foo-bar.fish: |
| 43 | +_RUNBOOK_COMPLETE=fish_source runbook | source |
| 44 | +``` |
| 45 | + |
| 46 | +For advanced completion setup see [docs](https://click.palletsprojects.com/en/8.1.x/shell-completion/#enabling-completion) |
| 47 | + |
| 48 | +# Principles |
| 49 | + |
| 50 | +- Prefer deno for better package management and developer ergonomics |
| 51 | + - But allow for other kernels (python) as secondary option, via compatible libraries |
| 52 | +- Make `runbook` batteries included for interfacing with shell commands and common runbook |
| 53 | +operations (ie grafana and notifications) |
| 54 | +- Sets up necessary requirements to ensure cell executions are timed and displayed as |
| 55 | +long as executions run through `runbook run ...` command |
| 56 | + |
| 57 | +# Caveats |
| 58 | + |
| 59 | +1. Running notebook in VScode does not set the timings necessary in notebook for being auditable and exported later |
| 60 | + 1. Recommendation: if auditable runs are needed, use jupyter via browser `runbook run TITLE` |
| 61 | +1. Notebooks have different structured ids per cell depending on run environment |
| 62 | + 1. Recommendation: if requiring consistency, write your own pre-processor to standardize on an id format |
| 63 | +1. Builting shell package requires a shell environment and is only expected to run on Linux or Mac not Windows. |
| 64 | + 1. Recommendation: suggest fixes in PR or Issues on Github |
| 65 | + |
| 66 | +## Deno / Typescript |
| 67 | +1. Parameter cells should use `let` declarations to allow for param overriding |
| 68 | + - This is required to correctly support executing the ts version of notebooks. |
| 69 | +1. Confirm/prompt functions always return false in notebooks due to lack of support |
| 70 | + in deno kernel. We may invest in upstreaming a patch to support this as it has support |
| 71 | + in python notebooks |
0 commit comments