Skip to content

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 (e.g. GitHub tokens) in variable values may expose that data in command preview and logs. Use Secrets for storing such data instead.

Variable vs Variable Value

Variable — defines metadata (name, reference, type, validation). Has no value field. Variable Value — stores actual values (value_char) in context. Use variable_value_ids on jet_template, server_template, server, or jet; or use variable_value records not linked to any entity for global values.

Access Rules

Group Action Condition
User R Variable access level is "User"
Manager R Variable access level is "Manager" or less
Manager CRU Variable access level is "Manager" or less and record is created by user (Managers cannot delete Variables)
Root CRUD Any record

Info

CRUD stands for Create, Read, Update, Delete.

Variable Configuration

Variables are located under the Cetmix Tower > Settings > Variables menu.

Variable List

Fields

Variable Form

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.

Variable 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 Other 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.

Variable Form Modifier

Available variables and functions:

  • value: variable value
  • result: final result that will be used as a variable value
  • general python functions (e.g. lower(), replace(), etc.)
  • re: regex operations (e.g. 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 Form Options

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"

Used for rendering file content:

FROM {{ os_image }}:{{ os_version }}
ARG ODOO_VERSION={{ odoo_default_version }}

Used to set the corresponding Server configuration value when this action is triggered:

Flight Plans Line Action

  • 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
User R Access level is "User" and user is added in "Users" in related Jet
User R Access level is "User" and user is added in "Users" in related Jet Template
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 R Access level is "Manager" or less and user is added in "Users" or "Managers" in related Jet
Manager R Access level is "Manager" or less and user is added in "Users" or "Managers" in related Jet Template
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 CRU Access level is "Manager" or less and user is added in "Managers" in related Jet
Manager CRU Access level is "Manager" or less and user is added in "Managers" in related Jet Template
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
Manager CRUD Access level is "Manager" or less and user is added in "Managers" in related Jet and record is created by user
Manager CRUD Access level is "Manager" or less and user is added in "Managers" in related Jet Template 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.

Use the following code as an 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 system parameters and helper tools in variable values and templates. It uses the format tower.<provider>.<property>. Not all providers are available in every context—which ones are filled depends on where the variable is being resolved (e.g. on a Server, on a Jet, in a Flight Plan, or in a File). Servers and Jets also have a metadata field (JSON); in Python code commands you can read and write it via server.metadata / jet.metadata and server.update_metadata({...}) / jet.update_metadata({...}).

When each provider is available:

Context tower.server tower.jet_template tower.jet tower.tools
Variable resolution on a server (e.g. running a command on a server, server variable value, run-command wizard with server only) Yes No No Yes
Variable resolution on a jet template only (e.g. getting a variable value for a jet template without a server) No Yes No Yes
Variable resolution in a jet context (e.g. command or flight plan run on a jet, jet variable value, waypoint plans) Yes (from jet's server) Yes (from jet's template) Yes Yes
Files and file templates Yes if linked to a server Yes if linked to a jet template Yes if linked to a jet Yes

In templates, reference only the providers that exist in your context (e.g. in a server-only command use tower.server.* and tower.tools.*; in a jet flight plan you can use all four). Missing providers are empty dicts, so e.g. tower.jet.name would not be available when running a server-only command.

Server properties (tower.server)

Available when resolving variables in a server (or jet) context:

  • tower.server.name — Current server name
  • tower.server.reference — Current server reference
  • tower.server.username — Current server SSH username
  • tower.server.partner_name — Current server partner name
  • tower.server.ipv4 — Current server IPv4 address
  • tower.server.ipv6 — Current server IPv6 address
  • tower.server.status — Current server status
  • tower.server.os — Current server operating system
  • tower.server.url — Current server URL
  • tower.server.hostname — Hostname from server URL (if URL is set)
  • tower.server.netloc — Network location from server URL (if URL is set)
  • tower.server.port — Port from server URL (if URL is set)

Jet template properties (tower.jet_template)

Available when resolving variables in a jet (or jet template) context:

  • tower.jet_template.name — Current jet template name
  • tower.jet_template.reference — Current jet template reference

Jet properties (tower.jet)

Available when resolving variables in a jet context:

  • tower.jet.name — Current jet name
  • tower.jet.reference — Current jet reference
  • tower.jet.url — Current jet URL
  • tower.jet.state — Current jet state
  • tower.jet.cloned_from — Reference of the jet this one was cloned from (or false)
  • tower.jet.hostname — Hostname from jet URL (if URL is set)
  • tower.jet.netloc — Network location from jet URL (if URL is set)
  • tower.jet.port — Port from jet URL (if URL is set)
  • tower.jet.waypoint.reference — Current waypoint reference (or false)
  • tower.jet.waypoint.type — Current waypoint template reference (or false)
  • tower.jet.waypoint.<key> — Waypoint metadata values (each metadata key is exposed as a property)

Helper tools (tower.tools)

Always available:

  • tower.tools.uuid — Generates a random UUID4
  • tower.tools.today — Current date, e.g. 2025-02-28 (default format)
  • tower.tools.now — Current date/time, e.g. 2025-02-28 21:58:31 (default format)
  • tower.tools.today_underscore — Current date with underscores as separators, e.g. 2025_02_28
  • tower.tools.now_underscore — Current date/time with underscores as separators, e.g. 2025_02_28_21_58_31

Warning

Do not redefine the tower variable unless you really need that on purpose.

YAML Format Specification

Variable

Variable has no value field

Do not use default_value_char on the variable model — it does not exist. Use variable_value records (with variable_id + value_char) via variable_value_ids on jet_template, server_template, server, or jet; or use variable_value records not linked to any entity for global values.

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.