Deployment of Configuration Template
Scenario Overview
This guide demonstrates how to use the CNC Device Configuration Templates API to deploy configuration templates to network devices. Deploying templates helps network administrators automate and standardize configuration changes across multiple devices, improving efficiency and reducing errors.
The operation in the following API references is used in this example.
Prerequisites
Before running this example, ensure:
- You have obtained an access token. Refer to the 'Getting Started' section for instructions.
- The
cnc-api-common.sh
script is properly configured. - Necessary input and output directories exist for storing and retrieving deployment files.
Creation of Configuration Template
Run the device-config-template-deployment.sh script from the example directory to deploy the configuration template.
cd cnc-device-config-templates-api-examples;./device-config-template-deployment.sh
Script Details
This script reads input from the device-config-template-deployment.json file located in the input directory. Upon successful execution of template deployment, the set of configured commands will be executed and reflected on device and the output is saved to the device-config-template-deployment.json file in the output directory.
For the request payload, user needs to provide the specified fields in the json payload below:
#!/bin/bash
. ./cnc-api-common.sh
device-config-template-deployment() {
# Assume the CNC JWT has already been obtained by running the get-cnc-jwt.sh script.
# Read from JWT file and export it as AUTH_TOKEN_HDR
export_jwt
# STEP 1 : Deploy configuration template to device
# STEP 2 : Store the output in CNC_API_OUTPUT file
CNC_API_URL=$CNC_DEVICE_CONFIG_API_CTX/v1/templates/deploy-template
CNC_API_INPUT="$PRJ/input/device-config-template-deployment.json"
CNC_API_OUTPUT="$PRJ/output/device-config-template-deployment.json"
http_post $CNC_API_URL @$CNC_API_INPUT $CNC_API_OUTPUT
}
device-config-template-deployment