Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

Configure and Use a Primary Source Location for a Script

You can store a single primary copy of each automation script in a central repository. This eases file management because you can make changes to the primary script in one location and then update the local copy on each device where the script is enabled. This section discusses how to configure the primary script's source location and how to refresh the local copy of the script.

Configure the Primary Script's Source Location

To specify the source location of the primary script from which a local script will be refreshed:

  1. Configure the source statement, and specify the URL of the primary source file as an HTTPS URL, HTTP URL, FTP URL, or secure copy (scp)-style remote file specification.

    The configuration hierarchy depends on the script type and filename.

    The following example configures the source location for the ospf-neighbors.slax op script.

  2. If the source location is on an HTTPS server, configure the cert-file statement on supported devices. Specify the absolute path to the certificate (Root CA or self-signed) in Privacy-Enhanced Mail (PEM) format that the device uses to validate the server's certificate.

    The configuration hierarchy depends on the script type and filename.

    The following example configures the root CA certificate that validates the certificate of the server where the primary copy of the ospf-neighbors.slax op script resides.

Including the source statement in the configuration does not affect the local copy of the script until you issue the set refresh configuration mode command. When you issue the set refresh command, the device replaces the local script with the copy from the source location.

Configure the Routing Instance Used to Refresh a Script from the Source Location

You can specify a routing instance to use to refresh or download a script from its primary source location. This routing instance can be either the nondefault management instance mgmt_junos or some other routing instance. You must configure the routing instance at the [edit system routing-instances] hierarchy level.

To use mgmt_junos when you update a script from its primary source location:

  1. Enable mgmt_junos by configuring the management-instance statement at the [edit system] hierarchy level.
  2. Configure the mgmt_junos routing instance at the [edit routing-instances] hierarchy level.
  3. Configure the mgmt_junos routing instance at the hierarchy level for that script:
    • For commit, op, or SNMP scripts, configure the mgmt_junos routing instance at the [edit system scripts (commit | op | snmp) file] hierarchy level.

    • For event scripts, configure the mgmt_junos routing instance at the [edit event-options event-script file] hierarchy level.

    • For JET scripts, configure the mgmt_junos routing instance at the [edit system extensions extension-service application file] hierarchy level.

Note:

To update scripts from a single primary source location using a configured management interface, you can configure only mgmt_junos for the routing-instance-name. To use a non-management interface, you can configure anything for the routing-instance-name.

Update a Script from the Primary Source Location

If you configure a primary source location for one or more scripts on a device, you can refresh the scripts on that device using the set refresh configuration mode command. You can update a single script or all scripts of a given script type that have a primary source location configured.

The update operation occurs as soon as you issue the set refresh command. When you issue the set refresh command, the device immediately attempts to connect to the specified URL and retrieve a copy of the primary source file. The copy overwrites the local script stored in the scripts directory on the device. If the load-scripts-from-flash statement is configured, the device updates the script on the flash drive instead of the script on the hard disk. If a primary source location is not defined for a script, the device issues a warning and does not update that script. For commit scripts, the updated commit script is executed when you next issue the commit command. If the script configuration includes the routing-instance statement, then Junos OS updates the script using that routing instance.

Note:

Issuing the set refresh command does not add the refresh statement to the configuration. Thus the command behaves like an operational mode command and yet it can be executed from within configuration mode. The functionality is provided in this manner as a convenience to users developing scripts.

If the device has dual Routing Engines and you want to update a script on both Routing Engines, you must issue the set refresh command on each Routing Engine separately. Alternatively, you can refresh the scripts on the requesting Routing Engine and then use either the request system scripts synchronize operational mode command to synchronize scripts to the other Routing Engine or the commit synchronize scripts configuration mode command to synchronize all scripts to the other Routing Engine when you commit and synchronize the configuration.

To update a single script from its master source, issue the set refresh command at the hierarchy level where the script is configured. The hierarchy location depends on the script type and filename as shown in the following examples. The source statement specifying the primary source location must already be configured.

To update all enabled scripts of a given script type from their master source files, issue the set refresh command at the hierarchy level for that script type.

Change History Table

Feature support is determined by the platform and release you are using. Use Feature Explorer to determine if a feature is supported on your platform.

Release
Description
25.2R1-EVO
Starting in Junos OS Evolved Release 25.2R1, you must specify a certificate when you refresh scripts from an HTTPS server.
21.2R1
Starting in Junos OS Release 21.2R1, you must specify a certificate when you refresh scripts from an HTTPS server.