...

/

Configuration Templates

Configuration Templates

Let's take a look at some examples of Jinja2 templates for VLAN, VRF, OSPF, static routes, etc.

Here are more examples of templates that can be refactored to fit or used directly in a network for configuration management coverage by function. The matching data model dictionaries will be posted for reference to make it easier to connect the two. However, focus on the templates at this point.

Below are examples of Jinja2 templates and playbooks to help you with your configurations.

VLAN

Here is an example for VLAN configuration:

vlan {{ global_campus_defaults.native_vlan }}
name NativeVLAN
{% if host_vlans is defined %}
{% for host_vlan in host_vlans %}
vlan {{ host_vlan }}
name {{ host_vlans[host_vlan].name }}
{% endfor %}
{% endif %}
VLAN template and partial

Data model: group_vars/CAMPUS.yml

  global_campus_defaults:
    native_vlan: 99

Data model: host_vars/DIST01.yml

VRF

Here is an example for VRF configuration:

{% if platform_defaults.type == 6000 or platform_defaults.type == 4000 %}
{% for host_vrf in host_vrfs %}
{% if host_vrf == "global" %}
{% else %}
vrf definition {{ host_vrf }}
{% endif %}
{% if host_vrf == "global" %}
{% else %}
vnet tag {{ host_vrfs[host_vrf].tag }}
address-family ipv4
exit-address-family
{% endif %}
{% if host_vrfs[host_vrf].multicast is defined %}
ip multicast-routing vrf {{ host_vrf }}
{% endif %}
{% endfor %}
{% endif %}
VRF template and partial

Data model: ...