Skip to content

Device Template Usage

Dashboard Location: N/A (Template assignment is configured in the NAC data model, not in the Meraki Dashboard)

Applying Templates and Supplying Variables to Devices

Section titled “Applying Templates and Supplying Variables to Devices”

Once templates are defined under meraki.templates.devices, each device can reference one or more of them by name using the templates field. Just like network templates, the templates field on a device is an ordered list — templates are merged into the device configuration in the order they are listed. If two templates define the same key, the last one wins. Device templates are applied after any network template has already been merged into the network, so a device’s own configuration and its templates always take precedence over the network-level configuration it belongs to.

The variables block supplies the values that replace ${variable_name} placeholders across all templates referenced by that device. Every placeholder used in any of the referenced templates must have a corresponding entry in variables, or an empty string is substituted. Variables that reference secrets should use !env variable_name instead of inline values.

Device templates are most useful for standardizing configuration by device type or model — for example, all 24-port access switches share the same port layout and VLAN scheme, while 48-port switches share a different one. Fields that vary per device — such as serial, name, and tags — stay on the device entry itself; fields that are common to every device of that type — such as port ranges and VLAN assignments — live in the template.

A device can also define its own entries in a list-valued field (such as switch.ports) alongside a template that defines entries in the same field — for example, a device with an extra port that isn’t part of its standard template. These entries are combined, not replaced: entries from the template and entries from the device are appended together, and two entries are merged into one only when every scalar field they define matches (nested fields like port_id_ranges are not part of that comparison). Give a device-specific entry a distinct scalar value — such as a unique name or vlan — to keep it from being merged with a template-provided entry.

Diagram

devices (meraki.domains.organizations.networks)

Section titled “devices (meraki.domains.organizations.networks)”
NameTypeConstraintMandatoryDefault Value
templatesListStringNo
variablesMapNo

Example 1: Model Templates — 24-Port and 48-Port Switch Port Layouts

Section titled “Example 1: Model Templates — 24-Port and 48-Port Switch Port Layouts”

This example defines two model templates, switch_24_port and switch_48_port, each configuring an access switch’s ports: all ports except the last are set to access mode on a shared access VLAN, and the last port is a trunk uplink on the native VLAN. Both access_vlan and native_vlan are parameterized so that switches in different closets or wiring rooms can use different VLANs while sharing the same port layout.

meraki:
templates:
devices:
- name: switch_24_port
type: model
configuration:
switch:
ports:
- port_id_ranges:
- from: 1
to: 23
type: access
vlan: ${access_vlan}
enabled: true
- port_id_ranges:
- from: 24
to: 24
type: trunk
vlan: ${native_vlan}
enabled: true
- name: switch_48_port
type: model
configuration:
switch:
ports:
- port_id_ranges:
- from: 1
to: 47
type: access
vlan: ${access_vlan}
enabled: true
- port_id_ranges:
- from: 48
to: 48
type: trunk
vlan: ${native_vlan}
enabled: true

Example 2: Applying the Templates to Individual Devices

Section titled “Example 2: Applying the Templates to Individual Devices”

Each device in the network references the template that matches its port count and supplies its own serial, name, and per-device variables. Closet-A-Switch is a 24-port switch on VLAN 10 with a native VLAN of 1; Closet-B-Switch is a 48-port switch on a different access VLAN. Adding a new switch of either size is as simple as adding a new device entry with its own serial, name, and variables — the shared port layout is defined once in the template.

meraki:
domains:
- name: EU
administrator:
name: admin
organizations:
- name: Acme
networks:
- name: Rome-Network-1
devices:
- serial: Q2XX-XXXX-0001
name: Closet-A-Switch
templates:
- switch_24_port
variables:
access_vlan: 10
native_vlan: 1
- serial: Q2XX-XXXX-0002
name: Closet-B-Switch
templates:
- switch_48_port
variables:
access_vlan: 20
native_vlan: 1

Example 3: Combining a Template with Device-Specific Ports

Section titled “Example 3: Combining a Template with Device-Specific Ports”

DMZ-Switch-01 references the switch_dmz template for its standard port layout, but also defines port 5 directly on the device — a port that isn’t part of the template. Because the device-level port entry has a distinct name (Direct device port) and vlan (20) from every template-provided entry, it is appended as a separate port rather than being merged into one of them.

meraki:
templates:
devices:
- name: switch_dmz
type: model
configuration:
switch:
ports:
- port_id_ranges:
- from: 7
to: 7
name: DMZ port
type: access
vlan: ${access_vlan}
enabled: true
- port_id_ranges:
- from: 8
to: 9
type: trunk
vlan: ${native_vlan}
enabled: true
domains:
- name: EU
administrator:
name: admin
organizations:
- name: Acme
networks:
- name: Rome-Network-1
devices:
- name: DMZ-Switch-01
templates:
- switch_dmz
variables:
access_vlan: 1
native_vlan: 1
switch:
ports:
- port_id_ranges:
- from: 5
to: 5
name: Direct device port
type: access
vlan: 20
enabled: true

The resulting DMZ-Switch-01 configuration has three switch.ports entries: the DMZ port and trunk ports from switch_dmz, plus Direct device port defined directly on the device — none of them merged together.