NetAuto Academy

Configuration & Template Automation

Why Templates Matter

Intermediate11 min read

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
🎓 Teach This Lesson

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:

push_ntp.py — Netmiko Fundamentals, Lesson 4
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.

Quick checkConcept check
What's the core problem with hardcoding each device's configuration as its own Python string, once you have more than a handful of devices?

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.

Hard-coded configuration
  1. One Python string per deviceSW1's block, SW2's block, SW3's block...
  2. Every device-specific value typed by hand
  3. A typo or missed device hides in the copy-paste
Templated configuration
  1. One template, many devicesthe structure is written once
  2. Device-specific values come from dataa dict or list, not hand-typed text
  3. The same template produces every device's config
Quick checkIdentify the correct code
A team needs to configure VLAN 10 named USERS on 40 switches. Which approach is what this module is building toward?

The full progression this module builds

  1. Hard-coded configurationone Python string per device — where this curriculum starts
  2. Repeated Python stringscopy-pasted per device — the pain point
  3. Structured dataa dict/list describing each device's values
  4. Templatewritten once, describing the shape
  5. Rendered configurationdata + template = real config text
  6. Validation / previewrendered ≠ automatically correct
  7. 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.

Quick checkConcept check
Which stage in the progression above is where a network engineer's own device data (VLANs, hostnames, per-site values) actually lives?

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.

Quick checkMyth check
Does this module replace Reliable Automation's retry policy, dry-run mode, or post-check verification with something new?

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