4.9 KiB
Variables
Variables are defined per template in template.json under the top-level variables array. There is no separate schema reference layer anymore, so the manifest is the source of truth.
Runtime Shape
Each entry in variables is a group. Each group contains items.
{
"variables": [
{
"name": "general",
"title": "General",
"description": "Base settings",
"items": [
{
"name": "service_name",
"type": "str",
"title": "Service name",
"default": "my-service"
},
{
"name": "environment",
"type": "enum",
"title": "Environment",
"value": "stage",
"config": {
"options": ["prod", "stage", "dev"]
}
}
]
}
]
}
Group fields:
nametitledescriptiontoggleneedsitems
Item fields:
nametypetitledescriptiondefaultvaluerequiredneedsextraconfig
Runtime mapping notes:
titleis used as the prompt labeldescriptionis used as the display/help text- if
descriptionis omitted, the runtime falls back totitle
Supported Types
strintfloatboolenumemailurlhostnamesecret
Type notes:
booldefaults tofalsewhen omitted- other types default to empty unless a
defaultorvalueis provided secretvalues are masked in prompts and display output
default vs value
Use default for the normal manifest default.
Use value when the template should pin the runtime value directly. If both are present, value wins.
Example:
{
"name": "environment",
"type": "enum",
"title": "Environment",
"default": "prod",
"value": "stage",
"config": {
"options": ["prod", "stage", "dev"]
}
}
Config Object
Additional behavior is configured through config.
Supported fields:
placeholdertextareaunitoptionssliderminmaxstepautogenerated
Enum Options
{
"name": "environment",
"type": "enum",
"title": "Environment",
"config": {
"options": ["prod", "stage", "dev"]
}
}
Textarea Input
{
"name": "notes",
"type": "str",
"title": "Notes",
"config": {
"textarea": true,
"placeholder": "Optional notes"
}
}
Integer Slider
{
"name": "replicas",
"type": "int",
"title": "Replicas",
"default": 3,
"config": {
"slider": true,
"min": 1,
"max": 9,
"step": 2,
"unit": "nodes"
}
}
Autogenerated Secrets
config.autogenerated is supported only for secret variables.
Character-based example:
{
"name": "database_password",
"type": "secret",
"title": "Database password",
"config": {
"autogenerated": {
"kind": "characters",
"length": 40,
"characters": ["A", "B", "1", "2"]
}
}
}
Base64 example:
{
"name": "api_token",
"type": "secret",
"title": "API token",
"config": {
"autogenerated": {
"kind": "base64",
"bytes": 12
}
}
}
Rules:
- autogenerated secrets cannot define
default - base64 generation uses
bytes, notlength autogeneratedon non-secret variables is rejected
Dependencies with needs
Both groups and items support needs.
Examples:
"needs": "traefik_enabled=true""needs": "network_mode=bridge,macvlan""needs": "network_mode!=host""needs": "traefik_enabled=true;network_mode=bridge"
Semantics:
- semicolon means AND
- comma means OR within a single comparison
=means the value must match!=means the value must not match
Behavior notes:
- group
needscontrols whether the group is considered available - item
needscontrols whether the item is shown and validated - disabled boolean items are reset to
falseunless they were explicitly set via CLI
Group Toggles
Groups may define toggle, but the referenced toggle variable must exist as a boolean item in that same group.
{
"name": "traefik",
"title": "Traefik",
"toggle": "traefik_enabled",
"items": [
{
"name": "traefik_enabled",
"type": "bool",
"title": "Enable Traefik",
"default": false
},
{
"name": "traefik_host",
"type": "hostname",
"title": "Hostname"
}
]
}
If the toggle variable is missing, the runtime ignores the toggle.
Override Order
For a loaded template, values are applied in this order:
default/valuefromtemplate.json- saved defaults from the active config file
--var-file--var- interactive prompt answers
Inspecting Variables
Use show against the template you care about:
boilerplates compose show nginx
boilerplates terraform show cloudflare-dns-record
That view reflects the actual runtime state for that template, including defaults, dependencies, toggle state, and file structure.