---
trove_services:
  trove-api:
    container_name: trove_api
    group: trove-api
    enabled: true
    image: "{{ trove_api_image_full }}"
    volumes: "{{ trove_api_default_volumes + trove_api_extra_volumes }}"
    dimensions: "{{ trove_api_dimensions }}"
    healthcheck: "{{ trove_api_healthcheck }}"
    haproxy:
      trove_api:
        enabled: "{{ enable_trove }}"
        mode: "http"
        external: false
        port: "{{ trove_api_port }}"
        listen_port: "{{ trove_api_listen_port }}"
        tls_backend: "{{ trove_enable_tls_backend }}"
        backend_http_extra:
          - "option httpchk"
      trove_api_external:
        enabled: "{{ enable_trove }}"
        mode: "http"
        external: true
        listen_port: "{{ trove_api_listen_port }}"
        tls_backend: "{{ trove_enable_tls_backend }}"
        external_fqdn: "{{ trove_external_fqdn }}"
        port: "{{ trove_api_public_port }}"
        backend_http_extra:
          - "option httpchk"
  trove-conductor:
    container_name: trove_conductor
    group: trove-conductor
    enabled: true
    image: "{{ trove_conductor_image_full }}"
    volumes: "{{ trove_conductor_default_volumes + trove_conductor_extra_volumes }}"
    dimensions: "{{ trove_conductor_dimensions }}"
    healthcheck: "{{ trove_conductor_healthcheck }}"
  trove-taskmanager:
    container_name: trove_taskmanager
    group: trove-taskmanager
    enabled: true
    image: "{{ trove_taskmanager_image_full }}"
    volumes: "{{ trove_taskmanager_default_volumes + trove_taskmanager_extra_volumes }}"
    dimensions: "{{ trove_taskmanager_dimensions }}"
    healthcheck: "{{ trove_taskmanager_healthcheck }}"

####################
# Config Validate
####################
trove_config_validation:
  - generator: "/trove/tools/trove-config-generator.conf"
    config: "/etc/trove/trove.conf"

####################
# Database
####################
trove_database_name: "trove"
trove_database_user: "{% if use_preconfigured_databases | bool and use_common_mariadb_user | bool %}{{ database_user }}{% else %}trove{% endif %}"
trove_database_address: "{{ database_address | put_address_in_context('url') }}:{{ database_port }}"

####################
# Database sharding
####################
trove_database_shard_root_user: "{% if enable_proxysql | bool %}root_shard_{{ trove_database_shard_id }}{% else %}{{ database_user }}{% endif %}"
trove_database_shard_id: "{{ mariadb_default_database_shard_id | int }}"
trove_database_shard:
  users:
    - user: "{{ trove_database_user }}"
      password: "{{ trove_database_password }}"
  rules:
    - schema: "{{ trove_database_name }}"
      shard_id: "{{ trove_database_shard_id }}"


####################
# Docker
####################
trove_tag: "{{ openstack_tag }}"

trove_conductor_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ docker_image_name_prefix }}trove-conductor"
trove_conductor_tag: "{{ trove_tag }}"
trove_conductor_image_full: "{{ trove_conductor_image }}:{{ trove_conductor_tag }}"

trove_api_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ docker_image_name_prefix }}trove-api"
trove_api_tag: "{{ trove_tag }}"
trove_api_image_full: "{{ trove_api_image }}:{{ trove_api_tag }}"

trove_taskmanager_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ docker_image_name_prefix }}trove-taskmanager"
trove_taskmanager_tag: "{{ trove_tag }}"
trove_taskmanager_image_full: "{{ trove_taskmanager_image }}:{{ trove_taskmanager_tag }}"

trove_api_dimensions: "{{ default_container_dimensions }}"
trove_conductor_dimensions: "{{ default_container_dimensions }}"
trove_taskmanager_dimensions: "{{ default_container_dimensions }}"

trove_api_enable_healthchecks: "{{ enable_container_healthchecks }}"
trove_api_healthcheck_interval: "{{ default_container_healthcheck_interval }}"
trove_api_healthcheck_retries: "{{ default_container_healthcheck_retries }}"
trove_api_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}"
trove_api_healthcheck_test: ["CMD-SHELL", "healthcheck_curl http://{{ api_interface_address | put_address_in_context('url') }}:{{ trove_api_port }}"]
trove_api_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}"
trove_api_healthcheck:
  interval: "{{ trove_api_healthcheck_interval }}"
  retries: "{{ trove_api_healthcheck_retries }}"
  start_period: "{{ trove_api_healthcheck_start_period }}"
  test: "{% if trove_api_enable_healthchecks | bool %}{{ trove_api_healthcheck_test }}{% else %}NONE{% endif %}"
  timeout: "{{ trove_api_healthcheck_timeout }}"

trove_conductor_enable_healthchecks: "{{ enable_container_healthchecks }}"
trove_conductor_healthcheck_interval: "{{ default_container_healthcheck_interval }}"
trove_conductor_healthcheck_retries: "{{ default_container_healthcheck_retries }}"
trove_conductor_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}"
trove_conductor_healthcheck_test: ["CMD-SHELL", "healthcheck_port trove-conductor {{ om_rpc_port }}"]
trove_conductor_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}"
trove_conductor_healthcheck:
  interval: "{{ trove_conductor_healthcheck_interval }}"
  retries: "{{ trove_conductor_healthcheck_retries }}"
  start_period: "{{ trove_conductor_healthcheck_start_period }}"
  test: "{% if trove_conductor_enable_healthchecks | bool %}{{ trove_conductor_healthcheck_test }}{% else %}NONE{% endif %}"
  timeout: "{{ trove_conductor_healthcheck_timeout }}"

