Skip to content

Device Models

Configurations can be applied to different entities, such as a single device, a group of devices or globally.

Device

A single device can be configured by providing a configuration directly under a device.

nxos:
devices:
- name: Switch1
url: https://1.2.3.4
configuration:
system:
hostname: Switch1
mtu: 9216

Device Groups

Multiple devices can be configured by providing a configuration under a device group.

nxos:
device_groups:
- name: LEAFS
configuration:
system:
fabric_forwarding:
anycast_gateway_mac: 20:20:00:00:10:12

Devices can be added to a device group either from the device or the group configuration.

nxos:
devices:
- name: Leaf1
device_groups:
- LEAFS
nxos:
device_groups:
- name: LEAFS
devices:
- Leaf1
- Leaf2

Global

Global configurations will be applied to all devices.

nxos:
global:
configuration:
system:
mtu: 9216

Interface Groups

Interface groups can be used to configure multiple interfaces with the same configuration.

nxos:
interface_groups:
- name: LOOPBACK_INTERFACE
configuration:
ospf:
process_name: "1"
area: 0.0.0.0
network_type: p2p
pim:
admin_state: true
sparse_mode: true

Interface groups can then be applied to one more interfaces of one or more devices:

nxos:
device_groups:
- name: LEAFS
configuration:
interfaces:
loopbacks:
- id: 1
interface_groups: [LOOPBACK_INTERFACE]

Variables

Variables can be used to define reusable values that can be used in configurations. Variables can be defined globally, per device or per device group, where device variables take precendence over device group variables and device group variables take precedence over global variables. Instead of hardcoding a specific configuration value, a placeholder using the ${...} syntax can be used. The value will be replaced by the variable value when rendering the device configuration.

Terraform is being used as a templating engine and the exact syntax is documented here.

nxos:
global:
configuration:
system:
hostname: ${hostname}
devices:
- name: Leaf1
variables:
hostname: LEAF1
- name: Leaf2
variables:
hostname: LEAF2

Configuration Templates

Configuration templates can be used to define reusable configurations that can be applied repeatedly to device groups. This is useful if the same configuration (e.g. service related) is applied repeatedly using different variable values. Either global or device group variables can be used in configuration templates.

nxos:
configuration_templates:
- name: vlan
configuration:
vlans:
- id: ${vlan_id}
name: L2_${vlan_id}
device_groups:
- name: vlan_100
configuration_templates: [vlan]
variables:
vlan_id: 100
- name: vlan_101
configuration_templates: [vlan]
variables:
vlan_id: 101