Use variables in configuration jobs

A configuration job is a set of configuration commands that you can run on one or more managed instances. When you run 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 run 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 Console:

  1. Navigate to Infrastructure > 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.

  5. Once you see dollar signs enclose the variable’s value, click 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.

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

  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 Infrastructure > 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 the Preview Variables tab to preview the variables in a single consolidated view that you have defined while creating or editing a configuration job.

  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.

    Preview variables 2

  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 Console. 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 Console gives first priority to instance level values. If there are no values provided to the variables for individual instances, NetScaler Console uses the value provided at the group level. If there are no values provided at group level, NetScaler Console uses the variable value provided at the global level. If you provide an input for a variable across all three levels, NetScaler Console uses the instance level value as the default value.

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

    Upload key file

    Important

    When you upload a CSV file from a Mac, the 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 Console.

    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 run 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 run 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 run your job now or schedule it to be run at a later time. You can also choose what action NetScaler Console must 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.

    Schedule job

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

Note

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

Use variables in configuration jobs

In this article