How to Use Variables in Configuration Jobs on NetScaler MAS

A configuration job is a set of configuration commands that you can execute on one or more managed instances. When you execute the same configuration on multiple instances, you might want to use different values for the parameters used in your configuration. You can define variables that enable you to assign different values for these parameters or execute a job across multiple instances.

For example, consider a basic load balancing configuration where you add a load balancing virtual server, add two services, and bind the services to the virtual server. Now, you might want to have the same configuration on two instances but with different values for the virtual server and services names and IP addresses. You can use the configuration jobs feature to achieve this by using variables to define the names and IP addresses of the virtual server and services.

In this example, the following commands and variables are used:

add lb vserver **servername** HTTP **ipaddress** **portnumber**

add service **servicename1** **ipaddress1** HTTP 80

add service **servicename2** **ipaddress2** HTTP 80

bind lb vserver **servername** **servicename1**

bind lb vserver **servername** **servicename2**

To create a configuration job by defining variables in NetScaler MAS:

  1. Navigate to Networks > Configuration Jobs.

  2. Click Create Job.

  3. On the Create Job page, select the custom job parameters such as the name of the job, the instance type, and the configuration type.

  4. In the Configuration Editor, type in the commands to add a load balancing virtual server, two services, and bind the services to the virtual server. Double click to select the values that you want to convert to a variable, and then click Convert to Variable. For example, select the IP address of the load balancing server ipaddress, and click Convert to Variable as shown in the image below.

    localized image

  5. Once you see dollar signs enclose the variable’s value, click on the variable to further specify the details of the variable such as name, display name, and type. You can also click the Advanced option if you want to further specify a default value for your variable. Click Save and then, click Next.

    localized image

    Type in the rest of your commands and define all the variables.

    localized image

  6. You can review all the variables that you have defined while creating or editing a configuration job in a single consolidated view.

  7. Do one of the following to view all the variables in a single consolidated view:

    • While creating a configuration job, navigate to Networks > Configuration Jobs, select Create Job. On the Create Job page, you can review all the variables that you have added while creating the configuration job.

    • While editing a configuration job, navigate to Network > Configuration Jobs, select the Job Name and click Edit. On the Configure Job page, you can review all the variables that were added while creating the configuration job.

  8. You can then click on the Preview Variables tab to preview the variables in a single consolidated view that you have defined while creating or editing a configuration job.

    localized image

  9. A new pop-up window appears and displays all the parameters of variables such as Name, Display Name, Type, and default value in a tabular format. You can also edit and modify these parameters. Click the Done button after you have edited or modified any of the parameters.

    localized image

  10. You can then rearrange and reorder the commands in the configuration editor as appropriate. You can move the command from one line to another by dragging and dropping the command line. You can also move or rearrange the command line from one line to any target line by simply changing the command line number in the text box.

  11. Select the instances you want to run the configuration job on.

  12. In the Specify Variable Values tab, select the Upload input file for variable values option and then click Download Input Key File. In our example, you will need to specify the server name on each instance, the IP addresses of the server and services, port numbers, and the service names. Save the file and upload it. If your values aren’t defined accurately, the system might throw an error.

  13. The input key file is downloaded to your local system and you can edit it by specifying the variable values for each NetScaler instance you’ve selected previously and click Upload to upload the input key file to NetScaler MAS. Click Next. The input key file downloads to your local system and you can edit it by specifying the variable values for each NetScaler instance that you have selected previously.

    Note: In the input key file, the variables are defined at three levels:

    • Global level

    • Instance-group level

    • Instance level

    Global variables are variable values that are applied across all instances. Instance group level variable values are applied to all instances that are defined in a group. Instance level variable values are only applied to a specific instance.

    NetScaler MAS gives first priority to instance level values. If there are no values provided to the variables for individual instances, NetScaler MAS uses the value provided at the group level. If there are no values provided at group level, NetScaler MAS uses the variable value provided at the global level. If you provide an input for a variable across all three levels, NetScaler MAS uses the instance level value as the default value.

  14. Click Upload to upload the input key file to NetScaler MAS. Click Next.

    localized image

    Important

    When you upload a CSV file from a Mac, Mac stores the CSV file with semicolons instead of commas. This will cause the configuration to fail when you upload the input file and run the job. If you are using a Mac, use a text editor to make the necessary changes and then upload the file.

  15. You can also give common variable values across all instances and click Upload to upload the input key file to NetScaler MAS.

    The key input files containing the variables values are persisted (with the same file name) in the configuration jobs. You can view and edit these input files that you have used and uploaded earlier while creating or editing the configuration jobs.

    To view the executed configuration jobs while creating a configuration job, navigate to Network > Configuration Jobs, and click Create Job. In the Create Job page. On the Specify Variable Values tab, select the Common Variable Values for all Instances option to view the uploaded files. To edit the input files, download the input file and then edit and upload the files (keeping the same file name).

    To view the already executed configuration jobs while editing a configuration job, navigate to Network > Configuration Jobs, select the Job Name and click Edit. In the Configure Job page, on the Specify Variable Values tab, select the Common Variable Values for all Instances option to view the uploaded files. To edit the input files, download the input file and then edit and upload the files (keeping the same file name).

  16. On the Job Preview tab, you can evaluate and verify the commands to be run on each instance or instance group.

  17. In the Execute tab, you can choose to execute your job now or schedule it to be executed at a later time. You can also choose what action NetScaler MAS should take if the command fails and if you’d like to send an Email notification regarding the success or failure of the job along with other details.

    localized image

    After configuring your jobs and executing it, you can see the job details by navigating to Networks > Configuration Jobs and select the job you just configured.  Click on Details and then, click on Variable Details to see the list of variables added to your job.

    localized image

    Note

    The values that you have provided for the variables in step 5 are retained by NetScaler MAS when you save the job and exit, or when you schedule a job to be run at a later point of time.

How to Use Variables in Configuration Jobs on NetScaler MAS

In this article