Add Overlay
CI/CD

Add New Networks Using CI/CD Pipeline

In this final section for Ansible you are going to use your newly built pipeline to add two new Networks. This demonstrates how easy it is to make changes to your Network stored in GitLab as code and validate those changes against your staging fabric before pushing the changes to your production fabric.

Step 1 - Add Two Networks Your Overlay Variables File

Since you have a central variable file for all of your VRFs and Networks, all you need to do is modify the file to add the new data. Normally you would open this file and add the new Networks but to make it easy we are going to replace the file you created ealier with the new Networks added in.


touch ~/workspace/ndfclab/ansible/group_vars/all/overlay.yml
cat << EOF > ~/workspace/ndfclab/ansible/group_vars/all/overlay.yml
---
vrfs:
  - vrf_name: &refvrf_ansible AnsibleVRF
    vrf_id: 150001
    vlan_id: 2000
    attach: []
    attach_group: all_leaf
networks:
  - net_name: AnsibleNet1
    vrf_name: *refvrf_ansible
    net_id: 130001
    vlan_id: 2301
    vlan_name: AnsibleNet1_vlan2301
    gw_ip_subnet: "192.168.11.1/24"
    attach: []
    attach_group: esxi
  - net_name: AnsibleNet2
    vrf_name: *refvrf_ansible
    net_id: 130002
    vlan_id: 2302
    vlan_name: AnsibleNet2_vlan2302
    gw_ip_subnet: "192.168.12.1/24"
    attach_group: esxi
# -------------------------------------
# New Networks Added Below
# -------------------------------------
  - net_name: GitLabNet1
    vrf_name: *refvrf_ansible
    net_id: 130003
    vlan_id: 2303
    vlan_name: GitLabNet1_vlan2303
    gw_ip_subnet: "192.168.13.1/24"
    attach: []
    attach_group: esxi
  - net_name: GitLabNet2
    vrf_name: *refvrf_ansible
    net_id: 130004
    vlan_id: 2304
    vlan_name: GitLabNet2_vlan2304
    gw_ip_subnet: "192.168.14.1/24"
    attach_group: esxi
EOF


Step 2 - Add the Modified overlay.yml for Committing to the GitLab Repo


git add .


Step 3 - Double Check File Staged For Commit


git status .


The following file is staged for commit. Make sure your list matches the output below!

    On branch stage
    Your branch is up to date with 'origin/stage'.
    
    Changes to be committed:
      (use "git restore --staged ..." to unstage)
            modified:   group_vars/all/overlay.yml

Step 4 - Commit Files to the GitLab Repo


git commit -m "Add new Networks Overlay"


Step 5 - Push Files to the GitLab Repo stage Branch


git push -u origin stage


Step 6 - Check to make sure the Lint Stage was run.

As soon as the code was committed to the stage branch, Ansible Lint validation was triggered. Return to your GitLab and navigate to Pipelines:

  1. Click Build on the side menu
  2. Then click Pipelines
  3. Click your new pipeline

  4. Only the lint stage is triggered when committing the code to the stage branch, circle check icon indicates pipeline succeeds



    This shows the ansible_lint job ran successfully for the initial setup commit. If you want to see detailed logs of the job run you can click the ansible lint job.





Step 7 - Create a Merge Request (Also known as a Pull Request)

Now you need to create a merge request to verify/test the new Networks configuration against the NDFC staging environment fabric.

  1. Click Merge requests on the side menu
  2. Then click New merge request



  3. Select stage as Source branch
  4. Select main as Target branch
  5. Then click Compare branches and continue



  6. Leave all of the fields with the default settings, then click Create merge request



  7. Click the circle icon in screen below to navigate to pipeline page



Step 8 - Wait Until Pipeline Completes

Wait until your pipeline completes against staging. In the mean time, feel free to checkout what is going on in your NDFC instance by following the next step.




Step 9 - Login to Nexus Dashboard and Verify the new Networks on the Staging Fabric

In your browser, navigate back to your NDFC instance.

  1. Close your prod fabric as that should be the last location you were at in NDFC.



  2. Then double-click on your fabric-stage



  3. Click Networks and review add L2VNI overlay networks named after GitLab
  4. Double-click GitLabNet1
  5. Note

    You may need to wait for the pipeline for some of the Networks to show up in the NDFC GUI.




  6. Click Network Attachments and review the networks are attached to your leaf switches
  7. Then close your new network
  8. Note

    You may need to wait for the pipeline for some of the Network Attachments to show up in the NDFC GUI.




Step 10 - Navigate to the Merge Request

When your pipeline is done, open the merge request page:

  1. Click !# in the text Related merge request !# to merge stage



Step 11 - Merge the Request

To open the merge request page:

  1. Click Merge



  2. Once your code is merged, a new CD pipeline is triggered. Click the pipeline number



Step 12 - Wait Until the Pipeline is Finished

Wait until the pipeline is finished:



    This step will deploy the new VRF and new Networks to the Production Fabric

    You have now modifed your Fabric by updating your source code and then using the CI and CD pipelines to deploy the changes!




Step 13 - Verify the new Networks on the Production Fabric

In your browser, return to NDFC and navigate to your prod-fabric:

  1. Close your stage-fabric



  2. Navigate to prod-fabric



  3. Verify prod-fabric Overview Dashboard displays
  4. Check fabric-prod

    This time open the fabric page and check fabric-prod, NOT fabric-stage. Remember the CD pipeline pushes changes to the production fabric and you may need to wait to see the new Networks as the pipeline runs.




  5. Navigate to Networks and verify new Networks:
  6. Double-click on GitLabNet1



  7. Navigate to Network Attachments and verify new Network Attachments:



Congratulations on completing the lab!


You successfully exported NDFC's REST API and experimented with them in Postman.

You took what you learned with NDFC's REST API and applied it to develop a Pythonic command line program to get and create network elements, VRFs and Networks in NDFC.

You have successfully developed a complete, end-to-end Ansible playbook using Infrastructure-as-Code (IaC) for deploying staging and production NDFC fabrics. This reusable playbook leverages YAML data files for configuration, enabling efficient and consistent deployments.

Thank you for attending Cisco Live 2025!!

  • Introduction
  • Development Environment
  • NDFC
  • ND/NDFC REST API
  • NDFC Postman
  • NDFC Python
  • NDFC Ansible
  • NDFC CI/CD