Skip to content

Auto Build

Ben Trachtenberg edited this page Jun 5, 2018 · 3 revisions

A Auto Build uses only a csv file, which can be created with Excel to make it more readable to hold variables, and to tell it what yaml file to use. In this example I wanted to show you can use variables, and static data within the yaml.

Create a csv file in the yaml directory, you can figure out what is needed for variables by looking at the templates in the templates directory. For this example you can see the base yaml templates is template_auto_build_v2.yml.

  1. Create csv file for your variables.
  2. Use the cli to run a build, something like this "python QuickConfigTemplates run_build -a -t auto_build_v2.csv -c" this is dependent on if you are running from source, or compiled, compiled will look something like this "QuickConfigTemplates run_build -a -t auto_build_v2.csv -c"

Example csv data auto_build_v2.csv

variable,value,notes
yml_template,template_auto_build_v2.yml,The yml template file
change_number,TKTNUMBER,
service_vrf_name,VRF_NAME,
vlan_tag,107,
service_export_rt,12345:1,
pe_name_a,SOME-ROUTER-00,
pe_mgmt_ip_a,10.1.1.1,
pe_interface_a,Te0/2/0/7,
pe_ip_a,10.2.2.1,
pe_mask_a,255.255.255.254,
ce_bgp_as,123456,
ce_name_a,SOME-CE-00,
ce_ip_a,10.2.2.2,
pe_name_b,SOME-ROUTER-01,
pe_mgmt_ip_b,10.1.1.2,
pe_interface_b,Te0/2/0/7,
pe_ip_b,1.1.1.1,
pe_mask_b,255.255.255.254,
ce_name_b,SOME-CE-01,
ce_ip_b,10.2.2.5,

Example yaml data template_auto_build_v2.yml

--- # This is a yml template
version: 2
data:
-   template: iosxr_base.jinja2
    ticket_number: {{ change_number }}
    devices:
    -   device:
        -   devicename: {{ pe_name_a }}
            management_ip: {{ pe_mgmt_ip_a }}
            mpls_pe_to_ce_interfaces:
            -   interface: {{ pe_interface_a }}.{{ vlan_tag }}
                vrf: {{ service_vrf_name }}
                tag: {{ vlan_tag }}
                description: {{ ce_name_a }} vrf {{ service_vrf_name }}
                ip: {{ pe_ip_a }}
                mask: {{ pe_mask_a }}

-   template: ios_base.jinja2
    ticket_number: {{ change_number }}
    devices:
    -   device:
        -   devicename: {{ pe_name_b }}
            management_ip: {{ pe_mgmt_ip_b }}
            routed_interfaces:
            -   bfd: true
                description: description a
                interface: g0/0
                ip: 10.1.1.1
                mask: 255.255.255.252
                tag: 701

The above will produce something like this

Ticket Number: TKTNUMBER
<SOME-ROUTER-00, 10.1.1.1>

interface Te0/2/0/7.107
 description SOME-CE-00 vrf VRF_NAME
 vrf VRF_NAME
 ipv4 address 10.2.2.1 255.255.255.254
 encapsulation dot1q 107



</SOME-ROUTER-00, 10.1.1.1>


Ticket Number: TKTNUMBER
<SOME-ROUTER-01, 10.1.1.2>

interface g0/0
 description description a
 encapsulation dot1q 701
 no switchport
 bfd interval 250 min_rx 250 multiplier 3
 ip address 10.1.1.1 255.255.255.252
 no ip redirects
 no ip proxy-arp
 arp timeout 270
end

</SOME-ROUTER-01, 10.1.1.2>