Skip to content

rConfig - Snippets

1 mins V7 Pro

Snippets are short configurations that can be used to configure your devices either individually or in bulk. They are a great way to save time and ensure that your configurations are consistent across your devices.

From V7, we have add some new features to snippets. First, you can send a snippet to a device, from the devices page. This is a great way to test a configuration on a single device, before sending it to all devices. Second, roles are applied to snippets. This means that you can control who can see and use snippets, and who can edit and delete them. Last, you can parameterize snippets. This means that you can add variables to your snippets, and then use them in your configurations.

Introducing Seamless SSO: rConfig's New Okta Integration!

Check out the tutorial video above.

Adding/ Editing Vendors

From the main Snippets view, click New Snippet to add a new snippet, or click the edit button in the table.

Snippets Main View

The snippet form itself is very simple. You can add a snippet name, and a description for the snippet, and then add the snippet configuration. The snippet configuration is a free text field. Add lines as if you were manually typing in the configuration i.e. include ‘conf t’ to start a new configuration section, if on Cisco devices. You will notice the roles options at the bottom of the form. This is where you can apply roles to the snippet. Roles are retired from the main roles view. Simply, if you account is a member of the role, you can see the snippet. The system-wide default ‘admin’ role is applied to all snippets by default, and this cannot be removed.

You may also adjust roles for snippets from the main table. See screenshot below.

Snippets Role Assign

Parameterized Snippets

You can not add arbitrary variables to your snippets. This is a great way to make your snippets more flexible. For example, you can add a variable for the hostname of a device, and then use that variable in your configuration. To add a variable, simply add a variable name in the format of {variable_name} to your snippet. You can then use this variable in your configuration. When you send the snippet to a device, you will be prompted to enter the value for the variable.

Parameterized snippets

Send snippets to individual devices

You can send individual snippets to devices from the devices page. Simply click the ‘Send Snippet’ button on the device row, and select the snippet you want to send. You will be prompted to enter the value for any variables in the snippet, if the snippet is parameterized.

Select snippet snippets

Select your parameters and click ‘Send Snippet’. The snippet will be sent to the device, and you will be redirected to the device page. You can see the output of the snippet in the devices configs table. See section below for more information on parameterized snippets.

Select snippet snippets

Sending snippets in bulk

The most effective way to send snippets in bulk to multiple up to 100s or 1000s of devices is via a scheduled task. You can create a task of type ‘Send Snippet’ and select the snippet you want to send. You can then select the devices, categories or tags you want to send the snippet to. The recommendation is to set the snippet schedule to something like once a year, if this is a one off job such as updating device firmware. Then you can delete the task after you run it manually.

Snippets parameters and instuctions

Parameters

As of 7.0.5 you can add paramters to snippets. Parameters allow you to add variables to your snippets, that can be used later when sending the snippet to a device. To add a parameter simpley add a parameter name in the format of {parameter_name} to your snippet. The paramter then can be used in your configuration when sending the snippet to individual devices.

Example parameterized snippet

Terminal window
conf t
interface {Interface ID}/{Port}
desc {Enter a Description}
switchport access {VLAN ID}
end
do wr mem
Send Parameterized snippet from device page.

As you can see from the screenshot, when you parameterize your snippet, you will be prompted to enter the value for the parameter.

Instructions

As of 7.0.9 you can add instructions to snippets. This means, you can alter the order of operations in your snippet configuration. This is useful if you need to slow down, or speed up certain steps in your configuration.

The first supported instructions are sleep and config_prompt. Instructions must be entered in the format of #[instruction_name instruction_value].

Sleep

The sleep instruction allows you to pause the snippet for a specified number of seconds, and mutliple times if required. Example:

#[config_prompt router1(config)#]
conf t
snmp-server host 3.3.3.3 TESTCOMMUNITY300
#[sleep 3]
no snmp-server host 3.3.3.3 TESTCOMMUNITY300
snmp-server host 4.4.4.4 TESTCOMMUNITY400
#[sleep 4]
no snmp-server host 4.4.4.4 TESTCOMMUNITY400
snmp-server host 5.5.5.5 TESTCOMMUNITY500
#[sleep 5]
no snmp-server host 5.5.5.5 TESTCOMMUNITY500
exit
wr mem
exit

Config Prompt

The config_prompt instruction allows you to change the prompt of the device when in config mode. This will help speed up your configuration deployment as the devices main prompt as configured in device settings is not always correct when entering config mode on network devices. This instruction gives your more felxibility. The instruction must be entered in the format of #[config_prompt new_prompt]. Please note any special characters that might intefere with regexp operation are automatically escaped.

Role based access to Snippets

As of V7.0.8 there is a new feature to allow role based access to snippets. This feature is enabled by default, and the system admin role has access to all snippets. This is hardcoded and cannot be changed.

Troubleshooting Device RBAC

If any issues are encountered with the device RBAC feature, you can run the following command to update the device roles to Update all devices to ensure they at least have admin have roles attached to them.

php artisan rconfig:update-snippet-roles