How it works...

We use the same interface data that was declared in the p2p_ip data structure in the all.yml file, in order to provision the OSPF configuration on the network devices in our sample network. We use a new Jinja2 template defined in the ospf.j2 file under the templates/junos directory to capture the OSPF configuration parameters (OSPF cost, OSPF interface type, and so on) that need to be implemented on the Juniper devices.

Under the tasks/Juniper_build_config.yml file, we add a new task that uses the ospf.j2 Jinja2 template to render the Jinja2 template, and output the OSPF configuration section for each device outlined in our Ansible inventory.

The following snippet outlines the OSPF configuration generated for the mxpe01 device after running the playbook with the new task:

$ cat configs/mxpe01.cfg

<-- Output Trimmed for brevity ------>

protocols {
ospf {
area 0 {
interface ge-0/0/0 {
interface-type p2p;
metric 100;
}
interface ge-0/0/1 {
interface-type p2p;
metric 100;
}
interface lo0.0 {
passive;
}
}
}
}