Configuration Variables
Variables are used to define configuration parameters which can be applied to various entities. Such as Servers, Commands, Files, and File Templates.
Danger
Storing sensitive data (eg GitHub tokens) in variable values may expose that data in command preview and logs. Use Secrets for storing such data instead.
Access Rules
Group | Action | Condition |
---|---|---|
User | R | Access level is "User" |
Manager | R | Access level is "Manager" or less |
Manager | CRU | Access level is "Manager" and record is created by user |
Root | CRUD | Any record |
Info
CRUD stands for Create, Read, Update, Delete.
Variable Configuration
Variables are located under the Cetmix Tower > Settings > Variables
menu.
Fields
Field | Description |
---|---|
Name | A readable name for the variable. |
Reference | A unique identifier for addressing the variable in conditions and expressions. Also used for YAML export/import. Leave blank to auto-generate based on the name. |
Access Level | Minimum access level required to access this Variable. |
Type | Variable type. |
Validation Pattern | Regex pattern to validate the variable value. |
Validation Message | Custom message to display if the variable value validation fails. The default message will be used if not set. |
Note | Additional notes or comments about the variable. |
Tabs
Tab | Description |
---|---|
Values | Values of the variable. Check Variable Applicability for more details. |
Value Modifier | Python code used to modify the variable value. Check Value Modifier for more details. |
Buttons
There are several clickable smart buttons located in the top of the form.
Button | Description |
---|---|
Values | Values of the variable. Opens value list when clicked. |
Commands | Commands that use this variable. Opens command list when clicked. |
Files | Files that use this variable. Opens file list when clicked. |
File Templates | File Templates that use this variable. Opens file template list when clicked. |
Used in Values | Another variables that use this variable in their values. Opens variable list when clicked. |
Value Modifier
Python code that is used to modify the variable values.
Available variables and functions:
value
: variable valueresult
: final result that will be used as a variable valuegeneral python functions (eg. lower(), replace(), etc.)
re: regex operations (eg. re.sub, re.match, etc.)
Example:
if value.startswith('http'):
result = value.lower().strip().replace('_', '-').replace(" ","")
else:
result = 'https://' + re.sub(r'\s+', '', value)
Info
Value modifier is applied after the variable value is rendered in the code. So it doesn't affect the way value is displayed in the UI.
Variable Types
Type | Description |
---|---|
String | A string of characters. |
Options | Pre-defined list of values. Name is displayed in the dropdown. Value is assigned as a variable value. |
Variable Applicability
Variables can be used in the following entities:
Used for rendering command code:
ls -lh {{ file_store_location }}
url = "https://api.hetzner.cloud/"+{{ hetzner_api_version }}+"/servers"
- Files and File Templates
Used for rendering file content:
FROM {{ os_image }}:{{ os_version }}
ARG ODOO_VERSION={{ odoo_default_version }}
Used for to set the corresponding Server configuration value when this action is triggered:
- Other Variables
Used to compose complex values that can include other variables:
Variable: Root Location
Value: /opt/cetmix_tower
Variable: Log File Location
Value: {{ root_location }}/logs
Variable Values
Variable Value Access Rules
Variables values access rules can be configured separately for each variable value. By default, each variable value inherits access rules from the variable.
Warning
Variable value access level must be same or higher than the variable access level.
For example, if a variable has access level Manager
, its values can have access level Manager
or Root
but can't have access level User
.
Group | Action | Condition |
---|---|---|
User | R | Access level is "User" and value is global |
User | R | Access level is "User" and user is added in "Users" in related Server |
User | R | Access level is "User" and user is added in "Users" in related Flight Plan |
User | R | Access level is "User" and user is added in "Users" in related Flight Plan Server |
Manager | R | Access level is "Manager" or less and value is global |
Manager | R | Access level is "Manager" or less and user is added in "Users" or "Managers" in related Server |
Manager | R | Access level is "Manager" or less and user is added in "Users" or "Managers" in related Server Template |
Manager | R | Access level is "Manager" or less and user is added in "Users" or "Managers" in related Flight Plan |
Manager | R | Access level is "Manager" or less and user is added in "Users" or "Managers" in Server the Flight Plan Action belongs to |
Manager | CRU | Access level is "Manager" or less and user is added in "Managers" in related Server |
Manager | CRU | Access level is "Manager" or less and user is added in "Managers" in related Server Template |
Manager | CRU | Access level is "Manager" or less and user is added in "Managers" in related Flight Plan |
Manager | CRU | Access level is "Manager" or less and user is added in "Managers" in Server the Flight Plan Action belongs to |
Manager | CRUD | Access level is "Manager" or less and user is added in "Managers" in related Server and record is created by user |
Manager | CRUD | Access level is "Manager" or less and user is added in "Managers" in related Server Template and record is created by user |
Manager | CRUD | Access level is "Manager" or less and user is added in "Managers" in related Flight Plan and record is created by user |
Manager | CRUD | Access level is "Manager" or less and user is added in "Managers" in Server the Flight Plan Action belongs to and record is created by user |
Root | CRUD | Any record |
Info
Read+Write+Create+Delete stands for Read, Write, Create, Delete.
Variable Value Rendering
Cetmix Tower uses jinja2
for variable rendering. This means that any jinja2
supported expressions can be used.
Here is an example of a command with if else
statements:
docker run -d -p {{ odoo_port }}:8069 \
{% if odoo_longpolling_port and odoo_longpolling_port != '0' and odoo_workers and odoo_workers != '0' %}
-p {{ odoo_longpolling_port }}:8072 \
{% endif %}
-v {{ odoo_data }}:/var/lib/odoo \
{% if odoo_config_location %}
-v {{ odoo_config_location }}:/etc/odoo \
{% endif %}
Variable Rendering Modes
There are two rendering modes available:
- Generic (or ssh) mode. This is the default mode. It is used for rendering variables in SSH Commands, Files and File Templates.
- Pythonic mode. This mode is used for rendering variables in Commands that run Python code.
Let use the following code as example:
current_branch={{ branch }}
current_version={{ package_version }}
need_update={{ update_available }}
where branch
is main
, package_version
is 0.12
and update_available
is False
Generic Mode
Default mode which renders variable values "as is". It is done in order to keep compatibility with any code interpreter which may be used to run a command. The code from example will be rendered the following way:
current_branch=main
current_version=0.12
need_update=False
Pythonic Mode
This mode is used in commands that run Python code (Action: Execute Python code
).
In this mode all variable values except Boolean and None are enclosed in double quotes.
The code from example will be rendered the following way:
current_branch="main"
current_version="0.12"
need_update=False
The tower
System Variable
The special tower
variable can be used to access some system parameters and helper tools:
Server properties
tower.server.name
Current server nametower.server.reference
Current server referencetower.server.username
Current server SSH Usernametower.server.partner_name
Current server partner nametower.server.ipv4
Current server IPv4 Addresstower.server.ipv6
Current server IPv6 Addresstower.server.status
Current server statustower.server.os
Current server operating systemtower.server.url
Current server URL
Helper tools
tower.tools.uuid
Generates a random UUID4tower.tools.today
Current date, eg2025-02-28
(default format)tower.tools.now
Current date time, eg2025-02-28 21:58:31
(default format)tower.tools.today_underscore
Current date with underscores as separators, eg2025_02_28
tower.tools.now_underscore
Current date time with underscores as separators, eg2025_02_28_21_58_31
Warning
Do not redefine the tower
variable unless you really need that on purpose.
YAML Format Specification
Variable
String
type Variable
cetmix_tower_model: variable
access_level: manager # Access level required to access the variable. Possible values: user, manager, root
reference: instance_root # Unique identifier for addressing the variable in conditions and expressions. Leave blank to auto-generate based on the name.
name: Instance Root # Readable name of the variable
variable_type: s # Variable type. Possible values: s for string, o for options
option_ids: false # List of Options or Option objects. Used only for the 'o' variable type.
applied_expression: result = value.lower().strip().replace('_', '-').replace(" ","").replace("https://","").replace("http://","") # Python code to modify the variable value
validation_pattern: ^((\/|^)([\w\-\.]*|\{\{[^{}]+\}\}|{%\s*(if|else|endif)\b[^%]*?%\})+)+$ # Regex pattern to validate the variable value
validation_message: Must be a valid path. Can include variables. # Custom message to display if the variable value validation fails. The default message will be used if not set.
note: Root location of the instance files. # Additional notes or comments about the variable.
Options
type Variable
cetmix_tower_model: variable
access_level: manager # Access level required to access the variable. Possible values: user, manager, root
reference: odoo_version # Unique identifier for addressing the variable in conditions and expressions. Leave blank to auto-generate based on the name.
name: Odoo Version # Readable name of the variable
variable_type: o # Variable type. Possible values: "s" for string, "o" for options
option_ids: # List of Options or Option objects. Used only for the "o" variable type.
- odoo_version_variable_option_8 # Option reference or Option object.
- odoo_version_variable_option_7 # Option reference or Option object.
- odoo_version_variable_option_6 # Option reference or Option object.
- odoo_version_variable_option_5 # Option reference or Option object.
- odoo_version_variable_option_4 # Option reference or Option object.
- odoo_version_variable_option_3 # Option reference or Option object.
applied_expression: false # Python code to modify the variable value
validation_pattern: false # Regex pattern to validate the variable value
validation_message: false # Custom message to display if the variable value validation fails. The default message will be used if not set.
note: Odoo version variable
Variable Option
cetmix_tower_model: variable_option
reference: odoo_version_variable_option_8 # Unique identifier for addressing the variable in conditions and expressions. Leave blank to auto-generate based on the name.
sequence: 10 # Sequence of the option. Used to sort the options. Lower values are displayed first.
access_level: manager # Access level required to access the variable. Possible values: user, manager, root
name: 'Odoo 18.0' # Readable name of the option
value_char: '18.0' # Value of the option
Variable Value
cetmix_tower_model: variable_value
reference: instance_root_variable_value_1_8 # Unique identifier for addressing the variable in conditions and expressions. Leave blank to auto-generate based on the name.
access_level: root # Access level required to access the variable. Possible values: user, manager, root
variable_id: instance_root # Variable reference or Variable object. Variable the value belongs to.
variable_ids: # List of Variables or Variable objects. Variables used in the variable value.
- tower_root # Variable reference or Variable object.
value_char: {{ tower_root }}/odoo # Value of the option
required: true # Boolean. If true, the variable value is required. Used only in Server Templates.
Please refer to the General YAML Format Specification for more details.