Skip to main content
Inject Strigo context into your labs and exercises

How to leverage Strigo's variable interpolation to provide context to your labs and exercises.

Nir Cohen avatar
Written by Nir Cohen
Updated over 10 months ago

Let's say that you're teaching a class on how to build websites using (the notoriously unknown and hypothetical) https://how-to-build-websites.com. When the class begins and the students join, you may want each of their labs to spin up, running a browser that's pointing at their users' accounts at https://how-to-build-websites.com, using the URL https://how-to-build-websites.com?user=STUDENT_EMAIL_HERE.

Strigo provides a way for you to inject the student's email directly into the lab's provisioning script (using userdata) or into lab exercises.

To accommodate the example mentioned above, you could configure your lab to run the following script on a Linux Desktop, which will, in turn, run Chrome in Kiosk Mode and display the URL shown above.

You can inject different types of context to accommodate different needs, depending on how you want your student's labs to be configured.

Variable Format

We try to be as unintrusive as possible when using variables in scripts, and so we use a specifically compiled variable interpolation format: {{ .STRIGO_VAR_NAME }}.

  • The prefix must be {{ .STRIGO_

  • The suffix must be }}

Note the space after the {{ and before the }}.

Variable Reference:

Note: All of the variables below are available for both exercises and userdata scripts, with the exception of STRIGO_RESOURCE_NAME and STRIGO_RESOURCE_DNS not being available in exercises.

  • STRIGO_EVENT_ID => The unique identifier of the event.

  • STRIGO_ENROLLMENT_ID => The unique identifier of the enrollment (for on-demand enrollments only).

  • STRIGO_EVENT_NAME => The name of the event as you've defined it.

  • STRIGO_CLASS_ID => The unique identifier of the class.

  • STRIGO_CLASS_NAME => The name of the class as you've defined it.

  • STRIGO_USER_ID => The unique identifier of the user.

  • STRIGO_USER_EMAIL => The email of the currently logged-in user.

  • STRIGO_USER_NAME => The name of the currently logged-in user.

  • STRIGO_ORG_ID => The unique identifier of your organization.

  • STRIGO_ORG_NAME => The name of your training organization.

  • STRIGO_PARTNER_ID => The unique identifier of your training partner.

  • STRIGO_PARTNER_NAME => The name of your training partner.

  • STRIGO_WORKSPACE_ID => The unique identifier of the current workspace.

  • STRIGO_WORKSPACE_FLAVOR => The type of the current workspace (Can be ondemand or event).

  • STRIGO_RESOURCE_NAME => The name of the current lab resource (as defined in the class template).

  • STRIGO_RESOURCE_DNS => The Dynamic DNS address of the current lab resource (as defined in the class template).

  • STRIGO_EVENT_HOST_EMAIL => The email of the current host of the event.

Note: STRIGO_PARTNER_ID, STRIGO_PARTNER_NAME and STRIGO_EVENT_HOST_EMAIL are only relevant for ILT (they will be undefined in on-demand).

In addition, the following variables are exposed in each lab for every lab in the class:

  • STRIGO_RESOURCE_#_ID => The unique identifier for the lab resource.

  • STRIGO_RESOURCE_#_NAME => The name of the lab resource.

  • STRIGO_RESOURCE_#_DNS => The Strigo Dynamic DNS address for the lab resource.RESOURCE_DNS

  • STRIGO_EVENT_HOST_RESOURCE_#_DNS => The event host's lab resource Dynamic DNS address.

  • STRIGO_RESOURCE_#_WEB_INTERFACE_#_NAME => The lab resource's Web interface names.

  • STRIGO_RESOURCE_#_WEB_INTERFACE_#_URL => The lab resource's Web interface Urls.

  • STRIGO_RESOURCE_#_WEB_INTERFACE_#_ID => The lab resource's Web interface IDs.

# is the number of the lab (starting from 0), as per the order of the resources in the class template. So, for example, if you have two resources, the first one named My Nice Lab, and the other named My Other Nice Lab, you'll be able to do something like the following in each resource:

# Exporting resource details to env variables
export STRIGO_RESOURCE_0_ID="{{ .STRIGO_RESOURCE_0_ID }}"
export STRIGO_RESOURCE_0_NAME="{{ .STRIGO_RESOURCE_0_NAME }}"
export STRIGO_RESOURCE_0_DNS="{{ .STRIGO_RESOURCE_0_DNS }}"
export STRIGO_RESOURCE_1_ID="{{ .STRIGO_RESOURCE_1_ID }}"
export STRIGO_RESOURCE_1_NAME="{{ .STRIGO_RESOURCE_1_NAME }}"
export STRIGO_RESOURCE_1_DNS="{{ .STRIGO_RESOURCE_1_DNS }}"

