Skip to content

Tag: <preamble_task> - Preamble Task Definition

Definition

The <preamble_task> tag can be used in two places. Firstly, under the <proxy_parameters> tag it can be used to define commands that are run after a connection to a device is established but before a system task is run, i.e. user_add. Here it is used to put a device into a more scripting friendly mode: turning of pagination of results, tell the device not to line wrap, etc.

Secondly, the <preamble_task> tag can be used under <proxy_parameters> tag to define commands that are to be run before the connection is passed to the user. A typical example of this might be elevating a user role using an enable mode command.

The tag has the following attributes:

Parameters

  • Name (str) : This is the internal name of the task. This for legacy reasons the name of the task is 1.

The <preamble_task> tag contains a single <commands> tag, which can then contain multiple <command> tags. Any operation that can be done in a user task can be done in a preamble task.

Example: Putting a device into a scripting friendly mode

Here's a simple example of putting a device into a scripting friendly mode by setting the terminal length and width both to 0, meaning no limit.

Here the <preamble_task> tag is used under the <access> tag:

1
2
3
4
5
6
7
   <access type='shell' default='yes' protocol='ssh'>
      <preamble_task name='1'>
         <commands>
            <command>terminal length 0</command>
            <command>terminal width 0</command>
         </commands>
      </preamble_task>

Example: Putting a user proxy connection into admin mode

Used under the <proxy_parameters> tag, here the command block checks if the user has the admin access token and if so then runs some commandsteps to enter enable mode:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
   <proxy_parameters connection=''>
      <preamble_task name='1'>
         <commands>
            <command>
               <conditions>
                  <testEq name='accesstoken' value='admin'/>
               </conditions>
               <commandstep shellprompt='.*Password:'>enable</commandstep>
               <commandstep shellprompt='.*'>%(enable_password.0.password)s</commandstep>
               <success type='ci_match' value=''/>
               <failed type='ci_in' value='Invalid password'/>
               <failed type='default'/>
            </command>
         </commands>
      </preamble>

Parent Tags

Child Tags