vPC
VXLAN as Code

Step 1 - Create

With the devices added to the fabric, you can now create the vPC peering between staging-leaf1 and staging-leaf2. You will create a new file named vpc.nac.yml. This file will contain all of the necessary vPC configurations to establish the vPC peering for the leaf switches. The vPC settings such as peer-link Vlan and peer-keepalive VRF to use are defined under the vpc section of the global key. The actual vpc_peers are defined under the vpc_peers of the topology section. Again, this vPC peering configuration will be used by the Ansible playbook to create the vPC peering between the leaf switches.


touch ~/workspace/ndlab/nac/host_vars/fabric-stage/vpc.nac.yml
code-server -r ~/workspace/ndlab/nac/host_vars/fabric-stage/vpc.nac.yml


      
---

vxlan:
  global:
    vpc:
      peer_link_vlan: 3600
      peer_keep_alive: management
      auto_recovery_time: 240
      delay_restore_time: 150
      peer_link_port_channel_id: 500
      advertise_pip: true
      domain_id_range: 1-100
  topology:
    vpc_peers:
      - peer1: staging-leaf1
        peer2: staging-leaf2
        fabric_peering: true






Step 2 - Execute Ansible Playbook

Make sure you are in your root Ansible directory


cd ~/workspace/ndlab/nac

From the root Ansible project directory execute the following command:


ansible-playbook -i hosts.stage.yml vxlan.yml --tags cr_manage_vpc_peers

Upon a successful run of the playbook your output should look as follows:

  <... SNIP ...>

  PLAY RECAP *******************************************************************************************************************************************************************
  fabric-stage               : ok=230  changed=32   unreachable=0    failed=0    skipped=761  rescued=0    ignored=0


  PLAYBOOK RECAP ***************************************************************************************************************************************************************
  Playbook run took 0 days, 0 hours, 1 minutes, 16 seconds


  TASKS RECAP ******************************************************************************************************************************************************************
  Wednesday 01 October 2025  16:08:33 +0000 (0:00:00.382)       0:01:16.706 *****
  ===============================================================================
  cisco.nac_dc_vxlan.create : Manage vPC Peering in Nexus Dashboard ----------------------------------------------------------------------------------------------------- 1.91s
  cisco.nac_dc_vxlan.common : Get POAP Data From POAP Enabled Devices --------------------------------------------------------------------------------------------------- 1.88s
  cisco.nac_dc_vxlan.connectivity_check : Get Cisco Nexus Dashboard Fabric Controller Version --------------------------------------------------------------------------- 1.55s
  cisco.nac_dc_vxlan.common : Build Fabric Creation Parameters From Template -------------------------------------------------------------------------------------------- 0.84s
  cisco.nac_dc_vxlan.connectivity_check : Verify Authorization to Nexus Dashboard --------------------------------------------------------------------------------------- 0.79s
  cisco.nac_dc_vxlan.validate : Copy Service Model Data to Host --------------------------------------------------------------------------------------------------------- 0.74s
  cisco.nac_dc_vxlan.common : Build Fabric Switch Inventory List From Template ------------------------------------------------------------------------------------------ 0.68s
  cisco.nac_dc_vxlan.common : Retrieve NDFC Device Username and Password from Group Vars and update inv_config ---------------------------------------------------------- 0.67s
  cisco.nac_dc_vxlan.common : Build VRFs Attach List From Template ------------------------------------------------------------------------------------------------------ 0.65s
  cisco.nac_dc_vxlan.common : Retrieve NDFC Device Username and Password from Group Vars and update inv_config ---------------------------------------------------------- 0.65s
  cisco.nac_dc_vxlan.common : Build Loopback Interfaces List From Template ---------------------------------------------------------------------------------------------- 0.65s
  cisco.nac_dc_vxlan.common : Build Interface --------------------------------------------------------------------------------------------------------------------------- 0.64s
  cisco.nac_dc_vxlan.common : Build Networks Attach List From Template -------------------------------------------------------------------------------------------------- 0.63s
  cisco.nac_dc_vxlan.common : Build Interface --------------------------------------------------------------------------------------------------------------------------- 0.63s
  cisco.nac_dc_vxlan.common : Build Fabric Switch Inventory List From Template ------------------------------------------------------------------------------------------ 0.62s
  cisco.nac_dc_vxlan.common : Build Links for vPC Peering --------------------------------------------------------------------------------------------------------------- 0.62s
  cisco.nac_dc_vxlan.common : Build Interface --------------------------------------------------------------------------------------------------------------------------- 0.62s
  cisco.nac_dc_vxlan.common : Build Policy List From Template ----------------------------------------------------------------------------------------------------------- 0.61s
  cisco.nac_dc_vxlan.common : Build Fabric Links ------------------------------------------------------------------------------------------------------------------------ 0.60s
  cisco.nac_dc_vxlan.common : Build Interface --------------------------------------------------------------------------------------------------------------------------- 0.59s

  ROLES RECAP ******************************************************************************************************************************************************************
  Wednesday 01 October 2025  16:08:33 +0000 (0:00:00.384)       0:01:16.707 *****
  ===============================================================================
  common ----------------------------------------------------------------- 59.58s
  validate ---------------------------------------------------------------- 5.75s
  create ------------------------------------------------------------------ 4.26s
  connectivity_check ------------------------------------------------------ 3.85s
  common_global ----------------------------------------------------------- 0.05s
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  total ------------------------------------------------------------------ 73.50s
  

Step 3 - Return to NDFC & Verify vPC Peering is Pending

The vPC peering should now be pre-staged between leaf1 and leaf2. Return to NDFC and verify.

In NDFC, you should still be on the Switches tab, if not:

  1. Click Switches in the top navigation bar




Step 4 - Return to VSCode & Close All Open Tabs

On the keyword press Ctrl + K + W. This should close all open tabs to clear your workspace for the next section.


Continue to the next section to define the interfaces for the leaf switches in your fabric using VXLAN as Code.