Skip to content

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.

  1. Collect — Use Inputs or Template blocks to collect values from the user via a form
  2. Reference — Other blocks reference those values using inputsId
  3. Substitute — Values are inserted using Boilerplate template syntax like {{ .VarName }}

There are three ways to collect variables:

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.

The Inputs block collects variables without generating files. Define variables inline, then reference them from other blocks:

<Inputs id="config">
```yaml
variables:
- 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.

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.

Commands, Checks, Templates, and TemplateInline blocks all support the inputsId prop to import variables:

<Command inputsId="config" command="echo {{ .ProjectName }}" />

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 }}"
/>

Variables are substituted using Boilerplate template syntax:

SyntaxDescription
{{ .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.