Configuration & Template Automation
Why Templates Matter
What you'll learn
- Why a hardcoded configuration string breaks down past a handful of devices
- The seven-stage progression this module builds: data, template, render, validate, deploy
- That this module extends Reliable Automation's project, not a new one
- Why send_config_set() itself doesn't change — only how its input gets produced
Listen to a guided explanation of this lesson.
Spoken narration isn't supported in this browser.
The problem with a hardcoded string
Every configuration push so far in this curriculum has looked like this:
config_commands = [
"ntp server 192.168.1.1", # placeholder IP
]
connection.send_config_set(config_commands)A single, fixed configuration line, hardcoded directly into the script.
That works for one line on one device. Now picture a real access-layer rollout: 50 switches, each needing its own set of VLANs — different IDs, different names, some switches needing three VLANs, others needing five. Hardcoding each switch's block as its own Python string means 50 near-identical blocks, each one a chance to typo a VLAN ID or forget a switch entirely.
A better shape for the same problem
This has a familiar answer already. "Functions & Reusable Automation Logic" made exactly this case for Python code: one function definition, called from many places, instead of the same logic copy-pasted at each call site. Templating is that same idea, applied to configuration text instead of Python logic — one template, rendered once per device, driven by that device's own data.
- One Python string per deviceSW1's block, SW2's block, SW3's block...
- Every device-specific value typed by hand
- A typo or missed device hides in the copy-paste
- One template, many devicesthe structure is written once
- Device-specific values come from dataa dict or list, not hand-typed text
- The same template produces every device's config
The full progression this module builds
- Hard-coded configurationone Python string per device — where this curriculum starts
- Repeated Python stringscopy-pasted per device — the pain point
- Structured dataa dict/list describing each device's values
- Templatewritten once, describing the shape
- Rendered configurationdata + template = real config text
- Validation / previewrendered ≠ automatically correct
- Safe deploymentReliable Automation's dry-run/retry/post-check, unchanged
This is not a new project
This module extends the exact project Reliable Automation built — the same inventory format, the same retry policy, the same dry-run default, the same independent post-check, the same structured result reporting. The only thing that changes is where the configuration content itself comes from: instead of a hardcoded f-string, it's rendered from structured data through a template. Everything about deploying it safely stays exactly as Reliable Automation left it.
What doesn't change
send_config_set() itself is untouched — it still takes a list of configuration-mode command lines, exactly as "Making Configuration Changes Safely" taught it. What changes is how that list gets built: instead of typing ["ntp server 192.168.1.1"] by hand, it becomes the rendered output of a template, split into lines. The retry policy, the dry-run default, the pre-check/post-check pattern, and the structured result classification from Reliable Automation don't need to know or care whether the configuration they're applying came from a hardcoded string or a rendered template — that boundary is exactly where this module plugs in.
Key takeaways
- Hardcoded, copy-pasted configuration strings don't scale past a handful of devices — every copy is a chance for a mistake.
- Templating solves this the same way reusable functions solved repeated Python logic: one definition, driven by per-device data.
- This module's full progression: hard-coded config → repeated strings → structured data → template → rendered config → validate/preview → safe deployment.
- This is an extension of Reliable Automation's project, not a new one — the retry/dry-run/post-check/reporting machinery is untouched.
- send_config_set() itself never changes — only how the list of commands passed to it gets produced.
Done with this lesson?
Next lesson
Jinja2 Fundamentals Through Network Examples