Overview of Updating Scripts from a Remote Source
You can update automation scripts on Junos devices by retrieving a copy from a remote machine (which can be another Junos device or a regular networked computer). This eases file management because you can store a primary copy of each automation script in a single central repository. You can then make changes to the primary script and update the local copy of that script on each device where the script is 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 define the remote location that stores the single primary copy
of that script. To specify the location, configure the source
statement and a URL at the hierarchy level where you configured the script. After you
configure the source, you can issue the set refresh
configuration mode
command for a script, and the device replaces its local copy of the script with the one
from the URL.
You can also store a copy of a primary script at an alternate remote location, for example, on a
backup server. This is convenient when, for example, the configured source location
cannot be accessed due to network issues or other problems. To refresh a single script
or multiple scripts from the alternate location, you issue the
set refresh-from
configuration mode command at the appropriate
hierarchy level and specify a 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 all scripts of a given type on the device. When
you issue the set refresh
or set refresh-from
command,
the 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
the device encounters a problem, it generates an error message.
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 can use one of the following options:
-
Issue the
set refresh
orset refresh-from
configuration mode command on each Routing Engine. -
Refresh the scripts on the requesting Routing Engine and then use the
request system scripts synchronize
operational mode command to synchronize scripts to the other Routing Engine. -
Use the
request system scripts refresh-from
operational mode command to refresh a script from a specific URL and include thesync
option to refresh the script on both Routing Engines. -
Refresh the scripts on the requesting Routing Engine and then use the
commit synchronize scripts
configuration mode command to synchronize all scripts to the other Routing Engine when you commit and synchronize the configuration.
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 therefresh-from
URL conflicts with and is overridden by thesource
statement URL. For information about therefresh-from
statement, see Use an Alternate Source Location for a Script.