Variable Groups in CloudRay provide a convenient way to define and manage sets of variables for use in your script templates. They help you centralise configuration, customise script behaviour, and enhance security by storing sensitive data securely.

The key benefits of Variable Groups include:

  • Customise Script Behaviour: Inject different values into your scripts based on the environment, purpose, or target server
  • Centralise Configuration: Store and manage common variables in a single location, simplifying updates and maintenance
  • Enhance Security: Avoid hardcoding sensitive information like passwords or API keys directly in your scripts

Creating Variable Group

Follow these steps to create a new variable group in CloudRay:

  1. Navigate to “Variable Groups”: Click on the “Variable Groups” tab in the CloudRay interface.
Screenshot of locating Variable group in CloudRay
  1. Click “New Script Variable Group”: Start creating a new variable group.
Screenshot of adding a new variable in CloudRay
  1. Enter Details:
Screenshot of adding a new variable in CloudRay
  • Name: Provide a descriptive name for your group (e.g., “Production Environment Variables”, “Website Deployment Settings”).
  • Variables:
    • Key: Enter the name of the variable (e.g., api_key, db_password).
    • Value: Enter the corresponding value for the variable.
    • Add More Variables: Click the ”+” button to add additional key-value pairs to your group.
  1. Save Variable Group: Click “Save Variable Group” to store your newly created group.

Managing Variable Groups

You can view, update, and delete variable groups to ensure your automation scripts stay aligned with the latest configurations.

Viewing Existing Variable Groups

Screenshot of viewing Variables in CloudRay

To check your available Variable Groups, simply click on the “Variable Groups” in the list. This will display the list of variable groups available in your account

Editing a Variable Group

If you need to modify your variable group’s details, follow these steps:

Screenshot of Editing a Variable in CloudRay
  1. Click “Edit” next to the variable you wish to update
Screenshot of Editing a Variable in CloudRay
  1. Modify the variable name, add or remove variables, or update their values
  2. Click on “Save” to save your changes

Deleting a Variable Group

  1. Find the group you want to remove
Screenshot of Editing a Variable in CloudRay
  1. Click “Delete” to delete the variable group

Using Variable Groups in Scripts

CloudRay allows you to dynamically reference variables from your groups within script templates.

  1. Create a Runlog: When you create a new Runlog to execute a script, you’ll have the option to select a Variable Group.
  2. Reference Variables in Your Script: In your script template, use the following syntax to reference variables from the selected group:

For example, if you have a variable named api_key in your group, you would reference it in your script template like this:

API_KEY={{api_key}}

This approach keeps your scripts flexible and environment-agnostic while enhancing security and maintainability.

For more details on managing and running scripts in CloudRay, refer to the Script and Runlogs docs.