Skip to content
This repository has been archived by the owner on Jun 28, 2022. It is now read-only.

Build Phase

TiTom edited this page Nov 13, 2015 · 2 revisions

Build Phase

In this section, script will provide offline configuration by using template and YAML to create baseline configuration with specific data per device.

Configuration file can be imported in a ZTP server to push configuration on every new devices you add in your network.

Build configuration offline

Script is available at this page

First of all, it is required to build a Jinja2 template. A Jinja2 is a common language to build template and it is not junos oriented. More information about how Jinja2 works is available at the following page. Below is an example of JINJA2 syntax in a Junos configuration:

interfaces {
    {%- for item in uplinks %}
    {{uplinks[item]['interface']}} {
        unit 0 {
        description "{{uplinks[item]['description']}}";
            family inet {
                address {{uplinks[item]['address']}}/31;
            }
        }
    }
    {%- endfor %}

Then you have to create your YAML file to specify a key values per device. Below is a quick overview of how a YAML file might be constructed:

 - host_name: leaf1
  management_ip: 172.30.108.139
  # loopback and router_id and ibgp (overlay/evpn) local_address are the same
  loopback: 10.20.1.1
  router_id: 10.20.1.1
  switch_options_route_distinguisher: 10.20.1.1:1
  snmp_location: "DC1 room1 raw1 rack01"
  uplinks: 
   to_spine01: 
    interface: et-0/0/22
    description: "UPLINK - L1 to S1 - 192.168.0.0/31"
    address: 192.168.0.0
   to_spine02: 
    interface: et-0/0/23
    description: "UPLINK - L1 to S2 - 192.168.0.2/31"
    address: 192.168.0.2
  • Usage:
python build-configuration-offline.py -t $template-file$ -d $yaml-file$ -k $yaml-key$

In this scenario, YAML key is entry prefixes with - in your YAML file.

This script will create one file per device defined in the YAML file.

Clone this wiki locally