# Exporting web interface IDs to env variables
export STRIGO_RESOURCE_0_WEB_INTERFACE_0_ID="{{ .STRIGO_RESOURCE_0_WEB_INTERFACE_0_ID }}"
export STRIGO_RESOURCE_0_WEB_INTERFACE_1_ID="{{ .STRIGO_RESOURCE_0_WEB_INTERFACE_1_ID }}"

Security and Privacy

It is important to emphasize:

  • Strigo does not inject any context beyond what's explicitly specified in the script, thus making data exposure very explicit.

  • Additionally, the interpolation is done server-side, before reaching the lab, and so no information is sent to the users' browsers.

Example deployment script:

Below is an example for a script (specifically for Linux, but can be modified for a Windows script just as well) with the exhaustive list of variables you can use:

#!/bin/bash

cat <<EOF >> ~/.bashrc
export STRIGO_EVENT_ID="{{ .STRIGO_EVENT_ID }}"
export STRIGO_EVENT_NAME="{{ .STRIGO_EVENT_NAME }}"
export STRIGO_CLASS_ID="{{ .STRIGO_CLASS_ID }}"
export STRIGO_CLASS_NAME="{{ .STRIGO_CLASS_NAME }}"
export STRIGO_USER_ID="{{ .STRIGO_USER_ID }}"
export STRIGO_USER_EMAIL="{{ .STRIGO_USER_EMAIL }}"
export STRIGO_USER_NAME="{{ .STRIGO_USER_NAME }}"
export STRIGO_ORG_ID="{{ .STRIGO_ORG_ID }}"
export STRIGO_ORG_NAME="{{ .STRIGO_ORG_NAME }}"
export STRIGO_PARTNER_ID="{{ .STRIGO_PARTNER_ID }}"
export STRIGO_PARTNER_NAME="{{ .STRIGO_PARTNER_NAME }}"
export STRIGO_WORKSPACE_ID="{{ .STRIGO_WORKSPACE_ID }}"
export STRIGO_WORKSPACE_FLAVOR="{{ .STRIGO_WORKSPACE_FLAVOR }}"
export STRIGO_RESOURCE_NAME="{{ .STRIGO_RESOURCE_NAME }}"
export STRIGO_RESOURCE_DNS="{{ .STRIGO_RESOURCE_DNS }}"
export STRIGO_EVENT_HOST_EMAIL="{{ .STRIGO_EVENT_HOST_EMAIL }}"
export STRIGO_RESOURCE_0_ID="{{ .STRIGO_RESOURCE_0_ID }}"
export STRIGO_RESOURCE_0_NAME="{{ .STRIGO_RESOURCE_0_NAME }}"
export STRIGO_RESOURCE_0_DNS="{{ .STRIGO_RESOURCE_0_DNS }}"
export STRIGO_RESOURCE_1_ID="{{ .STRIGO_RESOURCE_1_ID }}"
export STRIGO_RESOURCE_1_NAME="{{ .STRIGO_RESOURCE_1_NAME }}"
export STRIGO_RESOURCE_1_DNS="{{ .STRIGO_RESOURCE_1_DNS }}"
export STRIGO_EVENT_HOST_RESOURCE_0_DNS="{{ .STRIGO_EVENT_HOST_RESOURCE_0_DNS }}"
export STRIGO_EVENT_HOST_RESOURCE_1_DNS="{{ .STRIGO_EVENT_HOST_RESOURCE_1_DNS }}"
export STRIGO_RESOURCE_0_WEB_INTERFACE_0_ID="{{ .STRIGO_RESOURCE_0_WEB_INTERFACE_0_ID }}"
export STRIGO_RESOURCE_0_WEB_INTERFACE_1_ID="{{ .STRIGO_RESOURCE_0_WEB_INTERFACE_1_ID }}"
EOF

Notes:

  1. This is just an example. You can use the variables in whichever way you want.

  2. This example just assumes there are two Resources in the Lab, hence the variables for RESOURCE_0 and RESOURCE_1. Again, this is just an example and depends on the number of Resources you have in the Lab.

Did this answer your question?