Scaffolding Templatesο
Audience: Operators who need to scaffold new configuration files, zones, or tenants from a consistent template β whether for a single file or an entire multi-tenant directory tree.
Overviewο
The strata new command creates pre-filled configuration files from templates. There are three
layers of templates, each more powerful than the last:
Layer |
Source |
Best for |
|---|---|---|
1 β Single file |
Package or workspace |
One-off file creation |
2 β Bundle directory |
|
Multi-file scaffolds (e.g. a full environment stack) |
3 β Solution bundle |
|
Multi-path, multi-tenant fleet scaffolding |
Templates use Jinja2 syntax for variable substitution: {{ variable_name }}.
Layer 1 β Single-file templatesο
The simplest case: scaffold one YAML file from a template.
# List all available templates
strata new --list
# Create a file from the built-in 'namespace' template
strata new --template namespace --name my-namespace
# Write to a specific directory
strata new --template namespace --name my-namespace --path config/namespaces/
# Supply variables inline (skip interactive prompt)
strata new --template environment --name dev --set region=westeurope
Template files live in:
Package built-ins: shipped with strata (
strata new --listshows them)Workspace overrides:
.strata/templates/<name>.yamlβ takes precedence over built-ins
Variables in the template file ({{ name }}, {{ region }}, etc.) are filled from:
--set KEY=VALUEflags (highest priority)spec.contextinsolution.json(team-shared defaults)Interactive prompt for anything still missing (Ctrl+C to cancel)
Layer 2 β Bundle directory templatesο
A bundle directory contains multiple files that are all copied and rendered together. This is useful when a logical unit requires more than one file (e.g. a stack with a workspace, deployment, and environment file).
Structure:
.strata/templates/
βββ mystack/
βββ template.yaml # optional: name, description, variables
βββ scaffold/
βββ config/
β βββ {{ name }}-config.yaml
βββ deploy/
β βββ deploy-{{ name }}.yaml
βββ environments/
βββ env-{{ name }}.yaml
template.yaml (optional manifest):
name: mystack
description: Full stack β config, deployment, and environment
variables:
- name: name
description: Short name for this stack
Usage:
strata new --template mystack --name acme
This copies every file under scaffold/, rendering {{ name }} in both path segments
and file content. Output goes to the current directory (or --path if given).
Variable names can also appear in directory and file names β the entire relative path is rendered before writing.
Layer 3 β Solution bundlesο
Solution bundles are defined in solution.json and describe where to write templates
rather than what to copy. This enables a single strata new command to scaffold
files into multiple locations at once β the foundation for fleet and multi-tenant workflows.
Defining solution bundlesο
Edit .strata/solution.json and add a spec.templates section:
{
"spec": {
"templates": [
{
"name": "customer",
"bundle": [
{
"name": "customer",
"path": "customers/{{ shortname }}"
},
{
"name": "bootstrap",
"path": "zones/{{ zonecode }}/customers/{{ shortname }}"
},
{
"name": "environment",
"path": "zones/{{ zonecode }}/customers/{{ shortname }}/{{ environment }}"
}
]
},
{
"name": "zones",
"bundle": [
{
"name": "zone",
"path": "zones/{{ zonecode }}"
}
]
}
]
}
}
Each entry in bundle has:
nameβ the template source to look up via the standard resolution chain (layers 1β2)pathβ Jinja2 expression for the destination directory, relative to the work path
How resolution worksο
When you run strata new --template customer, the CLI:
Finds
"customer"insolution.json spec.templates[]Collects all Jinja2 variables across every bundle path:
shortname,zonecode,environmentSubtracts any already supplied via
--setorsolution.json spec.contextPrompts interactively for whatever remains (Ctrl+C cancels cleanly, nothing is written)
For each bundle entry:
Renders the
pathwith all collected variables β destination directoryResolves the
nameas a template source (.strata/templates/<name>/or package file)Copies and renders all template files into the destination directory
Usageο
# Scaffold a new zone
strata new --template zones
zonecode: eu-west
# β creates: zones/eu-west/
# Scaffold a new customer (prompts for all variables)
strata new --template customer
shortname: acme
zonecode: eu-west
environment: production
# β creates:
# customers/acme/
# zones/eu-west/customers/acme/
# zones/eu-west/customers/acme/production/
# Supply all variables inline β no prompts
strata new --template customer --set shortname=acme --set zonecode=eu-west --set environment=production
Fleet and multi-tenant patternsο
Solution bundles are the building block for operating strata at scale.
Recommended directory layoutο
<workspace root>/
βββ customers/
β βββ acme/ β customer definition files
β βββ contoso/
βββ zones/
β βββ eu-west/ β zone bootstrap files
β β βββ customers/
β β βββ acme/ β customer bootstrap in this zone
β β β βββ production/ β environment files
β β βββ contoso/
β βββ us-east/
β βββ customers/
β βββ acme/
βββ .strata/
βββ solution.json
Onboarding a new customerο
# 1. Add a new zone (if it doesn't exist yet)
strata new --template zones --set zonecode=us-east
# 2. Onboard the customer into that zone
strata new --template customer \
--set shortname=contoso \
--set zonecode=us-east \
--set environment=production
Onboarding a customer into multiple zonesο
Run strata new --template customer once per zone:
for zone in eu-west us-east ap-southeast; do
strata new --template customer \
--set shortname=acme \
--set zonecode=$zone \
--set environment=production
done
Template resolution order (full)ο
When a template name is given, the CLI searches in this order and uses the first match:
Priority |
Source |
Location |
|---|---|---|
0 |
Solution bundle |
|
1 |
Workspace bundle dir |
|
2 |
Workspace single file |
|
3 |
Package bundle dir |
Built-in bundle shipped with strata |
4 |
Package single file |
Built-in |
Solution bundles (priority 0) define routing β where files land. The actual template content always comes from priorities 1β4.
Adding new template sourcesο
Add a workspace single-file templateο
Create .strata/templates/<name>.yaml. Use {{ variable }} for substitution.
Add a workspace bundle directoryο
.strata/templates/
βββ <name>/
βββ template.yaml # optional manifest
βββ scaffold/
βββ ... # files and folders to copy
Add a solution bundleο
Edit solution.json directly β add an entry to spec.templates[]. No CLI command
exists yet for this; it is a hand-authored section of the solution state file.
Each bundle entryβs name must match an existing template source (priorities 1β4 above).