{"id":1475,"date":"2023-03-22T16:22:53","date_gmt":"2023-03-22T15:22:53","guid":{"rendered":"http:\/\/192.168.1.213:8088\/?p=1475"},"modified":"2023-10-13T05:40:10","modified_gmt":"2023-10-13T04:40:10","slug":"cisco-ndfc-ztp-zero-touch-provisioning-with-ansible-for-bgp-evpn-fabrics","status":"publish","type":"post","link":"http:\/\/192.168.1.213:8088\/cisco-ndfc-ztp-zero-touch-provisioning-with-ansible-for-bgp-evpn-fabrics\/","title":{"rendered":"Cisco NDFC ZTP (Zero-Touch-Provisioning) with Ansible for BGP EVPN fabrics"},"content":{"rendered":"\t\t
If you want to build BGP EVPN based Datacenter fabrics, Cisco’s answer is NDFC (Nexus Dashboard Fabric Controller)<\/a>.<\/p> Cisco Nexus Dashboard Fabric Controller (NDFC) is a network automation and management solution offered by Cisco. NDFC provides a single dashboard for managing and automating network operations across multi-cloud, on-premises, and edge environments.<\/p> In this article, I am describing how to build a BGP EPVN fabric and provision Spine and Leaf switches using POAP (PowerOn auto-provisioning)<\/a> with Ansible modules<\/a>.<\/p> POAP is being used to configure and update devices once they are booted and come up without any configuration. It is a very convenient way to configure the fabric, add the devices and then just turn on the devices in the data center and everything gets configured automatically!<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t My entire environment is fully virtualized. I am running a virtual Nexus Dashboard<\/a> and CML (Cisco Modelling Labs)<\/a> to simulate my Nexus devices.<\/p> If you want to replicate this setup as well, make sure to allocate enough resources for the Nexus Dashboard (16x vCPUs and 64GB RAM<\/strong>). As always I run the code in a GitLab CI\/CD pipeline and it is executed within a Docker container. The Docker container is stored in my own GitLab Docker registry. If you don’t know how to set up the GitLab server with a Docker registry, check out my previous article:<\/p> For this use case I am using a very basic Docker container with:<\/p> As the base is set now, it is time to build the data model. If you create a BGP EVPN fabric there are a lot of variables you need to deal with. That’s why I created the following data model which I will load later into my Ansible playbook:<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t To create the fabric I am using the Easy_Fabric template and left pretty much everything as a default value. The only values I changed are:<\/p> It also makes sense to create a separate file for the switch inventory details. The most important information is the serial number<\/strong> of the device as we need to map the correct role to each switch (Spine, Leaf, Border-Leaf etc.).\u00a0<\/p> Make sure to have that information handy before starting with POAP!<\/strong><\/p> For the Ansible playbook, it just needs four different modules:<\/p> \u00a0<\/p> Make sure that the following parameters are set in the ansible.cfg:\u00a0<\/p> The pipeline itself is very simple and consists of three stages:<\/p> Let’s run the pipeline and validate the process:<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t At first, the Ansible play will create the fabric:<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t After some time once the switches booted up, it will start with the POAP process and sends out DHCP request.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t As the fabric has the DHCP server option enabled and a range is assigned, the switches will receive an IP address.\u00a0<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t Once the switches become available, which will be after some minutes, they will be added to the fabric.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t The switches will download the python script from the NDFC server, configure basic connectivity like IP address and credentials and the switch will reboot.\u00a0<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t The Ansible tasks wait for the switches to come back online to configure the “role” (Spine\/Leaf) related configurations. This process can take up to 10 – 15 minutes.\u00a0<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t Once the switches come back online, the config state is unknown. NDFC will sync this after a while.\u00a0<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t Once the config state is synced, NDFC will push the configuration to the switches.\u00a0<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t You can see the process more in detail if you go back to the pipeline status. The Ansible module will:\u00a0<\/p> After a while, you should see that the entire pipeline was executed successfully. \ud83d\ude03<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\tLab setup<\/h5>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
<\/strong>https:\/\/www.cisco.com\/c\/en\/us\/td\/docs\/dcn\/nd\/2x\/deployment\/cisco-nexus-dashboard-deployment-guide-221\/nd-deploy-esx-22x.html<\/a><\/p>Docker container<\/h6>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
Cisco is a master in renaming products \ud83d\ude09<\/li><\/ul>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\n\t\t\t\t
\n\t\t\t\t\t
Building the container in a pipeline<\/h5>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t
Building the data model<\/h5>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
fabric_settings.yaml:<\/h6>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t
fabric_inventory.yaml:<\/h6>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t
Building the playbok<\/h5>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
Both defined yaml files needs to be loaded for the fabric and inventory data<\/li>
This module is used to create the fabric using the fabric_settings by converting it into JSON payload<\/li>
<\/strong>Once the fabric is created it will take some time in order to get the IP address from the DHCP server (in my case the NDFC controller) and the switches are visible in the POAP inventory.\u00a0<\/li>
The inventory module is used to add and provision the devices into the created fabric\u00a0<\/li><\/ul>\n\t\t\t\t
\n\t\t\t\t\t
Building the pipeline<\/h5>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
<\/strong>The Docker container will be created and uploaded to the GitLab Docker registry\u00a0<\/li>
<\/strong>Ansible playbook syntax will be checked against linting rules<\/li>
<\/strong>Ansible playbook will be executed<\/li><\/ul>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\n\t\t\t\t
\n\t\t\t\t\t
Run the pipeline<\/h5>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
References<\/h5>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t