Overview of Updating Scripts from a Remote Source
You can update the automation scripts on a device running Junos OS by retrieving a copy from a remote machine (which can be another device running Junos OS or a regular networked computer). This eases file management, because you can make changes to the master script in a single location and then update the copy on each device where the script is currently enabled. Each device continues to use its locally stored scripts, only updating a script when you issue the appropriate operational or configuration mode command.
For each script, you can configure the source statement and a URL at the hierarchy level where you configured the script to define the remote location that houses the master copy of that script. When you then issue the set refresh configuration mode command for a script, the device running Junos OS updates its local copy by retrieving the remote master copy from that URL.
You can also store a copy of a particular script at a remote location other than the master source. This is convenient when, for example, the master source cannot be accessed due to network issues or other problems. To refresh a single script or multiple scripts from the remote location, you issue the set refresh-from configuration mode command at the appropriate hierarchy level and specify the URL. You can also refresh a single script from a remote location using the request system scripts refresh-from operational mode command.
You can use the set refresh and set refresh-from commands to update either an individual script or multiple scripts of a given type on the device. When you issue the set refresh or set refresh-from command, the switch, router, or security device immediately attempts to connect to the appropriate remote source for each script. If successful, the device updates the local script with the remote source. If a problem occurs, a set of error messages is returned.
Issuing the set refresh or set refresh-from command does not add the refresh and refresh-from statements to the configuration. Thus, these commands behave like operational mode commands by executing an operation, instead of adding a statement to the configuration. The refresh and refresh-from statements are mutually exclusive.
If a device has dual Routing Engines and you want to update the script on both Routing Engines, you must issue the set refresh or set refresh-from command on each Routing Engine separately. Alternatively, starting in Junos OS Release 13.2, 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. If you use the request system scripts refresh-from operational mode command to refresh a script from a specific URL, include the sync option to refresh the script on both Routing Engines.
For commit scripts, we recommend that you do not automate the update function by including the refresh statement as a commit script change element. Even though this might seem like a good way to ensure that the most current commit script is always used, we recommend against it for the following reasons:
Automated update means that the network must be operational for the commit operation to succeed. If the network goes down after you make a configuration error, you cannot recover quickly.
If multiple commit scripts need to be updated during each commit operation, the network response time can slow down.
Automated update is always the last action performed during a commit operation. Consequently, the updated commit script executes only during the next commit operation. This is because commit scripts are applied to the candidate configuration before the software copies any persistent changes generated by the scripts to the candidate configuration. In contrast, if you perform the update operation manually, the updated commit script takes effect as expected, that is, immediately after you commit the refresh statement in the configuration.
If you automate the update operation, the refresh-from statement has no effect, because the refresh-from URL conflicts with and is overridden by the source statement URL. For information about the refresh-from statement, see Using an Alternate Source Location for a Script.