Jinja: It’s More Than Just Config Generation!

Jinja: It’s More Than Just Config Generation!

If I’m honest, I feel like Jinja gets a bad rap.

Its role is often thought to be only for generating network configurations.
And with model-driven automation being on the rise it can feel like Jinja is a legacy, tainted tool that we should be moving away from.

I’m here to say there’s more to Jinja than that.

Here are a few other ways Jinja is used in the field of network automation:

1. Ansible – Inline Data Manipulation
Filter and loop over only the interfaces you want, right inside the playbook, without extra preprocessing:

- name: Show enabled interfaces
  debug:
    msg: "{{ item.name }} - {{ item.ip }}"
  loop: "{{ interfaces | selectattr('enabled') | list }}"

2. NetBox – Custom Links
Build custom clickable links in the NetBox UI using data from the NetBox data model. These links are built using Jinja:

https://{{ obj.primary_ip.address }}/

3. Nautobot – Export Templates
Generate reports and documentation using Jinja-based templates that reference data from the Nautobot data model:

{% for dev in queryset %}
{{ dev.name }},{{ dev.primary_ip }}
{% endfor %}

These are just a few examples. But Jinja is far more versatile than it gets credit for and I’m in no doubt it’s not going anywhere soon!

Happy automating!

Subscribe to our newsletter and stay updated.

Don't miss anything. Get all the latest posts delivered straight to your inbox.
Great! Check your inbox and click the link to confirm your subscription.
Error! Please enter a valid email address!