Skip to content

Cetmix Tower YAML

Cetmix Tower YAML module is the core module that implements YAML interface for Cetmix Tower.
It allows to export and import Cetmix Tower records to/from YAML files and serves as an engine for other modules, such as Cetmix Tower Git.

Video Tutorial

Here is a short video showing how to export and import data from/to Cetmix Tower using YAML files.

Installation

To use these functionalities, you must have the Cetmix Tower YAML cetmix_tower_yaml module installed. For further details, please refer to the Installing the Modules section of the documentation.

Access Rights

Special access rights are required to use YAML export/import. Please refer to the Access Rights section of the documentation for more details.

Data Export to YAML

To export a record or multiple records to YAML:

1. Open the record you want to export, switch to the YAML tab and click the Export Yaml button.

Export Yaml

Or select multiple records and click Export Yaml in the Action menu.

Export Yaml

Warning

If there is no YAML tab in the record form or Export YAML item in the Action menu, that mean that the record does not support YAML export, or user doesn't have access to the data export feature.
Also please ensure that you have refreshed the page after enabling "Export YAML" in the user settings.

2. A wizard will open where you can configure the export options.

Export Yaml Wizard

Field Description
Explode Child Records If enabled, the child records will be exported completely, including all their fields and sub-records.
If disabled, only record references will be exported.
Remove Empty x2m Values If enabled, the empty values of Many2many, One2many and Many2one fields will be removed from the YAML file. This allows to reduce the size of the YAML file and to avoid errors when importing the data.
Preview Code Preview the generated YAML code before downloading the file.
Comment Optional text that will be added in the top of the YAML file as a comment.

3. Click the Generate YAML file button. Download the file from the pop up form that opens next.

Export Yaml Result

YAML File Modification

You can modify the result YAML file before importing it. You can also combine multiple YAML files into one by adding other records to the records section.
Check the YAML File Example for a reference.

Data Import from YAML

Cetmix Tower supports complex YAML files, which can contain multiple records from different models. When importing such files, the wizard will automatically create new records for each model or update existing records if they already exist.

To import records form a YAML file:

1. Go to Cetmix Tower > Tools > Import YAML.

Import Yaml

2. Upload the YAML file and click the Process button.

Import Yaml Import Yaml

3. A wizard will open where you can configure the import options.

Import Yaml Wizard

Following options are available for the If Record Exists field:

  • Skip: Skip the record if it already exists.
  • Update existing record: Update the existing record with the new data.
  • Create a new record: Create a new record with the same reference.

Warning

Variables, Variable Options, Key/Secrets, Tags and OSs will be updated if they exist in Odoo even in the Create new record mode. This is done to maintain data consistency and avoid duplicates.

4. Click the Import button. The following action will happen based on the imported data:

  • Single record: Form view of the imported record will be opened.
  • Multiple records from the same model: List view of the imported records will be opened.
  • Multiple records from different models: Notification with the list of models where new records were created will be shown.

Import Yaml Result

YAML File Example

Here is an example of a YAML file that contains multiple records from different models.

# This file is generated with Cetmix Tower.
# Details and documentation: https://cetmix.com/tower
# This file contains multiple records from different models.

cetmix_tower_yaml_version: 1
records:
- cetmix_tower_model: tag
  reference: such_much_tag
  name: 'Such Much Tag'
  color: 1
- cetmix_tower_model: key
  reference: such_much_secret
  key_type: s
  name: 'Such Much Secret'
  value_char: such_much_value
