Variables
Variables
Section titled “Variables”One of the most powerful features of Runbooks is the ability to collect input from users and pass those values to Commands, Checks, and Templates. This page explains how to wire variables between blocks.
How it works
Section titled “How it works”- Collect — Use Inputs or Template blocks to collect values from the user via a form
- Reference — Other blocks reference those values using
inputsId - Substitute — Values are inserted using Boilerplate template syntax like
{{ .VarName }}
Collection methods
Section titled “Collection methods”There are three ways to collect variables:
Template block
Section titled “Template block”The Template block reads variables from a boilerplate.yml file and renders a form. It also generates files from templates. Other blocks can reference the collected variables via inputsId:
This Template block reads a boilerplate.yml file located at templates/vpc that defines an Environment variable<Template id="infra" path="templates/vpc" />
<Command inputsId="infra" command="echo 'Deploying to {{ .Environment }}'"/>Use this when you want to both collect variables AND generate files.
Standalone Inputs block
Section titled “Standalone Inputs block”The Inputs block collects variables without generating files. Define variables inline, then reference them from other blocks:
<Inputs id="config">```yamlvariables: - name: ProjectName type: string description: Name for your project```</Inputs>
<Command inputsId="config" command="mkdir {{ .ProjectName }}"/>
<Check inputsId="config" command="test ! -d {{ .ProjectName }}" title="Verify project directory doesn't exist"/>Use this when you want to collect variables that will be used by multiple blocks, or when you don’t need to generate files.
Embedded Inputs block
Section titled “Embedded Inputs block”You can embed an <Inputs> block directly inside a <Command> or <Check> block. The variables are automatically available to the parent block without needing inputsId:
<Command command="echo 'Hello, {{ .Name }}!'"> <Inputs id="greeting"> ```yaml variables: - name: Name type: string ``` </Inputs></Command>The embedded inputs are also available to other blocks via inputsId="greeting".
Use this when variables are closely tied to a single command or check.
Referencing variables
Section titled “Referencing variables”The inputsId prop
Section titled “The inputsId prop”Commands, Checks, Templates, and TemplateInline blocks all support the inputsId prop to import variables:
<Command inputsId="config" command="echo {{ .ProjectName }}" />Multiple sources
Section titled “Multiple sources”You can reference multiple input sources by passing an array. Variables are merged in order, with later sources overriding earlier ones:
<Command inputsId={["global-config", "local-config"]} command="deploy --env {{ .Environment }} --name {{ .AppName }}"/>Template syntax
Section titled “Template syntax”Variables are substituted using Boilerplate template syntax:
| Syntax | Description |
|---|---|
{{ .VarName }} | Insert a variable value |
{{ .VarName | upper }} | Transform to uppercase |
{{ .VarName | lower }} | Transform to lowercase |
{{ if .VarName }}...{{ end }} | Conditional logic |
See the Boilerplate Templates page for the full syntax reference including loops, comparisons, and helper functions.