{"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
\n\t\t\t\t\t\t
\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t
\n\t\t\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t

\n\t\t\t\tTable of Contents\t\t\t<\/h4>\n\t\t\t\t\t\t\t
<\/i><\/div>\n\t\t\t\t
<\/i><\/div>\n\t\t\t\t\t<\/div>\n\t\t
\n\t\t\t
\n\t\t\t\t<\/i>\t\t\t<\/div>\n\t\t<\/div>\n\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
Introduction<\/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\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> \"\ud83d\udc4d\" :\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

\n\t\t\t\t
\n\t\t\t
Lab setup<\/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\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

\n\t\t\t\t
\n\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
\n\t\t\t
\n\t\t\t\t\n\t\t\t\t\tFROM ubuntu:22.04\r\n\r\nRUN apt-get update && \\\r\n  apt-get install -y gcc python3.11 git && \\\r\n  apt-get install -y python3-pip ssh && \\\r\n  pip3 install --upgrade pip && \\\r\n  pip3 install ansible && \\\r\n  pip3 install dnacentersdk && \\\r\n  pip3 install jmespath && \\\r\n  pip3 install pyats[full] && \\ \r\n  pip3 install ansible-lint && \\ \r\n  ansible-galaxy collection install cisco.dnac<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-b1bf80a elementor-widget elementor-widget-heading\" data-id=\"b1bf80a\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h6 class=\"elementor-heading-title elementor-size-default\">.gitlab-ci.yml<\/h6>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-0e39454 elementor-widget elementor-widget-code-highlight\" data-id=\"0e39454\" data-element_type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<div class=\"prismjs-default copy-to-clipboard \">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-bash line-numbers\">\n\t\t\t\t<code readonly=\"true\" class=\"language-bash\">\n\t\t\t\t\t<xmp>variables:\r\n  IMAGE_NAME_DNAC: $CI_REGISTRY_IMAGE\/dnac-pnp\r\n  IMAGE_TAG_DNAC: \"1.0\"\r\nstages:\r\n  - build\r\n  - deploy\r\n\r\nbuild_image:\r\n  stage: build\r\n  tags:\r\n    - shell-runner\r\n  script:\r\n    - docker build -t $IMAGE_NAME_DNAC:$IMAGE_TAG_DNAC .\r\n\r\npush_image:\r\n  stage: build\r\n  needs:\r\n    - build_image\r\n  tags:\r\n    - shell-runner\r\n  before_script:\r\n    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY\r\n  script:\r\n    - docker push $IMAGE_NAME_DNAC:$IMAGE_TAG_DNAC\r\n\r\ndnac_ansible_job:\r\n  stage: deploy\r\n  needs:\r\n    - push_image\r\n  tags:\r\n    - docker-runner\r\n  image: $IMAGE_NAME_DNAC:$IMAGE_TAG_DNAC\r\n  script:\r\n    - ansible-playbook -i ansible\/hosts ansible\/PNP_NOT_INTENT-BASED.yml \r\n    - ansible-playbook -i ansible\/hosts ansible\/PNP_INTENT-BASED.yml <\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-76d31b8 elementor-widget elementor-widget-heading\" data-id=\"76d31b8\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h5 class=\"elementor-heading-title elementor-size-default\">Non intent-based Ansible modules<\/h5>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-ad10cd1 elementor-widget elementor-widget-text-editor\" data-id=\"ad10cd1\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>Cisco implemented the Ansible modules for DNA Center based on the available APIs and created a 1:1 copy of that. <br \/>All available modules are listed here:<\/p><p><a href=\"https:\/\/github.com\/cisco-en-programmability\/dnacenter-ansible\/tree\/main\/plugins\/modules\" target=\"_blank\" rel=\"noopener\">https:\/\/github.com\/cisco-en-programmability\/dnacenter-ansible\/tree\/main\/plugins\/modules<\/a><\/p><p>For some customers, this is really overwhelming and if you don&#8217;t understand fully which API is used for which action, it won&#8217;t be easy to implement the Ansible modules.\u00a0<\/p><p>In the following example, I created the entire workflow to onboard a device with all necessary actions involved:<\/p><ul><li>Get the project ID of &#8220;Onboarding Configuration&#8221;<\/li><li>Create a template under the Onboarding configuration project<\/li><li>Approve the version of the template<\/li><li>Create a site\u00a0<\/li><li>Get the site ID<\/li><li>Get the Image ID (optional)<\/li><li>Add the device to the PNP inventory<\/li><li>Claim the device<\/li><\/ul><p>\u00a0<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-e7cbcfb elementor-alert-info elementor-widget elementor-widget-alert\" data-id=\"e7cbcfb\" data-element_type=\"widget\" data-widget_type=\"alert.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<div class=\"elementor-alert\" role=\"alert\">\n\n\t\t\t\t\t\t<span class=\"elementor-alert-title\">Information<\/span>\n\t\t\t\n\t\t\t\t\t\t<span class=\"elementor-alert-description\">For simplicity reasons, I included all used variables in the playbook itself. Usually, you should structure your data outside of the playbook to make it reusable.<\/span>\n\t\t\t\n\t\t\t\n\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-15b9035 elementor-widget elementor-widget-heading\" data-id=\"15b9035\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h6 class=\"elementor-heading-title elementor-size-default\">PNP_NOT_INTENT-BASED.yml<\/h6>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-caf133c elementor-widget elementor-widget-code-highlight\" data-id=\"caf133c\" data-element_type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<div class=\"prismjs-default copy-to-clipboard \">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-bash line-numbers\">\n\t\t\t\t<code readonly=\"true\" class=\"language-bash\">\n\t\t\t\t\t<xmp>- hosts: dnac_servers\r\n  gather_facts: no\r\n  connection: local\r\n  tasks:\r\n    - name: Get timestamp from the system\r\n      shell: \"date +%Y-%m-%d%H-%M-%S\"\r\n      register: tstamp\r\n#\r\n# Get project details\r\n#\r\n    - name: Get list of Projects and getting the ID of the onboarding project\r\n      cisco.dnac.configuration_template_project_info:\r\n        name: \"Onboarding Configuration\"\r\n      register: project_result\r\n\r\n    - name: Set Project variable\r\n      ansible.builtin.set_fact:\r\n        project_id: \"{{ project_result.dnac_response[0].id }}\" \r\n    - debug: var=project_id\r\n#\r\n# Create template \/ Template Info\r\n#\r\n    - name: Create an configuration_template_project\r\n      cisco.dnac.configuration_template_create:\r\n        name: \"CSR1000V_{{ tstamp.stdout }}\"\r\n        templateContent: \"hostname TEST\"\r\n        language: \"VELOCITY\"\r\n        projectName: \"Onboarding Configuration\"\r\n        deviceTypes:\r\n         - productFamily: \"Switches and Hubs\"\r\n        projectId: \"{{ project_id }}\"\r\n        softwareType: \"IOS-XE\"\r\n        softwareVariant: \"XE\"\r\n      register: configuration_template_project_result\r\n\r\n    - name: Set Task ID\r\n      ansible.builtin.set_fact:\r\n        task_id: \"{{ configuration_template_project_result.dnac_response.response.taskId }}\"\r\n    - debug: var=task_id\r\n\r\n    - name: Get Task by id\r\n      cisco.dnac.task_info:\r\n        taskId: \"{{ task_id }}\"\r\n      register: result_task_id\r\n\r\n    - name: Set Template ID\r\n      ansible.builtin.set_fact:\r\n        template_id: \"{{ result_task_id.dnac_response.response.data }}\"\r\n    - debug: var=template_id\r\n\r\n    - name: Create Versioning\r\n      cisco.dnac.configuration_template_version_create:\r\n        comments: \"COMMITED\"\r\n        templateId: \"{{ template_id }}\"\r\n      register: template_version_result\r\n#\r\n# Create Site \/ Site Info\r\n#\r\n    - name: Create Site\r\n      cisco.dnac.site_create:\r\n        site:\r\n          building:\r\n            latitude: 37.338\r\n            longitude: -121.832\r\n            name: \"beye.blog\"\r\n            parentName: \"Global\"\r\n        type: \"building\"\r\n\r\n    - name: Get Site Info \r\n      cisco.dnac.site_info:\r\n        name: \"Global\/beye.blog\"\r\n      register: site_result\r\n\r\n    - name: Set Site variable\r\n      ansible.builtin.set_fact:\r\n        site_id: \"{{ site_result.dnac_response.response[0].id }}\"\r\n    - debug: var=site_id \r\n#\r\n# Software Image Info\r\n#\r\n    - name: Get list of Images and getting the ID of the image \r\n      cisco.dnac.swim_image_details_info:\r\n        isTaggedGolden: True\r\n        imageName: \"csr1000v-universalk9.17.03.05.SPA.bin\"\r\n      register: image_result\r\n\r\n    - name: Set Images variable\r\n      ansible.builtin.set_fact:\r\n        image_id: \"{{ image_result.dnac_response.response[0].imageUuid }}\"\r\n    - debug: var=image_id\r\n#\r\n# ZTP \r\n#\r\n    - name: Adds a device to the PnP database \r\n      cisco.dnac.pnp_device:\r\n        state: present\r\n        version: 2\r\n        deviceInfo:\r\n          serialNumber: 96MZPDLDSNX\r\n          name: CSR1000V-01\r\n          state: Unclaimed\r\n          pid: CSR1000V\r\n      register: pnp_device_result\r\n\r\n    - name: Set Device variable\r\n      ansible.builtin.set_fact:\r\n        device_id: \"{{ pnp_device_result.dnac_response.id }}\"\r\n    - debug: var=device_id\r\n\r\n    - name: Claim device to a site \r\n      cisco.dnac.pnp_device_claim_to_site:\r\n        deviceId: \"{{ device_id }}\"\r\n        siteId: \"{{ site_id }}\"\r\n        type: \"Default\"\r\n        configInfo: \r\n          configId: \"{{ template_id }}\"\r\n          configParameters:\r\n          - key: \"\"\r\n            value: \"\"\r\n        imageInfo:\r\n          imageId: \"{{ image_id }}\"\r\n      register: claim_result\r\n    - debug: var=claim_result<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-f281daa elementor-widget elementor-widget-text-editor\" data-id=\"f281daa\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p><strong>Let&#8217;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<div class=\"elementor-element elementor-element-d91a9a0 elementor-widget elementor-widget-image\" data-id=\"d91a9a0\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<a href=\"http:\/\/192.168.1.213:8088\/wp-content\/uploads\/2023\/02\/ZTP_DNA_001.png\" data-elementor-open-lightbox=\"yes\" data-e-action-hash=\"#elementor-action%3Aaction%3Dlightbox%26settings%3DeyJpZCI6MTMzMiwidXJsIjoiaHR0cDpcL1wvMTkyLjE2OC4xLjIxMzo4MDg4XC93cC1jb250ZW50XC91cGxvYWRzXC8yMDIzXC8wMlwvWlRQX0ROQV8wMDEucG5nIn0%3D\">\n\t\t\t\t\t\t\t<img fetchpriority=\"high\" decoding=\"async\" width=\"800\" height=\"302\" src=\"http:\/\/192.168.1.213:8088\/wp-content\/uploads\/2023\/02\/ZTP_DNA_001-1024x386.png\" class=\"attachment-large size-large wp-image-1332\" alt=\"\" srcset=\"http:\/\/192.168.1.213:8088\/wp-content\/uploads\/2023\/02\/ZTP_DNA_001-1024x386.png 1024w, http:\/\/192.168.1.213:8088\/wp-content\/uploads\/2023\/02\/ZTP_DNA_001-300x113.png 300w, http:\/\/192.168.1.213:8088\/wp-content\/uploads\/2023\/02\/ZTP_DNA_001-768x289.png 768w, http:\/\/192.168.1.213:8088\/wp-content\/uploads\/2023\/02\/ZTP_DNA_001-1536x578.png 1536w, http:\/\/192.168.1.213:8088\/wp-content\/uploads\/2023\/02\/ZTP_DNA_001-2048x771.png 2048w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/>\t\t\t\t\t\t\t\t<\/a>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-3f2537d elementor-widget elementor-widget-image\" data-id=\"3f2537d\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<a href=\"http:\/\/192.168.1.213:8088\/wp-content\/uploads\/2023\/02\/ZTP_DNA_002.png\" data-elementor-open-lightbox=\"yes\" data-e-action-hash=\"#elementor-action%3Aaction%3Dlightbox%26settings%3DeyJpZCI6MTMzMywidXJsIjoiaHR0cDpcL1wvMTkyLjE2OC4xLjIxMzo4MDg4XC93cC1jb250ZW50XC91cGxvYWRzXC8yMDIzXC8wMlwvWlRQX0ROQV8wMDIucG5nIn0%3D\">\n\t\t\t\t\t\t\t<img decoding=\"async\" width=\"800\" height=\"302\" src=\"http:\/\/192.168.1.213:8088\/wp-content\/uploads\/2023\/02\/ZTP_DNA_002-1024x387.png\" class=\"attachment-large size-large wp-image-1333\" alt=\"\" srcset=\"http:\/\/192.168.1.213:8088\/wp-content\/uploads\/2023\/02\/ZTP_DNA_002-1024x387.png 1024w, http:\/\/192.168.1.213:8088\/wp-content\/uploads\/2023\/02\/ZTP_DNA_002-300x113.png 300w, http:\/\/192.168.1.213:8088\/wp-content\/uploads\/2023\/02\/ZTP_DNA_002-768x290.png 768w, http:\/\/192.168.1.213:8088\/wp-content\/uploads\/2023\/02\/ZTP_DNA_002-1536x580.png 1536w, http:\/\/192.168.1.213:8088\/wp-content\/uploads\/2023\/02\/ZTP_DNA_002-2048x774.png 2048w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/>\t\t\t\t\t\t\t\t<\/a>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-30987ac elementor-widget elementor-widget-text-editor\" data-id=\"30987ac\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p><strong>Let&#8217;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<div class=\"elementor-element elementor-element-d6bed61 elementor-widget elementor-widget-image\" data-id=\"d6bed61\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<a href=\"http:\/\/192.168.1.213:8088\/wp-content\/uploads\/2023\/02\/ZTP_DNA_003.png\" data-elementor-open-lightbox=\"yes\" data-e-action-hash=\"#elementor-action%3Aaction%3Dlightbox%26settings%3DeyJpZCI6MTM0MCwidXJsIjoiaHR0cDpcL1wvMTkyLjE2OC4xLjIxMzo4MDg4XC93cC1jb250ZW50XC91cGxvYWRzXC8yMDIzXC8wMlwvWlRQX0ROQV8wMDMucG5nIn0%3D\">\n\t\t\t\t\t\t\t<img decoding=\"async\" width=\"800\" height=\"300\" src=\"http:\/\/192.168.1.213:8088\/wp-content\/uploads\/2023\/02\/ZTP_DNA_003-1024x384.png\" class=\"attachment-large size-large wp-image-1340\" alt=\"\" srcset=\"http:\/\/192.168.1.213:8088\/wp-content\/uploads\/2023\/02\/ZTP_DNA_003-1024x384.png 1024w, http:\/\/192.168.1.213:8088\/wp-content\/uploads\/2023\/02\/ZTP_DNA_003-300x112.png 300w, http:\/\/192.168.1.213:8088\/wp-content\/uploads\/2023\/02\/ZTP_DNA_003-768x288.png 768w, http:\/\/192.168.1.213:8088\/wp-content\/uploads\/2023\/02\/ZTP_DNA_003-1536x576.png 1536w, http:\/\/192.168.1.213:8088\/wp-content\/uploads\/2023\/02\/ZTP_DNA_003-2048x768.png 2048w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/>\t\t\t\t\t\t\t\t<\/a>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<section class=\"elementor-section elementor-inner-section elementor-element elementor-element-4ced637 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"4ced637\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-50 elementor-inner-column elementor-element elementor-element-e6adc81\" data-id=\"e6adc81\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-8562dba elementor-widget elementor-widget-text-editor\" data-id=\"8562dba\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>Over 120 lines of code and 9 different DNA Center Ansible modules to use Plug and Play and onboard a device?!<\/p><p>&#8220;That&#8217;s too much and does not simplify the process using Ansible&#8221; <br \/>This is the feedback I got from one of my customers.\u00a0<\/p><p>The Cisco engineering team developed a module that is more intent-based. <img decoding=\"async\" class=\"emoji\" role=\"img\" draggable=\"false\" src=\"https:\/\/s.w.org\/images\/core\/emoji\/14.0.0\/svg\/1f44d.svg\" alt=\"\ud83d\udc4d\" \/><\/p><p>Thanks to the authors <a href=\"https:\/\/www.linkedin.com\/in\/madhan-sankaranarayanan-834277b\/\" target=\"_blank\" rel=\"noopener\">Madhan Sankaranarayanan<\/a> &amp; <a href=\"https:\/\/www.linkedin.com\/in\/rishita-chowdhary-01972817a\/\" target=\"_blank\" rel=\"noopener\">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<div class=\"elementor-column elementor-col-50 elementor-inner-column elementor-element elementor-element-5ab160a\" data-id=\"5ab160a\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-dd1f3ab elementor-widget elementor-widget-image\" data-id=\"dd1f3ab\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<img loading=\"lazy\" decoding=\"async\" width=\"514\" height=\"334\" src=\"http:\/\/192.168.1.213:8088\/wp-content\/uploads\/2023\/02\/omg.webp\" class=\"attachment-medium_large size-medium_large wp-image-1325\" alt=\"\" \/>\t\t\t\t\t\t\t\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\t<\/div>\n\t\t<\/section>\n\t\t\t\t<div class=\"elementor-element elementor-element-2249652 elementor-widget elementor-widget-heading\" data-id=\"2249652\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h5 class=\"elementor-heading-title elementor-size-default\">New intent-based Ansible modules<\/h5>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-5a95da6 elementor-widget elementor-widget-text-editor\" data-id=\"5a95da6\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>The following two Ansible modules are doing the job (<a href=\"https:\/\/github.com\/cisco-en-programmability\/dnacenter-ansible\/blob\/main\/plugins\/modules\/template_intent.py\" target=\"_blank\" rel=\"noopener\">cisco.dnac.template_intent<\/a> &amp; <a href=\"https:\/\/github.com\/cisco-en-programmability\/dnacenter-ansible\/blob\/main\/plugins\/modules\/pnp_intent.py\" target=\"_blank\" rel=\"noopener\">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<div class=\"elementor-element elementor-element-bf801e0 elementor-widget elementor-widget-heading\" data-id=\"bf801e0\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h6 class=\"elementor-heading-title elementor-size-default\">PNP_INTENT-BASED.yml<\/h6>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-753e366 elementor-widget elementor-widget-code-highlight\" data-id=\"753e366\" data-element_type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<div class=\"prismjs-default copy-to-clipboard \">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-bash line-numbers\">\n\t\t\t\t<code readonly=\"true\" class=\"language-bash\">\n\t\t\t\t\t<xmp>- hosts: dnac_servers\r\n  gather_facts: no\r\n  connection: local\r\n\r\n  tasks:\r\n    - name: Get timestamp from the system\r\n      shell: \"date +%Y-%m-%d%H-%M-%S\"\r\n      register: tstamp\r\n#\r\n# Create the template \r\n#      \r\n    - name: Create the template      \r\n      cisco.dnac.template_intent:\r\n        state: \"merged\"\r\n        config:\r\n        - projectName: \"Onboarding Configuration\"\r\n          templateContent: \"hostname TEST\"\r\n          language: \"velocity\"\r\n          deviceTypes:\r\n          - productFamily: \"Switches and Hubs\"\r\n          softwareType: \"IOS-XE\"\r\n          softwareVariant: \"XE\"\r\n          templateName: \"CSR1000V_{{ tstamp.stdout }}\"\r\n          versionDescription: \"{{ tstamp.stdout }}\"\r\n#\r\n# ZTP\r\n#\r\n    - name: Create pnp device\r\n      cisco.dnac.pnp_intent:\r\n        config:\r\n        - type: \"building\"\r\n          site:\r\n            building:\r\n              latitude: 37.338\r\n              longitude: -121.832\r\n              name: \"beye.blog\"\r\n              parentName: \"Global\" \r\n          project_name: \"Onboarding Configuration\"\r\n          template_name: \"CSR1000V_{{ tstamp.stdout }}\"\r\n          image_name: \"csr1000v-universalk9.17.03.05.SPA.bin\"\r\n          site_name: \"Global\/beye.blog\"\r\n          deviceInfo:\r\n            serialNumber: \"96MZPDLDSNV\"\r\n            hostname: \"CSR1000V-02\"\r\n            state: \"Unclaimed\"\r\n            pid: \"CSR1000V\"\r\n      register: pnp_result\r\n    - debug: var=pnp_result<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-30e0f0e elementor-widget elementor-widget-text-editor\" data-id=\"30e0f0e\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p><strong>Let&#8217;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<div class=\"elementor-element elementor-element-8bfa856 elementor-widget elementor-widget-image\" data-id=\"8bfa856\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<a href=\"http:\/\/192.168.1.213:8088\/wp-content\/uploads\/2023\/02\/ZTP_DNA_004.png\" data-elementor-open-lightbox=\"yes\" data-e-action-hash=\"#elementor-action%3Aaction%3Dlightbox%26settings%3DeyJpZCI6MTM1MSwidXJsIjoiaHR0cDpcL1wvMTkyLjE2OC4xLjIxMzo4MDg4XC93cC1jb250ZW50XC91cGxvYWRzXC8yMDIzXC8wMlwvWlRQX0ROQV8wMDQucG5nIn0%3D\">\n\t\t\t\t\t\t\t<img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"307\" src=\"http:\/\/192.168.1.213:8088\/wp-content\/uploads\/2023\/02\/ZTP_DNA_004-1024x393.png\" class=\"attachment-large size-large wp-image-1351\" alt=\"\" srcset=\"http:\/\/192.168.1.213:8088\/wp-content\/uploads\/2023\/02\/ZTP_DNA_004-1024x393.png 1024w, http:\/\/192.168.1.213:8088\/wp-content\/uploads\/2023\/02\/ZTP_DNA_004-300x115.png 300w, http:\/\/192.168.1.213:8088\/wp-content\/uploads\/2023\/02\/ZTP_DNA_004-768x295.png 768w, http:\/\/192.168.1.213:8088\/wp-content\/uploads\/2023\/02\/ZTP_DNA_004-1536x590.png 1536w, http:\/\/192.168.1.213:8088\/wp-content\/uploads\/2023\/02\/ZTP_DNA_004-2048x787.png 2048w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/>\t\t\t\t\t\t\t\t<\/a>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-384a7a9 elementor-widget elementor-widget-text-editor\" data-id=\"384a7a9\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p style=\"text-align: center;\"><strong>Here we go! This did it in just a few lines! \ud83d\udc4d<\/strong><\/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\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-374e7ba elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"374e7ba\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-3b1b7b5\" data-id=\"3b1b7b5\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-0fa507d elementor-widget elementor-widget-html\" data-id=\"0fa507d\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<script type=\"text\/javascript\">\n(function($) {\n    $(window).load(function() {\n        $('.token.entity').each(function() {\n            var title = $(this).attr('title');\n            $(this).html(title);\n        })\n    });\n})(jQuery);\n<\/script>\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\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>Table of Contents Introduction 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 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":1299,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[1,11,14],"tags":[],"class_list":["post-1106","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","category-automation","category-cisco-technologies"],"_links":{"self":[{"href":"http:\/\/192.168.1.213:8088\/wp-json\/wp\/v2\/posts\/1106"}],"collection":[{"href":"http:\/\/192.168.1.213:8088\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/192.168.1.213:8088\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/192.168.1.213:8088\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/192.168.1.213:8088\/wp-json\/wp\/v2\/comments?post=1106"}],"version-history":[{"count":63,"href":"http:\/\/192.168.1.213:8088\/wp-json\/wp\/v2\/posts\/1106\/revisions"}],"predecessor-version":[{"id":1470,"href":"http:\/\/192.168.1.213:8088\/wp-json\/wp\/v2\/posts\/1106\/revisions\/1470"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/192.168.1.213:8088\/wp-json\/wp\/v2\/media\/1299"}],"wp:attachment":[{"href":"http:\/\/192.168.1.213:8088\/wp-json\/wp\/v2\/media?parent=1106"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/192.168.1.213:8088\/wp-json\/wp\/v2\/categories?post=1106"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/192.168.1.213:8088\/wp-json\/wp\/v2\/tags?post=1106"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}