Device
NX-OSDevices represent individual NX-OS network devices (switches, routers) that are configured and managed, each identified by a unique name and a management URL for connectivity. Device configurations have the highest precedence in the configuration hierarchy (Global → Device Group → Device), allowing you to override inherited settings for specific devices while maintaining consistency through group and global defaults. The managed attribute can be used to temporarily skip a device due to maintenance, and devices can be assigned to device groups, variables, and templates for flexible configuration management. Device-specific raw CLI can be added with cli_templates, which use the same stage and order attributes as CLI templates but are defined inline on the device.
Devices represent individual NX-OS network devices (switches, routers) that are configured and managed, each identified by a unique name and a management URL for connectivity. Device configurations have the highest precedence in the configuration hierarchy (Global → Device Group → Device), allowing you to override inherited settings for specific devices while maintaining consistency through group and global defaults. The managed attribute can be used to temporarily skip a device due to maintenance, and devices can be assigned to device groups, variables, and templates for flexible configuration management.
Diagram
Section titled “Diagram”Diagram
Section titled “Diagram”Classes
Section titled “Classes”| Name | Type | Constraint | Mandatory | Default Value |
|---|---|---|---|---|
| devices | List | devices | No |
devices (nxos)
Section titled “devices (nxos)”| Name | Type | Constraint | Mandatory | Default Value |
|---|---|---|---|---|
| name | String | Yes | ||
| url | String | Yes | ||
| device_groups | List | String | No | |
| variables | Map | No | ||
| templates | List | String | No | |
| managed | Boolean | true, false | No | true |
| cli_templates | List | cli_templates | No |
devices (nxos)
Section titled “devices (nxos)”| Name | Type | Constraint | Mandatory | Default Value |
|---|---|---|---|---|
| name | String | Yes | ||
| url | String | Yes | ||
| device_groups | List | String | No | |
| variables | Map | No | ||
| templates | List | String | No |
cli_templates (nxos.devices)
Section titled “cli_templates (nxos.devices)”| Name | Type | Constraint | Mandatory | Default Value |
|---|---|---|---|---|
| name | String | Yes | ||
| stage | Choice | pre, post | No | |
| order | Integer | min: 0, max: 9 | No | |
| content | String | Yes |
Examples
Section titled “Examples”Example 1: Basic device inventory with management URLs and group assignments
nxos: devices: - name: SPINE1 url: https://10.50.202.116 device_groups: - SPINES variables: hostname: SPINE1 lo0_ip: 10.1.100.1
- name: SPINE2 url: https://10.50.202.117 device_groups: - SPINES variables: hostname: SPINE2 lo0_ip: 10.1.100.2Example 2: Leaf switches with VTEP variables and fabric group membership
nxos: devices: - name: LEAF1 url: https://10.50.202.118 device_groups: - LEAFS variables: hostname: LEAF1 lo0_ip: 10.1.100.3 vtep_ip: 10.1.200.1
- name: LEAF2 url: https://10.50.202.119 device_groups: - LEAFS variables: hostname: LEAF2 lo0_ip: 10.1.100.4 vtep_ip: 10.1.200.2Example 3: Device with inline configuration override, multiple group memberships, and managed flag
nxos: devices: - name: BORDER-LEAF1 url: https://10.50.202.120 device_groups: - LEAFS - BORDERS variables: hostname: BORDER-LEAF1 lo0_ip: 10.1.100.5 vtep_ip: 10.1.200.3 configuration: routing: bgp: asn: "65000" neighbors: - ip: 10.1.100.1 inherit_peer: SPINE-PEERS - ip: 10.1.100.2 inherit_peer: SPINE-PEERS templates: - L3_SERVICE
- name: LEAF-MAINT url: https://10.50.202.121 managed: false device_groups: - LEAFS variables: hostname: LEAF-MAINT lo0_ip: 10.1.100.6Example 4: Device with inline CLI templates applied before and after the modeled configuration
nxos: devices: - name: LEAF1 url: https://10.1.1.1 cli_templates: - name: PRE-HARDWARE stage: pre content: | hardware access-list tcam region ing-racl 1536 - name: POST-BANNER stage: post order: 1 content: | banner exec ^Managed by Network as Code^Examples
Section titled “Examples”Example 1: Basic device inventory with management URLs and group assignments
nxos: devices: - name: SPINE1 url: https://10.50.202.116 device_groups: - SPINES variables: hostname: SPINE1 lo0_ip: 10.1.100.1
- name: SPINE2 url: https://10.50.202.117 device_groups: - SPINES variables: hostname: SPINE2 lo0_ip: 10.1.100.2Example 2: Leaf switches with VTEP variables and fabric group membership
nxos: devices: - name: LEAF1 url: https://10.50.202.118 device_groups: - LEAFS variables: hostname: LEAF1 lo0_ip: 10.1.100.3 vtep_ip: 10.1.200.1
- name: LEAF2 url: https://10.50.202.119 device_groups: - LEAFS variables: hostname: LEAF2 lo0_ip: 10.1.100.4 vtep_ip: 10.1.200.2Example 3: Device with inline configuration override, multiple group memberships, and managed flag
nxos: devices: - name: BORDER-LEAF1 url: https://10.50.202.120 device_groups: - LEAFS - BORDERS variables: hostname: BORDER-LEAF1 lo0_ip: 10.1.100.5 vtep_ip: 10.1.200.3 configuration: routing: bgp: asn: "65000" neighbors: - ip: 10.1.100.1 inherit_peer: SPINE-PEERS - ip: 10.1.100.2 inherit_peer: SPINE-PEERS templates: - L3_SERVICE
- name: LEAF-MAINT url: https://10.50.202.121 managed: false device_groups: - LEAFS variables: hostname: LEAF-MAINT lo0_ip: 10.1.100.6