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** <!--NeedCopy-->
To create a configuration job by defining variables in Citrix ADM:
Navigate to Infrastructure > Configuration > Configuration Jobs.
Click Create Job.
On the Create Job page, select the custom job parameters such as the name of the job, the instance type, and the configuration type.
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.
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.
You can review all the variables that you have defined while creating or editing a configuration job in a single consolidated view.
Do one of the following to view all the variables in a single consolidated view:
- While creating a configuration job, navigate to Infrastructure > Configuration > 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.
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.
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.
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.
Select the instances you want to run the configuration job on.
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.
The input key file is downloaded to your local system and you can edit it by specifying the variable values for each Citrix ADC instance you’ve selected previously and click Upload to upload the input key file to Citrix Application Delivery Management (ADM). Click Next. The input key file downloads to your local system and you can edit it by specifying the variable values for each Citrix ADC instance that you have selected previously.
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.
Citrix ADM gives first priority to instance level values. If there are no values provided to the variables for individual instances, Citrix ADM uses the value provided at the group level. If there are no values provided at group level, Citrix ADM uses the variable value provided at the global level. If you provide an input for a variable across all three levels, Citrix ADM uses the instance level value as the default value.
lick Upload to upload the input key file to Citrix ADM. Click Next.
When you upload a CSV file from a Mac, Mac stores the CSV file with semicolons instead of commas. This causes 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.
You can also give common variable values across all instances and click Upload to upload the input key file to Citrix ADM.
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).
On the Job Preview tab, you can evaluate and verify the commands to be run on each instance or instance group.
In the Execute tab, you can choose to run your job now or schedule it to be run later. You can also choose what action Citrix ADM 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.
After configuring your jobs and running it, you can see the job details by navigating to Infrastructure > Configuration > Configuration Jobs and select the job you configured. Click Details and then, click Variable Details to see the list of variables added to your job.
The values that you have provided for the variables in step 5 are retained by Citrix ADM when you save the job and exit, or when you schedule a job to be run at a later point of time.