Pcornel
Browse topics
Options
Recent
Favorites
Automation · Technical reference

Templates

Direct answer

Templates in automation generate configuration files, device configs or messages from a template plus variables, typically with Jinja2, so one tested pattern produces many consistent outputs.

When to use this

Use this when generating configuration from templates and variables.

First 30 seconds

1. Templates generate configs from data (Jinja2, Go templates, Helm).

2. Separate data from logic.

3. Validate rendered output.

4. Keep logic simple.

5. Test rendering.

Operational verification

data + template → render → validate → deploy

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
automation design and operations
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

Platformautomation design and operations · Automation implementations are tool and platform specific. Use the adjacent Domain for the technology being automated and this Domain for automation behavior.
Scope / prerequisiteUse this when generating configuration from templates and variables.
What next?3 suggested next steps
Child topics (this level)11
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

2 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 Verification path Verify boundary

Record template revision/path, render run ID and context/object identifiers; inspect the runtime/control-plane result; then query the rendered configuration/document consumed by a downstream parser or service through an independent read path and compare it with the versioned intent. The negative fixture should deliberately exercise risks such as undefined values, unsafe escaping, implicit type conversion, environment-specific filters, secret exposure, whitespace-sensitive syntax and valid render producing invalid target configuration, choosing the cases most relevant to vSphere template identity/version, guest customization, clone task, datastore/network placement and post-clone VM/guest verification. For Automation → Templates, the evidence must connect the control-plane result to the rendered configuration/document consumed by a downstream parser or service and explain any gap between desired, controller-reported and consumer-visible state.

Step 2 Where it fails Narrow the fault

Failure analysis for Automation → Templates should follow the path through the components: template/context → expression evaluation → filters/tests → rendering/escaping → target parser → target apply → read-back. Common failure classes include undefined values, unsafe escaping, implicit type conversion, environment-specific filters, secret exposure, whitespace-sensitive syntax and valid render producing invalid target configuration. Before retrying a mutating operation, read current target state using the stable identity template revision/path, render run ID and context/object identifiers; if state is unknown, stop broad retries.

Evidence references

Evidence · 1 on this Topic

Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.

observation · 1
Drill down

Subtopics

Go one level deeper into this subject.

Subtopic Template Fundamentals

Template fundamentals: separate the structure (template) from the data (variables), keep templates small and readable, and test the rendered output before deploying it.

Subtopic Jinja2

Jinja2 is the Python template engine used by Ansible, Salt, NetBox and Nornir, with {{ variables }}, {% if %} and {% for %} blocks, filters and macros.

Subtopic Variables

Template variables are the values inserted into templates, coming from inventory, a source of truth or files.

Subtopic Conditions

Conditions in templates include or change output based on variables, such as {% if vlan_id %} ...

Subtopic Loops

Loops in templates repeat a block for each item, such as {% for intf in interfaces %} to generate interface sections, keeping templates short for many items.

Subtopic Filters

Template filters transform values during rendering, such as {{ name | upper }}, {{ list | join(',') }} or ipaddr filters for subnets in Ansible.

Subtopic Configuration Templates

Configuration templates generate full device or service configs, such as a switch config or nginx.conf, from a base template plus per-device variables.

Subtopic Golden Configurations

Golden configurations are the approved standard configs for each device role, generated from templates and used as the reference for compliance and drift checks.

Subtopic Rendering

Rendering combines a template with variables to produce the final text, such as Ansible's template module or jinja2's render(), which should fail on undefined variables.

Subtopic Validation

Validation of rendered templates checks the output before deployment, such as nginx -t, a YAML lint, a device config parser or comparing with the golden configuration.

Subtopic Template Troubleshooting

Troubleshoot templates by rendering with test data and diffing the output, enabling StrictUndefined to catch missing variables, checking whitespace control and filter usage.

Key points
  • Separate structure (template) from data (variables).
  • Fail on undefined variables.
  • Validate rendered output before deploying.
Key checks
  • Template files in git — versioned
  • python3 -c "import jinja2;print(jinja2.__version__)" — engine
  • Rendered output validation — correctness
ReferenceWhy it matters1 section · depth on demand

In depth

Templates generate text — configuration files, scripts, reports — by combining a fixed layout with variable data. In automation, Jinja2 is the most common engine (Ansible, Salt, Python), with Go templates in Helm and Terraform's templatefile().

{# chrony.conf.j2 #}
{% for s in ntp_servers %}
server {{ s }} iburst
{% endfor %}
makestep 1.0 3
PracticeReason
Keep logic minimal in templatesReadability
Put data in variables/source of truthOne template, many devices
Render and diff in CISee real changes
Use StrictUndefinedFail on missing variables
ReferenceImportant terms & boundaries1 section · depth on demand

Mechanics

Automation → Templates is owned at runtime by the template engine rendering a versioned template with a bounded context and filter/function set. Its durable intent is template source plus context schema, filters/tests and escaping/output contract; the stable identity contract is template revision/path, render run ID and context/object identifiers. The consumer-visible target is the rendered configuration/document consumed by a downstream parser or service. The operating invariants are that undefined variables are handled intentionally, escaping/quoting matches target syntax, filters are deterministic, secrets are not logged and rendered output is parsed/validated before apply. Follow the chain of components template/context → expression evaluation → filters/tests → rendering/escaping → target parser → target apply → read-back and record which layer currently owns truth.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor docautomation design and operations current

Authoritative/upstream documentation reviewed for bounded claims in Templates. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://learn.microsoft.com/en-us/azure/well-architected/operational-excellence/enable-automation · confidence 94%
Depth when you need it

Deep reference

Healthy vs suspicious evidence

Output interpretation

Capture at minimum template revision, context keys, render ID, undefined/error location, output digest/path, target parser result and applied object read-back. For vSphere template identity/version, guest customization, clone task, datastore/network placement and post-clone VM/guest verification, prefer typed fields and stable IDs over human presentation text.

Confirmation

Confirm action

Continue?