#Config-Loader
A simple SLAX script that allows for easily loading a config onto a a Junos device
- Place the script file "config-loader.slax" into the directory /var/db/scripts/op/ on the device
- Enable the script for usage in the configuration
..1
set system scripts op file config-loader.slax
- Commit the configuration ..1 If there is an error in the script or if the script is missing then Junos will throw an error
The tool can remotely load a configuration file via a file, FTP, or HTTP URL.
The script requires three arguments to load the configuration
- source: The URL source for the config
- FTP, HTTP, or a file path
- FTP Example ftp://foo:[email protected]:/config.text
- HTTP Example http://1.2.3.4:8080/config.text
- FILE Example /var/tmp/config.text
- action: The action to take with the config
- replace: Replaces the existing configuration with the newly loaded configuration file
- merge: Merges the newly loaded configuration with the existing config
- override: Discards all other candidate configurations and replaces it with the loaded config (not needed for this use case)
- set: Set is specified when the text file you are loaded uses configuration CLI commands
- format: The format of the loaded configuration
- xml: Specifies the loaded file is XML
- text: Specifies the file is loaded as a text config
- This supports the junos formatted file or a series of CLI set/delete commands
- If the loaded file is a series of set/delete commands the action MUST be set to "set"
Successfully loaded config:
root@device> op config-loader action set format text source http://172.16.237.1:8080/testconfig.set
Opening candidate configuration
Loading new configuration
Commiting candidate configuration
Error fetching config:
rroot@device> op config-loader action set format text source http://172.16.237.1:8080/testconfig.bad
Opening candidate configuration
Loading new configuration
Error fetching config
fetch: http://172.16.237.1:*: Not Found
Included in the repository under the tests/ folder is a series of test cases that can be used to test the tool