Bulk IP Address Allocation (Netbox) - Jinja2 Template
  • 18 Oct 2024
  • Dark
    Light
  • PDF

Bulk IP Address Allocation (Netbox) - Jinja2 Template

  • Dark
    Light
  • PDF

Article summary

Jinja2%20Templates

Before we start building our automation, we’re going to take a look at Jinja2 Templates.  If you are not familiar with Jinja2 Templates, they are a templating language developed for Python that allows users to take structured data and format it for human readability.  We will build a simple template that will show you how this is done.  Part of this use-case exercise will leverage a pre-built Jinja2 template, so this exercise will give you a better understanding of how they are built.

Jinja2 Template Video

Step 1

From IAP Cloud, log into your IAP instance by clicking the blue Launch icon. 

Step 2

From the IAP Dashboard, select Automation Studio.  From Automation Studio, click the at the top of the left navigation panel, and the Create window will open.

Step 3

From the dropdown, select Template.

Step 4

We will name our template Template - XX (XX represents your initials) and enter Workshop for the Group. From the Type dropdown, select Jinja2. Click Create

Step 5

Using the sample JSON data provided, enter the data on the left side of the template window.

{
"firstName": "", 
"title": "", 
"companyName": "",
 "repeatableTask": "", 
"vendorNames": []
}

Step 6

Using the sample template text, update the Jinja2 Template on the right side of the template window.  Once both templates have been populated, the template will be parsed and the output is displayed in the Output area.  This response can be used in workflows in the form of an object.  Click Save.

My name is {{ firstName }}, and I'm a(n) {{ title }}.
Here at {{ companyName }}, we would like to automate {{ repeatableTask }}.
{% if vendorNames | length == 1 %}
The most common networking vendor I work with is {{ vendorNames[0] | title }}. {% elif vendorNames | length > 1 %}
The most common networking vendors I work with are:
{% for vendor in vendorNames %}
- {{ vendor | title }}
{% endfor %}
{% endif %}

Step 7

Update the template on the left side of the template window and see how the output at the bottom of the screen changes.  

Step 8

Our use-case exercise will utilize the pre-built Bulk Allocate IP Addresses Report Jinja2 Template. Take a moment and review the template before proceeding with the exercise. 



Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.