Playbook name: pb_provision_ebgp_underlay.yml
This playbook first discovers the network topology, then it generates the Junos configuration for underlay IP connectivity and EBGP peering over the physical interfaces to redistribute the loopback addresses.
This Playbook relies on the following roles
targets
(default value =ip_underlay
): it is the hosts parameter of the playbook, used to set the target hosts. It can be a group name or a device name
push_config
: with this tag, upon generating the configurations, the playbook also loads and commits them to the corresponding remote devices.
Example:
ansible-playbook pb_provision_ebgp_underlay.yml -i inventory/hosts.ini -t push_config
We assume you have an inventory folder structured as following:
inventory
├── group_vars
├── host_vars
└── hosts.ini
Your hosts.ini
initially looks like this
# inventory/hosts.ini
router-1
router-2
router-3
router-4
router-5
router-6
-
Create a group called
ip_underlay
in the inventory file whose members are the devices you want to be part of the EBGP underaly:# inventory/hosts.ini router-4 router-5 router-6 [ip_underlay] router-1 router-2 router-3
-
Run the playbook with no further inputs:
ansible-playbook pb_provision_ebgp_underlay.yml -i inventory/hosts.ini
Result:
IP and EBGP configurations are generated for all members of the ip_underlay group. Files are stored in the following autogenerated folder:
inventory
├── _ebgp_underlay_configs
│ ├── ebgp_underlay.router-1.conf
│ ├── ebgp_underlay.router-2.conf
│ ├── ebgp_underlay.router-3.conf
│ ├── ip_underlay.router-1.conf
│ ├── ip_underlay.router-2.conf
│ └── ip_underlay.router-3.conf
IP addresses, ASNs and all the other parameters are using the default values. Following examples shows how to customize.
Example of output configuration:
# ip_underlay.router-1.conf
interfaces {
xe-0/0/1 {
mtu 9216;
unit 0 {
family inet {
address 10.100.0.0/31;
}
}
}
xe-0/0/2 {
mtu 9216;
unit 0 {
family inet {
address 10.100.0.2/31;
}
}
}
}
# ebpg_underlay.router-1.conf
protocols {
bgp {
group ebgp-underlay {
type external;
family inet {
unicast;
}
multipath {
multiple-as;
}
export pl-local_loopback;
local-as 4200000101;
neighbor 10.100.0.1 {
description router-2;
peer-as 4200000102;
}
neighbor 10.100.0.3 {
description router-3;
peer-as 4200000103;
}
}
}
}
policy-options {
policy-statement pl-local_loopback {
term 1 {
from {
protocol direct;
interface lo0.0;
}
then accept;
}
}
policy-statement ECMP {
then {
load-balance per-packet;
}
}
}
routing-options {
forwarding-table {
export ECMP;
}
}
The Autonomous System Numbers (ASNs) are generated incrementally starting from a default value 4200000100
(32-bits format).
You can change the seed value by modifying the variable asn_start
.
Example:
# inventory/group_vars/all.yml
asn_start: 65001
Each link will also be configured with a different IP subnet. By default the first subnet employed is 10.100.0.0/31
.
You can use a different subnet by modifying the variable ip_subnet_start
. Example:
# inventory/group_vars/all.yml
ip_subnet_start: "20.20.0.0/24"
The network mask determines the step when selecting the next subnet. In the above example, the first link will be configured with the subnet 20.20.0.0/24, the second link with 20.20.1.0/24 and so on.