Templates and Command Flows
One of rauto’s core strengths is that reusable execution logic is split into two layers:
- command templates for generating final command text
- command flow templates for interactive prompt/response execution
Command templates
Section titled “Command templates”Command templates are based on Minijinja, which is compatible with Jinja2 syntax and well suited for parameterizing repeated command structures.
A typical template
Section titled “A typical template”conf t{% for vlan in vlans %}vlan {{ vlan.id }} name {{ vlan.name }}{% endfor %}endExample variables:
{ "vlans": [ { "id": 10, "name": "MARKETING" }, { "id": 20, "name": "ENGINEERING" } ]}Execute it with:
rauto template configure_vlan.j2 \ --vars ./vars.json \ --connection core-sw-01How templates are stored
Section titled “How templates are stored”Command templates are not just loose local files. They are stored in rauto’s SQLite-backed runtime data and shared by both CLI and Web.
Common management commands:
rauto templates listrauto templates show configure_vlan.j2rauto templates delete configure_vlan.j2Command flow templates
Section titled “Command flow templates”When your task is not “send a fixed list of commands once” but something like this:
- the device asks multiple questions
- each prompt needs a different response
- the flow may need runtime variables or data from another saved connection
then rauto flow is usually the better abstraction.
What command flows are good at
Section titled “What command flows are good at”- Cisco-style
copy scp:/copy tftp:operations - installer-like CLI wizards
- multi-step confirmation flows
- device-side file transfer flows
- interactive command sequences driven by runtime input
Example: Cisco-like copy flow
Section titled “Example: Cisco-like copy flow”The rauto repository ships with an editable example:
name = "cisco_like_copy"description = "Generic interactive SCP/TFTP copy flow for Cisco-like CLIs."stop_on_error = truedefault_mode = "Enable"
[[vars]]name = "command"required = true
[[steps]]timeout_secs = 300command = "{{command}}"
[[steps.prompts]]patterns = ["(?i)^Address or name of remote host.*\\?\\s*$"]response = "{{server_addr}}"The key ideas in this model are:
- each
steprepresents one command execution phase promptsmatch device output and answer automaticallyvarscan declare variable metadata for CLI validation and Web form rendering
Runtime variable rules
Section titled “Runtime variable rules”Command flows support multiple variable injection styles:
--vars <file>to load variables from a JSON file--vars-json <json>to pass inline JSON- top-level variable access such as
{{server_addr}} - nested access through
vars, such as{{vars.server_addr}} - connection-aware references such as
{{peer.host}}
Additional runtime rules documented in the current README:
- runtime variables are merged into both top-level names and the nested
varsobject - references can use
connection_name.param_namefor cross-connection lookup - plain
param_nameresolves request vars first, then falls back to current target connection params - command flow templates can declare
current_connection_alias = "<alias>"so the selected target can be referenced directly as{{alias.host}},{{alias.username}}, and similar fields - one runtime variable can itself point to another saved connection name, enabling patterns such as
peer=edge94and then{{peer.host}}
Flow variable schema
Section titled “Flow variable schema”Command flow templates can declare a vars schema so both CLI and Web can validate or render runtime inputs more reliably.
The README calls out these supported fields:
nametyperequireddefaultoptionslabeldescription
This is important for enterprise usage because it turns a command flow into a more governable operator interface instead of a loose string template.
Built-in flows and selector behavior
Section titled “Built-in flows and selector behavior”The current README also documents built-in flow exposure:
- built-in templates are exposed via
/api/flow-templates/builtins - CLI execution accepts
--template builtin:<name> - Web selectors also use
builtin:<name>values
That means a team can mix:
- built-in flows shipped with the product
- organization-managed saved flows in SQLite
- ad-hoc local TOML files for experimentation
Flow control and branching
Section titled “Flow control and branching”The current flow model supports output-branch actions such as:
nextjumpstop_successstop_failure
This is one of the reasons rauto flow is more powerful than a simple expect-style macro. It can model branching behavior in guided operational sequences.
Recording behavior for command flows
Section titled “Recording behavior for command flows”The README explicitly notes:
- every execution records a session by default
--record-level key-events-onlykeeps the audit-friendly minimum--record-level fullcaptures richer prompt and transition detail--record-fileexports the same JSONL session to a file when needed
Managing command flow templates
Section titled “Managing command flow templates”rauto flow-template listrauto flow-template show cisco_like_copyrauto flow-template create cisco_like_copy --file ./my-flow.tomlrauto flow-template update cisco_like_copy --file ./my-flow.tomlrauto flow-template delete cisco_like_copyflow vs upload
Section titled “flow vs upload”Best for device-side interaction such as:
- the device running
copy scp: - the device asking for server, username, and password
- multiple prompts during one operation
upload
Section titled “upload”Best for directly uploading a local file through the remote host’s sftp subsystem:
rauto upload \ --local-path ./configs/daemon.conf \ --remote-path /tmp/daemon.conf \ --connection linux-jump-01Many network devices do not support SFTP, so upload is not a replacement for flow.
Best practices
Section titled “Best practices”- prefer command templates for pure command rendering
- prefer command flows when device interaction is involved
- store shared templates in
rautoinstead of scattering them in script folders - use
--dry-runor a test environment first for complex flows - declare clear
varsfor file transfer and installer-like templates
If you are moving toward rollback-aware change execution, continue with Transactions and Orchestration.