English

Jinja2 Templates Simplify Your Switch Configuration

Posted on Jan 13, 2024 by
724

What Is Jinja2?

Manually configuring multiple switches is often a tedious, time-consuming, and error-prone task. How many times have we created problems by forgetting to replace interface names or VLANs when copying and pasting configurations? A small typo can cause major problems, and that's exactly what we want to avoid.

In this case, Jinja2 plays an important role. Jinja2 is a powerful yet simple Python-based template language. Instead of manually entering every configuration, just create a template. After entering the data into the template, Jinja2 can easily generate a complete switch configuration for you, automating the process and providing convenience and reliability for network management.

Let's get started on how to use it...

Jinja2 Templates Simplify Your Switch Configuration

How to Use the Jinja2 Template

We can automate the configuration of the switch with the help of Ansible Jinja2 templates in four steps:

  • 1. Determine the specific functional configuration of the two spine or leaf switches

  • 2. Determine the specific configuration of the switch

  • 3. Create a Jinja2 template for switch specific setup that includes variables.

  • 4. Use the Jinja2 Template in AmpCon™ with Context Data (variable values) to automate the configuration of a group of switches.

The Spine-01 and Spine-02 PicOS-V switches' MLAG configuration is listed below.

Assume for the moment that we must automate the MLAG Feature configuration in the set of PicOS-V Spine switches (Spine-01 and Spine-02), which are shown in the topology below:

Jinja2 Templates Simplify Your Switch Configuration

Step 1: Determine the Two Spine Switch Configuration

Step1: Determine the Two Spine Switch Configuration

Step 2: Determine Switch Specific Configuration

The majority of the configuration lines between the spine switches are the same when you compare the MLAG configurations of the two switches shown above. There are only a few, easily distinguishable lines of setup that differ between the two switches.

Please refer to the highlights in the steps above. The following table summarizes the different variables in the data for each context:

Jinja2 Templates Simplify Your Switch Configuration

Step 3: Create a Variable-Filled Jinja2 Template

The Jinja2 template has configuration lines with variables at the top. Double curly braces are used by Jinja2 to represent variables. The Jinja2 Template's variables definition (context data) are located at the bottom.

See Appendix A – Jinja2 Template to Configure MLAG in Spine PicOS-V Switches for additional information.

Step 4: Utilize the Jinja2 Template in AmpCon™ to Automate Configuration for a Group of Switches

We may automate the configuration of the MLAG feature in a spine and leaf cluster using PicOS-V switches by performing the following steps with AmpCon™, a network controller from Pica8 for multi-vendor networks:

  • Upload template

  • Make each spine's configuration

  • Push configuration to spine(s)

Two-minute video tutorial

For more detailed step-by-step example, refer to “Automate Configuration of MLAG Feature in PicOS-V Switches” on page six.

Advantages of Using Jinja2 Templates to Configure Switches

Jinja2 templates bring several advantages when compared to manually configuring switches:

  • Efficient Automation: Save time and effort by automating the configuration process with Jinja2 templates.

  • Seamless Scalability: Easily extend configurations to a large number of switches, ensuring smooth management of expansive networks.

  • Error Mitigation: Minimize downtime by reducing the chance of configuration errors, a common issue in manual setups.

  • Versatile Compatibility: Jinja2 templates offer flexibility and compatibility with a variety of switch models, providing versatility in network administration.

  • Enhanced Uniformity: Improve consistency across switches, fostering standardized configurations and lowering the risk of discrepancies.

Conclusion

If you're seeking an automated approach to configure switches, Jinja2 templates stand out as a powerful tool to help save time, reduce errors, and enhance configuration consistency.

FS and Pica8 have established a strategic partnership, and you can explore products such as the PicOS® series, PicOS-V, and AmpCon™ network manager at FS.com. By combining Jinja2 templates with PicOS® and AmpCon™, you can achieve extremely flexible, resilient, and efficient network management. Start your free trial of PicOS-V now.

You might be interested in

Knowledge
See profile for Howard.
Howard
What Is PicOS-V and How to Use It
Jan 12, 2024
1.0k
Knowledge
Knowledge
Knowledge
See profile for Sheldon.
Sheldon
Decoding OLT, ONU, ONT, and ODN in PON Network
Mar 14, 2023
386.2k
Knowledge
See profile for Irving.
Irving
What's the Difference? Hub vs Switch vs Router
Dec 17, 2021
367.6k
Knowledge
See profile for Sheldon.
Sheldon
What Is SFP Port of Gigabit Switch?
Jan 6, 2023
335.6k
Knowledge