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 (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.

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.
Note Additional notes or comments about the variable.
Values Values of the variable. Check Variable Applicability 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 Another variables that use this variable in their values. Opens variable list when clicked.

Variable Types

Type Description
String A string of characters.
Selection Pre-defined list of values. Name is displayed in the dropdown. Value is assigned as a variable value.

Variable Form Selection

Variable Applicability

Variables can be used in the following entities:

ls -lh {{ file_store_location }}
url = "https://api.hetzner.cloud/"+{{ hetzner_api_version }}+"/servers"
FROM {{ os_image }}:{{ os_version }}
ARG ODOO_VERSION={{ odoo_default_version }}

Flight Plans Line Action

  • Other Variables:
Variable: Root Location
Value: /opt/cetmix_tower

Variable: Log File Location
Value: {{ root_location }}/logs

Variable Value Access Rules

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 Resolution Order

Variables values are rendered in the following order:

  1. If there is a variable value defined for a Server it will be used.
  2. If there is no variable value defined for a Server Global variable value will be used. Global variable values are values without any Server selected.

Variable Value Resolution Order

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

tower. System Variable

Special tower variable can be used to access some system parameters and helper tools:

Server properties

  • 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

Helper tools

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

Warning

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