3 mins read

System Scripts

Junos automation consists of a suite of tools used to automate operational and configuration tasks on network devices running Junos. In this post we will configure different system scripts on the router.

1. Basic system script configuration

First, we need to copy the scripts to the router:

The script files must be copied to a specific location, as follows:

  • op scripts to: /var/db/scripts/op/
  • commit scripts to: /var/db/scripts/commit/
  • event scripts to: /var/db/scripts/event/
  • snmp scripts to: /var/db/scripts/snmp/

We can check if the scripts are there:

To activate the script we will basically tell Junos where to search the script file. Junos will look in the /var/db/scripts/ locations we mentioned above:

For event script the activation is a little different. We must activate the script, at the [event-options] hierarchy, Additionally we must also create the event policy that will trigger the script:

2. Run the scripts

For each script type we can note:

  • Op script will run with the op my-op-script.slax command.
  • Commit script will run on every commit (we can include the optional keyword to avoid commit failure if file is missing).
  • Event script will be triggered by an event.
  • snmp script will trigger automatically when the SNMP manager requests information from the SNMP agent

3. Python Scripts

Python scripts (.py) is very similar with slax scripts (.slax) in terms of location and enabling, so the CLI commands from the previous chapters remain the same. Only the script file and file extension is different.

But, if we want to execute unsigned Python scripts we do need to configure the following:

4. load-scripts-from-flash

When configured, load commit, event, op, SNMP, and library scripts from the device’s flash memory instead of the hard disk.

This command will create the new script location: /config/scripts/. Files are not moved automatically from default location to this new one.


External Resources: