How to do it...

  1. Update the group_vars/core.yml file with the following data to define core links between core switches and WAN routers:
core_l3_links:
core01:
- name: Ethernet1/0
description: wan01_Gi2
ipv4: 10.3.1.0/30
ospf: yes
ospf_metric: 100
peer: wan01
core02:
- name: Ethernet1/0
description: wan02_Gi2
ipv4: 10.3.1.4/30
ospf: yes
ospf_metric: 200
peer: wan02
  1. Update the pb_build_network.yml playbook with the following tasks to set up OSPF:
- name: "PLAY 2: Configure Core Switches"
hosts: core
tags: l3_core
tasks:
< -------- Snippet -------- >
- name: "P2T9: Configure OSPF On Interfaces"
ios_config:
parents: interface {{ item.name }}
lines:
- ip ospf {{ ospf_process }} area {{ ospf_area }}
- ip ospf network point-to-point
- ip ospf cost {{item.ospf_metric | default(ospf_metric)}}
loop: "{{ (svi_interfaces + core_l3_links[inventory_hostname]) | selectattr('ospf') | list }}"
- name: "P2T10: Configure OSPF Passive Interfaces"
ios_config:
parents: router ospf {{ ospf_process }}
lines: passive-interface {{item.name}}
loop: "{{ (svi_interfaces + core_l3_links[inventory_hostname]) | selectattr('ospf','equalto','passive') | list }}"