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.

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

Variable List

To configure a variable navigate to the Cetmix Tower > Settings > Variables menu and click Create.

Fields

Field Description
Name A readable name for the variable.
Reference A unique identifier for addressing the variable in conditions and expressions. Leave blank to auto-generate based on the name.
Note Additional notes or comments about the variable.

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 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
  • Helper tools:

    • tower.tools.uuid Generates a random UUID4
    • tower.tools.today Current date
    • tower.tools.now Current date time

Warning

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