Variable Groups
Variable Groups are a powerful feature in CloudRay that lets you define and manage sets of variables for use in your script templates. By leveraging variable groups, you can:
- 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 and Managing Variable Groups
-
Navigate to “Variable Groups”: Click on the “Variable Groups” tab in the CloudRay interface.
-
Click “Add Variable Group”: Start creating a new variable group.
-
Enter Details:
- 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.
- Key: Enter the name of the variable (e.g.,
-
Save Variable Group: Click “Save Variable Group” to store your newly created group.
Using Variable Groups in Scripts
- Create a Runlog: When you create a new Runlog to execute a script, you’ll have the option to select a Variable Group.
- 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 }}