- cetmix_tower_model: server_template
  reference: demo_server_template_1
  name: 'Another Copy of Demo Server Template #1'
  color: 1
  os_id:
    reference: debian_10
    name: Debian 10
    color: 0
  tag_ids:
  - reference: custom
    name: Custom
    color: 3
  note: false
  ssh_port: 22
  ssh_username: admin
  ssh_auth_mode: p
  use_sudo: false
  variable_value_ids:
  - access_level: manager
    reference: demo_path_variable_value_1_3
    sequence: 10
    variable_id:
      access_level: manager
      reference: demo_path
      name: Demo Path
      variable_type: s
      note: false
    value_char: /opt/{{ tower.server.reference }}/cetmix-tower/{{ branch }}
    variable_ids:
    - access_level: manager
      reference: branch
      name: Branch
      variable_type: s
      note: false
  - access_level: manager
    reference: language_variable_value_1_4
    sequence: 10
    variable_id:
      access_level: manager
      reference: language
      name: Language
      variable_type: o
      option_ids:
      - reference: language_variable_option_1
        sequence: 10
        name: English (US)
        value_char: en_us
      - reference: language_variable_option_1_2
        sequence: 20
        name: Italian
        value_char: it
      - reference: language_variable_option_1_3
        sequence: 30
        name: Spanish (Mexican)
        value_char: es_mx
      - reference: language_variable_option_1_4
        sequence: 40
        name: German
        value_char: de
      - reference: language_variable_option_1_5
        sequence: 50
        name: German (Switzerland)
        value_char: de_ch
      note: false
    value_char: it
  - access_level: manager
    reference: odoo_demo_version_variable_value_1_3
    sequence: 10
    variable_id:
      access_level: manager
      reference: odoo_demo_version
      name: Odoo Demo Version
      variable_type: o
      option_ids:
      - reference: odoo_demo_version_variable_option_1
        sequence: 10
        name: '14.0'
        value_char: '14.0'
      - reference: odoo_demo_version_variable_option_1_2
        sequence: 20
        name: '15.0'
        value_char: '15.0'
      - reference: odoo_demo_version_variable_option_1_3
        sequence: 30
        name: '16.0'
        value_char: '16.0'
      - reference: odoo_demo_version_variable_option_1_4
        sequence: 40
        name: '17.0'
        value_char: '17.0'
      - reference: odoo_demo_version_variable_option_1_5
        sequence: 50
        name: '18.0'
        value_char: '18.0'
      note: false
    value_char: '17.0'
  - access_level: manager
    reference: url_variable_value_1_2
    sequence: 10
    variable_id:
      access_level: manager
      reference: url
      name: URL
      variable_type: s
      note: false
    value_char: https://cetmix.com
  server_log_ids:
  - reference: log_from_file_3
    name: Log from file
    log_type: file
    use_sudo: false
    file_template_id:
      reference: demo_file_template_4
      name: Demo File Template 4
      source: server
      file_type: text
      server_dir: /var/log
      file_name: server_demo_logs.txt
      keep_when_deleted: false
      tag_ids:
      - reference: production
        name: Production
        color: 2
      note: false
      code: false
  - reference: command_log_for_server_template_1
    name: 'Command Log for Server Template #1'
    log_type: command
    command_id:
      access_level: manager
      reference: create_directory
      name: Create directory
      action: ssh_command
      allow_parallel_run: false
      note: false
      tag_ids:
      - reference: production
        name: Production
        color: 2
      path: /home/{{ tower.server.username }}
      code: mkdir {{ dir }}
      server_status: false
      variable_ids:
      - access_level: manager
        reference: dir
        name: Directory
        variable_type: s
        note: false
    use_sudo: false
  flight_plan_id:
    access_level: manager
    reference: demo_flight_plan_1
    name: 'Demo Flight Plan #1'
    allow_parallel_run: false
    color: 0
    tag_ids:
    - reference: staging
      name: Staging
      color: 1
    note: Create directory and list its content
    on_error_action: e
    custom_exit_code: 0
    line_ids:
    - reference: demo_flight_plan_1_plan_line_1
      sequence: 5
      condition: false
      use_sudo: false
      path: /such/much/{{ demo_path }}
      command_id:
        access_level: manager
        reference: create_directory
        name: Create directory
        action: ssh_command
        allow_parallel_run: false
        note: false
        tag_ids:
        - reference: production
          name: Production
          color: 2
        path: /home/{{ tower.server.username }}
        code: mkdir {{ dir }}
        server_status: false
        variable_ids:
        - access_level: manager
          reference: dir
          name: Directory
          variable_type: s
          note: false
      action_ids:
      - reference: demo_flight_plan_1_plan_line_1_plan_line_action_1
        sequence: 1
        condition: ==
        value_char: '0'
        action: n
        custom_exit_code: 0
        variable_value_ids:
        - access_level: manager
          reference: branch_variable_value_1_3
          sequence: 10
          variable_id:
            access_level: manager
            reference: branch
            name: Branch
            variable_type: s
            note: false
          value_char: production
        - access_level: manager
          reference: flight_plan_end_time_unique_variable_value_1_2
          sequence: 10
          variable_id:
            access_level: manager
            reference: flight_plan_end_time_unique
            name: Flight Plan End Time Unique
            variable_type: s
            note: false
          value_char: final_value
        - access_level: manager
          reference: flight_plan_start_time_unique_variable_value_1_2
          sequence: 10
          variable_id:
            access_level: manager
            reference: flight_plan_start_time_unique
            name: Flight Plan Start Time Unique
            variable_type: s
            note: false
          value_char: initial_value
        - access_level: manager
          reference: flight_plan_status_unique_variable_value_1_2
          sequence: 10
          variable_id:
            access_level: manager
            reference: flight_plan_status_unique
            name: Flight Plan Execution Status
            variable_type: s
            note: false
          value_char: completed
        - access_level: manager
          reference: language_variable_value_1_3
          sequence: 10
          variable_id:
            access_level: manager
            reference: language
            name: Language
            variable_type: o
            option_ids:
            - reference: language_variable_option_1
              sequence: 10
              name: English (US)
              value_char: en_us
            - reference: language_variable_option_1_2
              sequence: 20
              name: Italian
              value_char: it
            - reference: language_variable_option_1_3
              sequence: 30
              name: Spanish (Mexican)
              value_char: es_mx
            - reference: language_variable_option_1_4
              sequence: 40
              name: German
              value_char: de
            - reference: language_variable_option_1_5
              sequence: 50
              name: German (Switzerland)
              value_char: de_ch
            note: false
          value_char: en_us
      - reference: demo_flight_plan_1_plan_line_1_plan_line_action_1_2
        sequence: 2
        condition: '>'
        value_char: '0'
        action: ec
        custom_exit_code: 255
    - reference: demo_flight_plan_1_plan_line_1_2
      sequence: 20
      condition: '{{ tower.server.status }} == ''running'' and {{ odoo_demo_version
        }} == "17.0"'
      use_sudo: false
      path: false
      command_id:
        access_level: user
        reference: list_files_in_directory
        name: List files in directory
        action: ssh_command
        allow_parallel_run: false
        note: false
        tag_ids:
        - reference: custom
          name: Custom
          color: 3
        path: /home/{{ tower.server.username }}
        code: ls -l
        server_status: false
      action_ids:
      - reference: demo_flight_plan_1_plan_line_1_2_plan_line_action_1
        sequence: 1
        condition: ==
        value_char: '-1'
        action: ec
        custom_exit_code: 100
        variable_value_ids:
        - access_level: manager
          reference: flight_plan_end_time_unique_variable_value_1_3
          sequence: 10
          variable_id:
            access_level: manager
            reference: flight_plan_end_time_unique
            name: Flight Plan End Time Unique
            variable_type: s
            note: false
          value_char: final_value
        - access_level: manager
          reference: flight_plan_start_time_unique_variable_value_1_3
          sequence: 10
          variable_id:
            access_level: manager
            reference: flight_plan_start_time_unique
            name: Flight Plan Start Time Unique
            variable_type: s
            note: false
          value_char: initial_value
        - access_level: manager
          reference: flight_plan_status_unique_variable_value_1_3
          sequence: 10
          variable_id:
            access_level: manager
            reference: flight_plan_status_unique
            name: Flight Plan Execution Status
            variable_type: s
            note: false
          value_char: completed
      - reference: demo_flight_plan_1_plan_line_1_2_plan_line_action_1_2
        sequence: 2
        condition: '>='
        value_char: '3'
        action: n
        custom_exit_code: 0
      variable_ids:
      - access_level: manager
        reference: odoo_demo_version
        name: Odoo Demo Version
        variable_type: o
        option_ids:
        - reference: odoo_demo_version_variable_option_1
          sequence: 10
          name: '14.0'
          value_char: '14.0'
        - reference: odoo_demo_version_variable_option_1_2
          sequence: 20
          name: '15.0'
          value_char: '15.0'
        - reference: odoo_demo_version_variable_option_1_3
          sequence: 30
          name: '16.0'
          value_char: '16.0'
        - reference: odoo_demo_version_variable_option_1_4
          sequence: 40
          name: '17.0'
          value_char: '17.0'
        - reference: odoo_demo_version_variable_option_1_5
          sequence: 50
          name: '18.0'
          value_char: '18.0'
        note: false
    - reference: demo_flight_plan_1_plan_line_1_3
      sequence: 30
      condition: false
      use_sudo: false
      path: false
      command_id:
        access_level: manager
        reference: upload_file_by_template
        name: Upload file by template
        action: file_using_template
        allow_parallel_run: false
        note: false
        tag_ids:
        - reference: staging
          name: Staging
          color: 1
        path: /home/{{ tower.server.username }}
        file_template_id:
          reference: demo_file_template_1
          name: Demo File Template 1
          source: tower
          file_type: text
          server_dir: '{{ demo_path }}'
          file_name: tower_demo_1.txt
          keep_when_deleted: false
          tag_ids:
          - reference: production
            name: Production
            color: 2
          note: false
          code: Hello, world!
        code: false
        server_status: false