Mode in detail

The mode field is an intent-based control for the Drupal Operator. It lets you encode what kind of deployment you’re doing, and the operator derives the low-level flags (drupal_do_not_install, drupal_import_*, no_mariadb) accordingly.

spec:
  mode: standard | clone | external-db

If mode is not set, it defaults to standard at the controller level.

Mode semantics

mode: standard

Intended for fresh site installs.

Effective behavior:

  • drupal_do_not_install: false
  • drupal_import_database: false
  • drupal_import_files: false
  • no_mariadb: false

Typical use:

  • Developer or platform user wants a brand new Drupal instance.
  • DB is created and owned by the operator.
  • Drupal runs drush si on first reconcile.

mode: clone

Intended for cloning an existing site from backups (DB + files).

Effective behavior:

  • drupal_do_not_install: true
    • Skips site-install.
  • drupal_import_database: true
  • drupal_import_files: true
  • no_mariadb: false

Required/supporting fields:

  • drupal_database_backup_path: path to DB dump inside import job container.
  • drupal_files_backup_path: path to files archive inside import job container.
  • change_cause: used to trigger imports (only if you are overwriting an existing install with a clone).

Example

spec:
  mode: clone
  drupal_database_backup_path: "/backups/prod/db.sql"
  drupal_files_backup_path: "/backups/prod/files.tar.gz"
  change_cause: "clone-prod-to-staging-2025-01-01"

The main flow then:

  • Scales down Drupal deployment before DB import (if it existed before).
  • Creates DB and files import Jobs.
  • Waits for them to succeed.
  • Updates status:
  • dbImported: true, lastDbImportChecksum, lastDbImportDate
  • filesImported: true, lastFilesImportChecksum, lastFilesImportDate
  • Redeploys Drupal and marks installed: true.

mode: external-db

Intended for using an external database (no operator-managed MariaDB).

Effective behavior:

  • no_mariadb: true (forced)
  • drupal_do_not_install, drupal_import_database, drupal_import_files:
    • Left to the user, or optionally defaulted in your logic.

Typical patterns:

  • Fresh install on external DB:

yaml spec: mode: external-db no_mariadb: true drupal_do_not_install: false drupal_import_database: false

  • Import into external DB (one-time clone):

```yaml spec: mode: external-db no_mariadb: true

    drupal_do_not_install: true
    drupal_import_database: true
    drupal_database_backup_path: "/backups/prod/db.sql"

```

How mode is implemented in the operator

- name: Set effective mode (default: new)
  set_fact:
    effective_mode: "{{ _ozzi_io_drupal.spec.mode | default('new') }}"

- name: Derive defaults from mode
  set_fact:
    drupal_do_not_install: >-
      {{ 'true' if effective_mode == 'clone'
          else (_ozzi_io_drupal.spec.drupal_do_not_install | default(false)) }}
    drupal_import_database: >-
      {{ 'true' if effective_mode == 'clone'
          else (_ozzi_io_drupal.spec.drupal_import_database | default(false)) }}
    drupal_import_files: >-
      {{ 'true' if effective_mode == 'clone'
          else (_ozzi_io_drupal.spec.drupal_import_files | default(false)) }}
    no_mariadb: >-
      {{ 'true' if effective_mode == 'external-db'
          else (_ozzi_io_drupal.spec.no_mariadb | default(false)) }}

This ensures:

  • All later tasks (when: no_mariadb == false, when: drupal_import_database | default(false)) see the mode-adjusted values.
  • Users can still explicitly override behavior if needed (for example, set drupal_import_files: false even in mode: clone, if you allow it).

Validation tasks

To fail early when config is incomplete for a mode, the operator has:

    - name: Fail if clone mode is missing DB backup path
      when: effective_mode == 'clone' and
            (_ozzi_io_drupal.spec.drupal_database_backup_path | default('')) == ''
      fail:
        msg: "mode=clone requires spec.drupal_database_backup_path to be set."

    - name: Fail if clone mode is missing files backup path
      when: effective_mode == 'clone' and
            (_ozzi_io_drupal.spec.drupal_files_backup_path | default('')) == ''
      fail:
        msg: "mode=clone requires spec.drupal_files_backup_path to be set."
  • Use mode: standard for:
  • Sites you want from scratch.
  • Use mode: clone for:
  • “Clone prod to staging” or “copy site to another site”.
  • Use mode: external-db for:
  • Production sites using a database outside the operator’s control.
  • Scenarios where DB backups/restores are handled externally from the operator.