Deploy
Ansible Role

Step 1 - Open The Main Task File for the Role

For the overlay role tasks, ensure you are in your VSCode Terminal and open the main.yml file found in roles/manage_overlay/tasks/ using the VSCode code keyword as before.


code-server -r ~/workspace/ndfclab/ansible/roles/deploy/tasks/main.yml


Step 2 - Add Tasks To Deploy Fabric

It is finally time to add tasks to your deploy role. The tasks will be used to save the configuration and deploy the pending fabric configuration to your switches.

For these tasks, we leverage the generic fallback module cisco.dcnm.dcnm_rest to interact with the NDFC REST API. The first task is the API to save the configuration of the fabric, while the second is to trigger the deployment of the fabric configuration.

For these tasks, you may be introduced to the block keyword. The block keyword is used to group tasks together. These tasks are grouped and have a common tag of deploy associated with them.



- ansible.builtin.debug:
    msg:
      - "----------------------------------------------------------------"
      - "+             Calling Role - [deploy]                     +"
      - "----------------------------------------------------------------"

- block:
    - name: Config-Save for Fabric {{ fabric_settings.FABRIC_NAME }}
      cisco.dcnm.dcnm_rest:
        method: POST
        path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ fabric_settings.FABRIC_NAME }}/config-save"

    - name: Deploy for Fabric {{ fabric_settings.FABRIC_NAME }}
      cisco.dcnm.dcnm_rest:
        path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ fabric_settings.FABRIC_NAME }}/config-deploy?forceShowRun=false"
        method: POST
  tags:
    - deploy

After successfully populating the file above, save the file using Ctrl+s on the Windows keyboard or by clicking File then Save.

Warning

Be sure to save your file! Not saving will result in your code not executing.

Step 3 - Open the Top Level build_fabric.yml Ansible Playbook

Navigate back to your build_fabric.yml file by using the VSCode code command:


code-server -r ~/workspace/ndfclab/ansible/build_fabric.yml


Step 4 - Add a line to call the deploy role under the roles: section of the playbook

Your build_fabric.yml file should already be populated from the previous section. With the file open, you only need to add the highlighted line, which should be line number 13 in your file. You can do this by highlighting the text in the lab guide and copying then pasting in your file or typing the line in your file. After one of those actions, press the return key such that there is a new line after where you entered - manage_overlay. Note: Make sure you identation is correct and aligns with the previous item which should be - manage_interfaces.


---
# This is the top level build playbook that runs the various
# Ansible roles that will be used to build out the fabric

- name: Build VXLAN EVPN Fabric on NDFC
  hosts: ndfc
  gather_facts: false

  roles:
    - create_fabric
    - add_inventory
    - setup_vpc
    - manage_interfaces
    - manage_overlay 
    - deploy # Add This Line Under The manage_overlay role from the previous section

After successfully populating the file above, save the file using Ctrl+s on the Windows keyboard or by clicking File then Save.

Warning

Be sure to save your file! Not saving will result in your code not executing.


Step 5 - Execute Ansible Playbook

Make sure you are in the root Ansible directory


cd ~/workspace/ndfclab/ansible

From the root ansible project directory execute the following command.


ansible-playbook -i hosts.stage.yml build_fabric.yml --tags deploy

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

  [WARNING]: file /home/cisco/Documents/ndfclab/ansible/roles/create_fabric/tasks/manage_external_fabric.yml is empty and had no tasks to include
  [WARNING]: file /home/cisco/Documents/ndfclab/ansible/roles/add_inventory/tasks/add_fabric_devices_poap.yml is empty and had no tasks to include
  [WARNING]: file /home/cisco/Documents/ndfclab/ansible/roles/add_inventory/tasks/add_fabric_external_devices.yml is empty and had no tasks to include
  [WARNING]: file /home/cisco/Documents/ndfclab/ansible/roles/manage_interfaces/tasks/loopback_interfaces.yml is empty and had no tasks to include
  [WARNING]: file /home/cisco/Documents/ndfclab/ansible/roles/manage_overlay/tasks/resync_fabric.yml is empty and had no tasks to include
  [WARNING]: file /home/cisco/Documents/ndfclab/ansible/roles/manage_overlay/tasks/add_vrf_lite_vrfs.yml is empty and had no tasks to include
  [WARNING]: file /home/cisco/Documents/ndfclab/ansible/roles/manage_overlay/tasks/add_policies.yml is empty and had no tasks to include

  PLAY [Build VXLAN EVPN Fabric on NDFC] ********************************************************************************************************************************************************************

  TASK [deploy : Config-Save for Fabric fabric-stage] *******************************************************************************************************************************************************
  ok: [10.15.0.98]

  TASK [deploy : Deploy for Fabric fabric-stage] ************************************************************************************************************************************************************
  ok: [10.15.0.98]

  PLAY RECAP ************************************************************************************************************************************************************************************************
  10.15.0.98                 : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0 

Step 6 - Return to NDFC & Verify Deployment

Return to your NDFC browser window and verify the deployment of the fabric configuration.

  1. Click the Switches tab in the top navigation bar

  2. Verify you see you switches in the Config Status as In-Sync. If not, please click the refresh button to the right of the Actions button



  3. Click Interfaces
  4. There will be many interfaces, but you should now be able to confirm interface configurations to your switches



  5. Click the VRFs tab in the top navigation bar
  6. Verify you see the VRF AnsibleVRF now with a Deployed status
  7. Double-click AnsibleVRF to review the VRF details



  8. Click VRF Attachments
  9. Confirm AnsibleVRF is now Deployed and Attached to your switches



  10. Click Networks
  11. Confirm AnsibleNet1 and AnsibleNet2 is associated to AnsibleVRF and Deployed to your switches
  12. Click the close button



  13. Click the Networks tab in the top navigation bar
  14. Verify you see the Networks AnsibleNet1 and AnsibleNet2 now Deployed.
  15. Double-click AnsibleNet1 to review the Network details



  16. Click Network Attachments
  17. Confirm AnsibleNet1 is now Deployed and Attached to your switches



  18. Click VRFs
  19. Confirm AnsibleVRF is associated to AnsibleNet1 and Deployed to your switches
  20. Click the close button



  21. Click the Overview tab in the top navigation bar
  22. Verify your overall fabric deployment status

Congratulations! You have automated the build of a functional VXLAN EVPN Fabric in a staging environment

Next you will start to extend the existing roles and learn more about the Ansible NDFC collection.