02_init_database.ymlΒΆ

---
# Initialize Odoo database and install core modules
# Note: The PostgreSQL database is created by sys-svc-rdbms before this role runs

- name: πŸ”Ž Check if Odoo schema is initialized (ir_module_module table exists)
  database_query:
    mask_values: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}"
    config: "{{ lookup('database', application_id) }}"
    query_file: "{{ role_path }}/files/sql/select/ir-module-module-table-exists.sql"
    expect_rows: true
  register: odoo_schema_exists
  ignore_errors: true

- name: πŸ› Debug schema check result
  debug:
    msg: "Schema exists check: rows={{ odoo_schema_exists.rows | default('NOT DEFINED') }}, failed={{ odoo_schema_exists.failed | default(false) }}"
  when: MODE_DEBUG | bool

- name: 🎬 Initialize Odoo database with core modules
  include_tasks: 02_init_database/bootstrap_schema.yml
  when: odoo_schema_exists.rows is not defined or odoo_schema_exists.rows | length == 0