---
- name: Creating Nova cell database
  become: true
  kolla_toolbox:
    container_engine: "{{ kolla_container_engine }}"
    module_name: mysql_db
    module_args:
      login_host: "{{ nova_cell_database_address }}"
      login_port: "{{ nova_cell_database_port }}"
      login_user: "{{ nova_cell_database_admin_user }}"
      login_password: "{{ nova_cell_database_admin_password }}"
      name: "{{ nova_cell_database_name }}"
  when:
    - not use_preconfigured_databases | bool
    - inventory_hostname == groups[nova_cell_conductor_group][0]

- name: Creating Nova cell database user and setting permissions
  become: true
  kolla_toolbox:
    container_engine: "{{ kolla_container_engine }}"
    module_name: mysql_user
    module_args:
      login_host: "{{ nova_cell_database_address }}"
      login_port: "{{ nova_cell_database_port }}"
      login_user: "{{ nova_cell_database_admin_user }}"
      login_password: "{{ nova_cell_database_admin_password }}"
      name: "{{ nova_cell_database_user }}"
      password: "{{ nova_cell_database_password }}"
      host: "%"
      priv: "{{ nova_cell_database_name }}.*:ALL"
      append_privs: "yes"
  when:
    - not use_preconfigured_databases | bool
    - inventory_hostname == groups[nova_cell_conductor_group][0]
  no_log: true

- import_tasks: rabbitmq.yml

- import_tasks: config_bootstrap.yml

- import_tasks: bootstrap_service.yml

- import_tasks: create_cells.yml
