Assign Variables

What does Assign Variables do?

At the beginning of a Prog command, you may wish to assign variables which you can reference multiple times later on in the script.

This makes it easy to update values that may be repetitive across multiple subsequent steps.

Examples:

  • IP addresses
  • Usernames
  • Password
  • Environment variables

For example, let’s say you’re creating a Prog which executes a series of remote commands. That directive requires you to define each time you use it the server IP address, port, username, and password (or SSH key).

By using the Assign Variables directive at the beginning, you can define each of these variables like so:

Our definition “name” Assigned “value” How it is “referenced”
ip_address 1.2.3.4 {{ ip_address }}
port 22 {{ port }}
username root {{ username }}
password secret! {{ password }}

Again, when the value is referenced, we use Liquid template format syntax to reference it. Proggy will automatically substitute the correct values for you when it sees the curly braces.

How do I use the Assign Variables directive?

Add the Assign Variables directive step. In order for the variables to be available for the entirety of the Prog, you must move this step to the beginning of the Prog order.

For convenience, you can specify multiple variables within a single step:

Assign variables settings
We can assign any arbitrary variables using the Assign Variable directive

Behaviour of the Assign Key/Value Pair directive

  • If you have another Assign Variables directive later, and it specifies the same variable name, the earlier directive’s definition for that name will be overwritten.
  • Definitions defined in Runtime Variables take precendence over any and all Assign Variables directives.
  • If no variables are specified, the step will skip but your Prog command will not terminate.

Example use cases for the Assign Key/Value Pair directive

  • To organize variable values at the start of Prog commands
  • For assigning default variable values