Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

Using Salt to Restore a Device Running Junos OS to the Factory-Default Configuration Settings

Juniper Networks provides support for using Salt to manage devices running Junos OS, and the Junos execution and state modules (for Salt) define functions that enable you to perform operational and configuration tasks on the managed devices. The salt.modules.junos.zeroize execution function and the salt.states.junos.zeroize state function enable you to restore a device running Junos OS to its factory-default configuration settings. After a device is restored to the factory-default configuration settings, you must log in through the console as root in order to access the device.

junos.zeroize Function Overview

The junos.zeroize function executes the request system zeroize operational command on the target hosts. The function resets both Routing Engines in a dual Routing Engine system.

This command removes all configuration information on the specified Routing Engines, resets all key values on the device, and then reboots the device and resets it to the factory-default configuration settings. The zeroize operation removes all data files, including customized configuration and log files, by unlinking the files from their directories, and it also removes all user-created files from the system including all plain-text passwords, secrets, and private keys for SSH, local encryption, local authentication, IPsec, RADIUS, TACACS+, and SNMP.

The salt.modules.junos.zeroize execution function syntax is:

The salt.states.junos.zeroize state function syntax is:

where id is the user-defined identifier for the state declaration.

For more information about the request system zeroize command, see request system zeroize.

How to Use the junos.zeroize Execution and State Functions

The junos.zeroize function enables you to easily reset one or more devices running Junos OS to its factory-default configuration settings from the Salt master command line.

For example, the following command resets the target device to its factory default settings:

You can perform the same operation in a Salt state file. For example:

When you execute the junos.zeroize function, it resets the device configuration, including the hostname and IP address and any configured connection and authentication information. As a result, the proxy minion is unable to maintain the connection to the device.

After the device is restored to its factory-default configuration settings, you must log in through the console as root in order to access the device. The device displays Amnesiac in place of a hostname, because the updated configuration no longer specifies a hostname.

To restore the connection between the Salt proxy minion and the managed device, you must configure the device with the appropriate settings. For example, you must configure the NETCONF-over-SSH service. You must also configure the device with the same connection and authentication settings that are defined in the proxy configuration for that device in the pillar data on the Salt master. The proxy minion will automatically reconnect to the device after the appropriate settings are configured and committed.