Network Automation Cookbook
上QQ阅读APP看书,第一时间看更新

How it works...

Using a similar approach to all the previous recipes, we use a Jinja2 template to generate the BGP configuration for the Juniper devices. However, in this section, we declare the BGP parameters in two different places, which are the group_vars and host_vars directories. In the group_vars/all.yml file, we declare the overall parameters for our BGP topology, such as the RR that we will use, and which address families we will configure. For each node in our inventory, we create a directory in the host_vars directory, and inside this directory, we create a bgp.yml file. This new YAML file holds the BGP peers for each node in our inventory. We use the data defined in these two locations to render the BGP configuration for each device.

This is a sample of the BGP configuration for the mxp01 router, which is the RR in our topology:

protocols {
bgp {
group Core {
type internal;
local-address 10.100.1.254;
cluster 10.100.1.254;
family inet {
unicast;
}
family inet-vpn {
unicast;
}
neighbor 10.100.1.1;
neighbor 10.100.1.2;
neighbor 10.100.1.3;
}
}
}