{"id":1106,"date":"2023-02-23T15:33:05","date_gmt":"2023-02-23T14:33:05","guid":{"rendered":"http:\/\/192.168.1.213:8088\/?p=1106"},"modified":"2023-10-13T05:40:11","modified_gmt":"2023-10-13T04:40:11","slug":"cisco-dna-center-ztp-zero-touch-provisioning-with-ansible-intent-based","status":"publish","type":"post","link":"http:\/\/192.168.1.213:8088\/cisco-dna-center-ztp-zero-touch-provisioning-with-ansible-intent-based\/","title":{"rendered":"Cisco DNA Center ZTP (Zero-touch-provisioning) with Ansible intent-based \ud83e\udd73"},"content":{"rendered":"\t\t
One use case that I have been working on for several customers is the ZTP (Zero-Touch-Provisioning) via PNP (Plug and Play) on Catalyst devices. Such a simple use case can be complex depending on the configuration that you want to push.\u00a0 I had customers who wanted to push the entire config (with BGP, MPLS, IPsec tunnels, etc.) in one shot or just a simple config (with a management IP, User).\u00a0<\/p>
Some of my customers implemented this via API calls and some via Ansible modules. A couple months ago Cisco developed a new, more intent-based Ansible module to simplify the provisioning process, which I will cover in this article in more detail.\u00a0<\/p>
If you want to learn more about the ZTP (PnP) process itself, I can highly recommend<\/strong> starting to read the blog series from Adam Radford<\/a> :\u00a0https:\/\/blogs.cisco.com\/developer\/cisco-dna-center-plug-and-play-pnp-part-1<\/a><\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t In my lab, I am using DNA Center with two CSR1000V routers and a GitLab server with a Docker Runner.\u00a0<\/p> For your reference, I attached the Dockerfile and the pipeline file.\u00a0<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t Cisco implemented the Ansible modules for DNA Center based on the available APIs and created a 1:1 copy of that. https:\/\/github.com\/cisco-en-programmability\/dnacenter-ansible\/tree\/main\/plugins\/modules<\/a><\/p> For some customers, this is really overwhelming and if you don’t understand fully which API is used for which action, it won’t be easy to implement the Ansible modules.\u00a0<\/p> In the following example, I created the entire workflow to onboard a device with all necessary actions involved:<\/p> \u00a0<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t Let’s check the pipeline status:\u00a0<\/strong><\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t Let’s validate the status in DNA Center:<\/strong><\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t Over 120 lines of code and 9 different DNA Center Ansible modules to use Plug and Play and onboard a device?!<\/p> “That’s too much and does not simplify the process using Ansible” The Cisco engineering team developed a module that is more intent-based. <\/p> Thanks to the authors Madhan Sankaranarayanan<\/a> & Rishita Chowdhary<\/a>.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t The following two Ansible modules are doing the job (cisco.dnac.template_intent<\/a> & cisco.dnac.pnp_intent<\/a>) in a simpler and an intent-based approach, as the modules are doing a lot of heavy API jobs in the backend \ud83d\ude00.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t Let’s validate the status in DNA Center:<\/strong><\/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
Dockerfile<\/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
.gitlab-ci.yml<\/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
Non intent-based Ansible modules<\/h5>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
All available modules are listed here:<\/p>PNP_NOT_INTENT-BASED.yml<\/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
This is the feedback I got from one of my customers.\u00a0<\/p>New intent-based Ansible modules<\/h5>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
PNP_INTENT-BASED.yml<\/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