trove_taskmanager_enable_healthchecks: "{{ enable_container_healthchecks }}"
trove_taskmanager_healthcheck_interval: "{{ default_container_healthcheck_interval }}"
trove_taskmanager_healthcheck_retries: "{{ default_container_healthcheck_retries }}"
trove_taskmanager_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}"
trove_taskmanager_healthcheck_test: ["CMD-SHELL", "healthcheck_port trove-taskmanager {{ om_rpc_port }}"]
trove_taskmanager_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}"
trove_taskmanager_healthcheck:
  interval: "{{ trove_taskmanager_healthcheck_interval }}"
  retries: "{{ trove_taskmanager_healthcheck_retries }}"
  start_period: "{{ trove_taskmanager_healthcheck_start_period }}"
  test: "{% if trove_taskmanager_enable_healthchecks | bool %}{{ trove_taskmanager_healthcheck_test }}{% else %}NONE{% endif %}"
  timeout: "{{ trove_taskmanager_healthcheck_timeout }}"

trove_api_default_volumes:
  - "{{ node_config_directory }}/trove-api/:{{ container_config_directory }}/:ro"
  - "/etc/localtime:/etc/localtime:ro"
  - "{{ '/etc/timezone:/etc/timezone:ro' if ansible_facts.os_family == 'Debian' else '' }}"
  - "kolla_logs:/var/log/kolla/"
  - "{{ '/dev/shm:/dev/shm' }}"
  - "{{ kolla_dev_repos_directory ~ '/trove:/dev-mode/trove' if trove_dev_mode | bool else '' }}"
  - "trove:/var/lib/trove/"
trove_conductor_default_volumes:
  - "{{ node_config_directory }}/trove-conductor/:{{ container_config_directory }}/:ro"
  - "/etc/localtime:/etc/localtime:ro"
  - "{{ '/etc/timezone:/etc/timezone:ro' if ansible_facts.os_family == 'Debian' else '' }}"
  - "kolla_logs:/var/log/kolla/"
  - "{{ '/dev/shm:/dev/shm' }}"
  - "{{ kolla_dev_repos_directory ~ '/trove:/dev-mode/trove' if trove_dev_mode | bool else '' }}"
  - "trove:/var/lib/trove/"
trove_taskmanager_default_volumes:
  - "{{ node_config_directory }}/trove-taskmanager/:{{ container_config_directory }}/:ro"
  - "/etc/localtime:/etc/localtime:ro"
  - "{{ '/etc/timezone:/etc/timezone:ro' if ansible_facts.os_family == 'Debian' else '' }}"
  - "kolla_logs:/var/log/kolla/"
  - "{{ '/dev/shm:/dev/shm' }}"
  - "{{ kolla_dev_repos_directory ~ '/trove:/dev-mode/trove' if trove_dev_mode | bool else '' }}"
  - "trove:/var/lib/trove/"

trove_extra_volumes: "{{ default_extra_volumes }}"
trove_api_extra_volumes: "{{ trove_extra_volumes }}"
trove_conductor_extra_volumes: "{{ trove_extra_volumes }}"
trove_taskmanager_extra_volumes: "{{ trove_extra_volumes }}"

####################
# OpenStack
####################
trove_internal_endpoint: "{{ trove_internal_base_endpoint }}/v1.0/%(tenant_id)s"
trove_public_endpoint: "{{ trove_public_base_endpoint }}/v1.0/%(tenant_id)s"

trove_logging_debug: "{{ openstack_logging_debug }}"

trove_keystone_user: "trove"

openstack_trove_auth: "{{ openstack_auth }}"

trove_api_workers: "{{ openstack_service_workers }}"

####################
# Kolla
####################
trove_git_repository: "{{ kolla_dev_repos_git }}/{{ project_name }}"
trove_dev_repos_pull: "{{ kolla_dev_repos_pull }}"
trove_dev_mode: "{{ kolla_dev_mode }}"
trove_source_version: "{{ kolla_source_version }}"

####################
# Notifications
####################
trove_notification_topics:
  - name: notifications
    enabled: "{{ enable_ceilometer | bool }}"

trove_enabled_notification_topics: "{{ trove_notification_topics | selectattr('enabled', 'equalto', true) | list }}"

####################
# Keystone
####################
trove_ks_services:
  - name: "trove"
    type: "database"
    description: "Trove Database Service"
    endpoints:
      - {'interface': 'internal', 'url': '{{ trove_internal_endpoint }}'}
      - {'interface': 'public', 'url': '{{ trove_public_endpoint }}'}

trove_ks_users:
  - project: "service"
    user: "{{ trove_keystone_user }}"
    password: "{{ trove_keystone_password }}"
    role: "admin"

####################
# TLS
####################
trove_enable_tls_backend: "{{ kolla_enable_tls_backend }}"

trove_copy_certs: "{{ kolla_copy_ca_into_containers | bool or trove_enable_tls_backend | bool }}"
