{% set mysql_dir = 'mysql' if kolla_base_distro in ['ubuntu', 'debian'] else '' %}
name: infra/mariadb/mariadb
enabled: {{ enable_mariadb | bool }}
container:
  image: "{{ mariadb_image }}:{{ mariadb_tag }}"
  parameters:
    - key: volume
      value: "mariadb_{{ deployment_id }}_{{ timestamp }}:/var/lib/mysql"
    - key: volume
      value: "kolla_logs_{{ deployment_id }}_{{ timestamp }}:/var/log/kolla"
service:
  daemon:
    command: /usr/bin/mysqld_safe --wsrep-new-cluster
    dependencies:
     - path: mariadb/bootstrap
  mem: {{ mariadb_mem }}
  cpus: {{ mariadb_cpus }}
  instances: {{ controller_nodes }}
  constraints: {{ controller_constraints }}
commands:
  bootstrap:
    run_once: True
    command: kolla_extend_start
    env:
      KOLLA_BOOTSTRAP:
      DB_ROOT_PASSWORD: "{{ database_password }}"
      DB_MAX_TIMEOUT: "{{ database_max_timeout }}"
    files:
      galera.cnf.j2:
        source: config/mariadb/templates/galera.cnf.j2
        dest: /etc/{{ mysql_dir }}/my.cnf
        owner: mysql
        perm: "0600"
