This article describes how to configure multiple devices using a Jinja template configuration and Ansible playbook to avoid manually configuring each device separately.
Manually configuring each device in a large topology can be a cumbersome, time-consuming an error-prone process requiring a separate login to each device.
Example with set up lab environment containing 3 logical systems on 3 routers each:
The logical-system "lr3" will serve as a route reflector. The following example configuration on "lr1" will stay the same for the remaining 7 logical systems, except for the local-address.
set logical-systems lr1 protocols bgp group pe type internal set logical-systems lr1 protocols bgp group pe export nhs set logical-systems lr1 protocols bgp group pe neighbor 192.168.0.3 local-address 192.168.0.1 set logical-systems lr1 protocols bgp group pe neighbor 192.168.0.3 family inet unicast set logical-systems lr1 protocols bgp group pe neighbor 192.168.0.3 family inet-vpn unicast set logical-systems lr1 protocols bgp group pe neighbor 192.168.0.3 family inet6 labeled-unicast explicit-null set logical-systems lr1 protocols bgp group pe neighbor 192.168.0.3 family l2vpn signaling set logical-systems lr1 protocols bgp group pe neighbor 192.168.0.3 family evpn signaling set logical-systems lr1 protocols bgp group pe neighbor 192.168.0.3 family inet-mvpn signaling
By generating a Jinja2 configuration template, repetitive configuration tasks across multiple devices can be automated. For example, in the above case you could use a Jinja2 configuration template to automatically build BGP configuration files, which could be applied using an Ansilbe playbook. All of this can be done without logging into a single router. The following snippet from the Jinja2 template shows how to place the variables and loop through the logical systems:
The same concept can be extended to reduce repetitive configuration tasks such as configuring MPLS, IS-IS, interfaces and other services separately. Identify a common template and variables within the template which could be modified to automatically build configuration files suited for all devices (or logical systems in this case). The following steps are required:
To start, copy the project files from the following GitHub location:
Gather the project files from the Github location " https://github.com/pranavs2508/apply-bgp-configuration "
Or
Use "git clone https://github.com/pranavs2508/apply-bgp-configuration " on your Linux terminal.
Example: