How to do it...

  1. Update the group_vars/core.yml file with following data to define the SVI interfaces:
$ cat group_vars/core.yml
<-- Output Trimmed for brevity ------>
svi_interfaces:
- name: Vlan10
ipv4: 10.1.10.0/24
vrrp: yes
ospf: passive
- name: Vlan20
ipv4: 10.1.20.0/24
vrrp: yes
ospf: passive
- name: Vlan100
ipv4: 10.1.100.0/24
vrrp: yes
ospf: passive
  1. Create core01.yml and core02.yml files under the host_vars folder and add the following content:
$ cat host_vars/core01.yml
hst_svi_id: 1
hst_vrrp_priority: 100
$ cat host_vars/core02.yml
hst_svi_id: 2
hst_vrrp_priority: 50
  1. Update the pb_build_network.yml playbook with the following tasks to create and enable the L3 SVI interfaces:
- name: "PLAY 2: Configure Core Switches"
hosts: core
tags: l3_core
tasks:
<-- Output Trimmed for brevity ------>
- name: "Create L3 VLAN Interfaces"
ios_l3_interface:
name: "{{item.name }}"
ipv4: "{{item.ipv4 | ipv4(hst_svi_id)}}"
loop: "{{svi_interfaces}}"
tags: l3_svi
- name: "Enable the VLAN Interfaces"
ios_interface:
name: "{{ item.name }}"
state: up
loop: "{{ svi_interfaces }}"
  1. Update the playbook with the following task to set up VRRP configuration on the SVI interfaces:
    - name: "Create VRRP Configs"
ios_config:
parents: interface {{ item.name }}
lines:
- vrrp {{item.name.split('Vlan')[1]}} priority {{ hst_vrrp_priority }}
- vrrp {{item.name.split('Vlan')[1]}} ip {{item.ipv4 | ipv4(254)|ipaddr('address')}}
loop: "{{svi_interfaces | selectattr('vrrp','equalto',true) | list }}"