Zero-Touch Provisioning (ZTP) automates the initial configuration of switches at boot time, which minimizes manual work and reduces deployment costs. ZTP can upgrade the switch to a specified OS image, apply a switch configuration, and check connectivity to external resources. For the ZTP commands, see Zero-Touch Provisioning Commands.
You can apply a switch configuration in one of two formats: a YAML configuration file or a text file of CLI commands.
To create a YAML configuration file, save the running configuration with the nv config save command, then upload the file to an external provisioning server.
To create a text configuration file, run the nv config show -o commands command and paste the output into a text file. You can edit the file later to add or replace commands.
ZTP can also run custom provisioning scripts. A script can be of any type, must include a shebang, and runs during the ZTP process.
Running DHCP-ZTP
ZTP is enabled by default; there is no command to enable it. Saving the configuration (with the nv config save command) disables ZTP.
To enable ZTP again, use one of the following methods:
-
Run the
nv action reset system factory-defaultcommand: This command clears the entire switch configuration and reboots the system. This is the recommended method. -
Run
nv action run system ztp: This command starts the ZTP process only if the system has no configuration. Unlike a factory reset, this command does not remove the startup configuration; make sure that you clear the configuration before you run it.
ZTP is based on DHCP. For ZTP to work, NVOS enables DHCP by default on all management interfaces. The switch requests option 66 (tftp-server-name), option 67 (bootfile-name), or both from the DHCPv4 server, or option 59 (bootfile-url) from the DHCPv6 server, and waits for a DHCP response that contains the URL of the ZTP JSON configuration file. For more information, see ZTP Configuration File.
The DHCP server must send the URL of the ZTP configuration file. DHCPv4 supports two options: 66 and 67. If the DHCP server sends both options, the switch combines them into a TFTP URL for the ZTP configuration file; option 66 does not include the TFTP protocol prefix. If the server sends only option 67, the switch uses it as the URL of the ZTP configuration file.
DHCPv6 supports only option 59, which contains the complete URL of the ZTP JSON configuration file. All the options are strings. The following table summarizes the options:
|
DHCP Option |
Name |
Description |
|---|---|---|
|
66 |
tftp-server-name |
TFTP server address. If the server sends this option, it must also send option 67. |
|
67 |
bootfile-name |
URL from which to download the ZTP JSON configuration file, or the path of the ZTP JSON file on the TFTP server. |
|
59 |
dhcp6.bootfile-url |
URL from which to download the ZTP JSON configuration file. |
Example of options 66 and 67 for DHCPv4:
option tftp-server-name "198.51.100.8";
option bootfile-name "ztp.json";
The switch combines these options into tftp://198.51.100.8/ztp.json.
Example of option 67 only for DHCPv4:
option bootfile-name "scp://<user>:<pass>@198.51.100.8/ztp.json";
Example of option 59 for DHCPv6:
option dhcp6.bootfile-url "http://[2001:db8::8]/ztp.json";
Dynamic Content Configuration
When a switch requests a file by URL, the server that handles the request must know which file to return. For example, when a switch requests a configuration file, the server must return the configuration file for that switch. The server can select the file in two ways:
-
Provisioning server side: DHCP options and HTTP headers
-
ZTP client side: dynamic URL (see ZTP Configuration File)
DHCP Options
So that the DHCP server can select the right files for each switch, NVOS sends the following identifying information:
-
Product name—option 61
-
Serial number—option 61
-
User class—option 77 (option 15 for DHCPv6)
When the server receives such a DHCP request, it can map the switch-specific information to the target file URLs according to predefined rules.
The NVOS switch sends the following DHCP options in the DHCP request:
|
DHCP Option |
Name |
Description |
|---|---|---|
|
61 |
dhcp-client-identifier |
Used to uniquely identify the switch initiating DHCP request. NVOS switches set this value:
|
|
77 |
user-class |
Optionally identifies the type or category of user or application. NVOS switches set this value to "NVOS-ZTP". |
|
15 |
dhcp6.user-class |
Optionally identifies the type or category of user or application. NVOS switches set this value to "NVOS-ZTP". |
HTTP Headers
To decide which file to return, the server needs information that uniquely identifies the requesting switch. You can implement logic on the server that processes this information and returns the right file.
All HTTP and HTTPS requests that ZTP makes include switch identification information in the HTTP headers:
|
Header |
Value |
Example |
|---|---|---|
|
User-Agent |
NVOS-ZTP/0.1 |
|
|
PRODUCT-NAME |
String specifying the switch model |
|
|
SERIAL-NUMBER |
Serial number provided by the manufacturer |
MT1234X56789 |
|
BASE-MAC-ADDRESS |
Ethernet MAC address that the manufacturer assigned to the switch |
12:34:56:AB:CD:EF |
|
NVOS-VERSION |
Version string, as shown by the |
nvos-25.02.xxxx |
|
NVUE-VERSION |
Version string, as shown by the |
2.X.X.X-nvos |
ZTP Configuration
ZTP Configuration File
To automate provisioning, ZTP needs a JSON configuration file. The file consists of configuration sections (objects), each with its own options, and tells ZTP how to provision the switch and where to get the provisioning data. Here is an example of a ZTP JSON configuration file:
{
"ztp": {
"01-image": {
"install": {
"url": "http://198.51.100.2/images/nvos.bin"
},
"uninstall": true
},
"02-commands-list": {
"url": "sftp://user:password@198.51.100.3/configs/commands.txt",
"clear-config": true
},
"03-startup-file": {
"url": "scp://user:password@198.51.100.4/configs/config.yaml",
"clear-config": false
},
"04-connectivity-check": {
"ping-hosts": [ "198.51.100.5", "localhost" ],
"ping-count": 10,
"ignore-result": true
},
"05-provisioning-script": {
"url": "scp://user:password@198.51.100.5/scripts/script.sh",
"timeout": 300
}
}
}
The main section, ztp, must always be present in the ZTP JSON configuration file. It can contain the following configuration sections:
-
image—to manage system images on the switch
-
commands-list—to apply CLI commands in textual form
-
startup-file—to apply YAML formatted configuration
-
connectivity-check—to check connectivity to predefined hosts
-
provisioning-script—to download and run a custom script
ZTP processes the configuration sections in lexical order. To control the order, you can add an xx- prefix to the section names (for example, 02-commands-list).
Each configuration section supports the following common parameters, which control how ZTP processes the section. If you do not specify a parameter, ZTP uses its default value:
-
description: Optional free-form text that describes the configuration section.
-
ignore-result (default: false):
-
true—ZTP marks the section as SUCCESS even if an error occurs while processing it.
-
false—ZTP marks the section as FAILED if an error occurs while processing it.
-
-
halt-on-failure (default: false):
-
true—If the section result is FAILED, ZTP stops immediately and marks the ZTP status as FAILED. ZTP does not process any other configuration sections.
-
false—ZTP moves on to the next configuration section.
-
The main ztp section also has its own parameters:
-
restart-ztp-no-config (default: false):
-
true—ZTP restarts if the switch startup configuration file is not present after ZTP processes all the configuration sections in the ZTP JSON configuration file. ZTP restarts up to 10 times.
-
false—ZTP exits after it processes all the configuration sections, even if the switch startup configuration file is not present.
-
-
restart-ztp-on-failure (default: true):
-
true—ZTP restarts if the ZTP result is FAILED after ZTP processes all the configuration sections in the ZTP JSON configuration file. ZTP restarts up to 10 times.
-
false—ZTP exits after it processes all the configuration sections.
-
If ZTP encounters errors while parsing the ZTP JSON configuration file, it exits and marks the status as FAILED. Check the JSON format before you roll out the file. If the data for a configuration section is insufficient, ZTP marks the section as failed and moves on to the next section.
ZTP Configuration image
The image configuration section manages system images on the switch. You can use it to install and uninstall images.
Example section that installs a new image and boots into it:
"image": {
"install": {
"url": "http://198.51.100.2/images/nvos.bin",
"skip-reboot": false
}
}
Example section that uninstalls an NVOS image from the switch:
"image": {
"uninstall": true
}
The image configuration section supports the following parameters. If you do not specify a parameter, ZTP uses its default value:
-
install—Installs an image from a URL.
-
url/dynamic-url—The URL from which to download the system image file, as a url or dynamic-url object.
-
skip-reboot (default: false)—Specifies whether to skip the reboot after ZTP installs the new image. If true, the switch does not reboot.
-
-
uninstall (default: false)—Uninstalls an existing image from the disk.
-
true—Uninstalls the image from the second partition.
-
false—Does nothing.
-
If you define both, ZTP processes uninstall first, then install.
ZTP Configuration startup-file
The startup-file configuration section applies a switch configuration in the form of a YAML file. The YAML file has the same format as the switch startup configuration file. Here is an example of a startup-file configuration section:
"startup-file": {
"url": "http://198.51.100.3/startup.yaml",
"clear-config": true,
"save-config": true
}
The startup-file configuration section supports the following parameters:
-
url/dynamic-url—The URL from which to download the startup.yaml file, as a url or dynamic-url object.
-
clear-config (default: true)—Specifies whether to clear the existing configuration before loading the downloaded startup.yaml file. If true, ZTP replaces the current configuration with the content of the file. If false, ZTP merges the configurations.
-
save-config (default: false)—Specifies whether to save the configuration after loading the downloaded startup.yaml file.
Setting save-config to true saves the configuration, which disables ZTP at the end of the ZTP session.
ZTP Configuration commands-list
The commands-list configuration section applies a switch configuration in the form of CLI text commands. The list of commands is provided in a text file that ZTP downloads and applies. The file must contain only non-interactive commands; otherwise, the entire commands-list section fails. It is the user's responsibility to make sure that the commands are non-interactive; for example, provide “force”, “-y”, “-n”, or similar flags to interactive commands to prevent AYS (Are You Sure?) questions.
Running the nv action reboot system command restarts the switch and restarts the ZTP flow for the current section from the beginning, which can result in a boot loop. Keep this in mind when you create the commands-list text file. To reboot without a boot loop, use the reboot configuration parameter, which reboots the system only after all the commands run.
Example of a commands-list configuration section:
"commands-list": {
"url": "http://198.51.100.4/commands.txt",
"clear-config": true,
"save-config": true
}
The commands-list configuration section supports the following parameters:
-
url/dynamic-url—The URL from which to download the commands-list file, as a url or dynamic-url object.
-
clear-config (default: true)—Specifies whether to clear the existing configuration before applying the file. If true, ZTP applies an empty (default) configuration before it runs the commands.
-
save-config (default: false)—Specifies whether to save the configuration after applying the downloaded commands.
-
reboot (default: false)—Specifies whether to reboot the system after running all the commands.
Setting save-config to true saves the configuration, which disables ZTP at the end of the ZTP session. An nv config save command in the commands-list text file has the same effect.
ZTP Configuration connectivity-check
The connectivity-check section pings remote hosts to verify that the switch can reach them. You can ping multiple hosts; if the ping to any of the hosts fails, the section fails.
"connectivity-check": {
"ping-hosts": [ "198.51.100.5", "localhost" ]
}
The connectivity-check section supports the following objects:
-
ping-hosts—List of IPv4 hosts to ping.
-
ping6-hosts—List of IPv6 hosts to ping.
-
retry-interval (default: 5)—The number of seconds to wait before retrying the ping to a host.
-
retry-count (default: 12)—The number of retries, after which ZTP stops pinging the host and moves on to the next host in the list.
-
ping-count (default: 3)—Stops after sending count ECHO_REQUEST packets. With the deadline option, ping waits for count ECHO_REPLY packets until the timeout expires.
-
deadline (default: N/A)—The number of seconds before ping exits, regardless of how many packets were sent or received. In this case, ping does not stop after it sends count packets; it waits until the deadline expires, until count probes are answered, or until the network reports an error.
-
timeout (default: N/A)—The number of seconds to wait for a response. This option affects the timeout only when there are no responses; otherwise, ping waits for two RTTs (round-trip times).
ZTP Configuration provisioning-script
The provisioning-script plugin downloads and runs a file.
The downloaded file must meet the following requirements:
-
Include a shebang, such as
bashorpython. -
Contain only non-interactive commands.
-
Return an exit code of
0upon successful execution.
A non-zero exit code causes the provisioning-script section to fail.
Configuration Example
// ztp.json
{
"ztp": {
"1-provisioning-script": {
"url": "scp://user:password@server/path/to/script",
"timeout": 300,
"parameters": {
"--nvos_image": "/images/nvos-3.10.bin",
"--site": "dc1",
"-n": 3,
"--verbose": true
}
}
}
}
Supported Objects
|
Object |
Description |
|---|---|
|
|
Defines the URL from which to download the file. |
|
|
Specifies the timeout, in seconds. The default value is |
|
|
Optional object containing name/value pairs that are passed to the script as command-line arguments. Each name represents the option flag itself, such as |
|
Common objects |
Supports common ZTP objects, such as |
Parameter Rules
The parameters object must comply with the following rules:
-
Parameter names must be valid command-line flags:
-
A single dash followed by one letter, such as
-i -
Two dashes followed by a name that begins with a letter and contains letters, digits, underscores, or hyphens, such as
--imageor--nvos_image
-
-
Parameter names are passed unchanged. The plugin does not add dashes.
-
Parameter values must be scalar values:
-
String
-
Number
-
Boolean
-
-
Arrays, objects, and
nullvalues are not supported. -
A maximum of 20 parameters is supported.
A malformed parameters object causes the section to fail before the file is downloaded. Examples of malformed configurations include:
-
An invalid
parametersobject type -
An invalid parameter name
-
A non-scalar parameter value
-
More than 20 parameters
The failure includes a descriptive error message.
String Value Escaping
String values follow standard JSON escaping rules:
-
To include a double quotation mark, use
\". -
To include a backslash, use
\\.
For example:
"parameters": {
"--message": "hello \"world\"",
"--path": "C:\\nvos\\img"
}
ZTP and OS Upgrade
You can upgrade from a version without ZTP to a version with ZTP, and back. When you upgrade from a version without ZTP, ZTP is disabled, because ZTP always assumes that it starts with an empty configuration.
Example Configurations
DHCPv4 Configuration
The following is a configuration example for an ISC DHCPv4 server:
host master {
hardware ethernet 12:34:56:AB:CD:EF;
fixed-address 198.51.100.201;
option bootfile-name "scp://<user>:<password>@198.51.100.8/ztp.json";
}
DHCPv6 Configuration
The following is a DHCPv6 configuration example:
host master {
........
option dhcp6.bootfile-url "http://[2001:db8::8]/ztp.json";
}
ZTP Configuration File Example
{
"ztp": {
"01-image": {
"uninstall": true
},
"02-commands-list": {
"url": "sftp://user:password@198.51.100.3/configs/commands.txt",
"clear-config": true
},
"03-startup-file": {
"url": "scp://user:password@198.51.100.4/configs/config.yaml"
},
"04-connectivity-check": {
"ping-hosts": [ "198.51.100.5", "localhost" ]
}
}
}
Commands List Example
# Disable password hardening
nv set system security password-hardening state disabled
# Configure log rotation rules
nv set system log rotation frequency weekly
# Configure system message
nv set system message pre-login Hello
# Applying config
nv config apply -y
YAML Formatted File Configuration
- set:
system:
log:
rotation:
size: 30.0
ntp:
dhcp: disabled
server:
localntpserver: {}
ua.pool.ntp.org:
association-type: pool
security:
password-hardening:
state: disabled
Provisioning Script Example
#!/usr/bin/python3
print("Hello world from Provisioning Script!")
Last updated: