Template
Templates provide a way to define reusable configuration blocks that can be applied to multiple devices or device groups with different variable values, enabling parameterized and repeatable deployments. Three template types are supported: model templates that use the data model with variable substitution (${var}), file templates that reference external configuration files, and CLI templates that contain raw NX-OS CLI commands with optional ordering control. Templates are assigned to devices, device groups, or global configuration, and support an order attribute (0-9) for controlling the sequence in which multiple templates are applied.
Diagram
Section titled “Diagram”Classes
Section titled “Classes”templates (nxos)
Section titled “templates (nxos)”| Name | Type | Constraint | Mandatory | Default Value |
|---|---|---|---|---|
| name | String | Yes | ||
| type | Choice | model, file, cli | Yes | |
| order | Integer | min: 0, max: 9 | No | 0 |
| file | String | No | ||
| content | String | No |
Examples
Section titled “Examples”Example 1: Model template for L2 VXLAN service provisioning with variable substitution
nxos: templates: - name: L2_SERVICE type: model configuration: vlan: vlans: - id: ${vlan_id} vni: 10${vlan_id} name: L2_${vlan_id} interfaces: nve: vnis: - vni: 10${vlan_id} ingress_replication_protocol: bgp evpn: vnis: - vni: 10${vlan_id} rd: auto route_target_imports: ["65000:10${vlan_id}"] route_target_exports: ["65000:10${vlan_id}"]Example 2: Model template for L3 VRF service with EVPN symmetric IRB
nxos: templates: - name: L3_SERVICE type: model configuration: vrfs: - name: ${name} vni: 1${l3_vlan_id} route_distinguisher: auto address_families: - address_family: ipv4-unicast route_target_imports: ["65000:1${l3_vlan_id}"] route_target_exports: ["65000:1${l3_vlan_id}"] route_target_imports_evpn: ["65000:1${l3_vlan_id}"] route_target_exports_evpn: ["65000:1${l3_vlan_id}"] vlan: vlans: - id: ${l3_vlan_id} vni: 1${l3_vlan_id} name: ${name} interfaces: nve: vnis: - vni: 1${l3_vlan_id} associate_vrf: true vlans: - id: ${l3_vlan_id} vrf: ${name} ip_forward: trueExample 3: CLI template for custom configuration with ordering control
nxos: templates: - name: GLOBAL_NTP type: cli order: 1 content: | ntp server 10.50.100.1 use-vrf management ntp server 10.50.100.2 use-vrf management ntp source-interface mgmt0
- name: GLOBAL_LOGGING type: cli order: 2 content: | logging server 10.50.100.2 use-vrf management logging level local7 6Example 4: File-based template referencing an external configuration file
nxos: templates: - name: SECURITY_BASELINE type: file file: security_baseline.cfg order: 0