Recommended Practices
Let's take a look at some guidelines we can follow to write better, human-readable templates.
We'll cover the following
Guidelines
Some general guidelines to help write templates that are human-readable and easy to change in collaboration with a full NetDevOps team:
- Use meaningful names for all files, variables, and data models.
- Differentiate between data found in
group_vars
andhost_vars
with standard prefixes on variables in data dictionaries. - Keep templates small, modular, and focused on specific tasks, features, platforms, or technologies.
- Do not write massive one-size-fits-all templates designed to provide full coverage of a device.
- Model data and abstract it from configurations.
- Do not nest too deep in multi-layered
for
loops orif
statements. - Write code in an editor that supports Jinja2 and YAML syntaxes.
- Establish best practices and share them with the team.
- After learning and developing skills, refactor code often.
- Software development is a continuous cycle of improvement.
Scope
We have created approximately 35 templates to cover all the configurations of the core, distribution, and access devices in our enterprise network. As more features arise, this list is certain to grow. Pick and choose which templates apply to the network and add more. For example, an EIGRP template.
Get hands-on with 1400+ tech skills courses.