---
masakari_services:
  masakari-api:
    container_name: masakari_api
    group: masakari-api
    enabled: true
    image: "{{ masakari_api_image_full }}"
    volumes: "{{ masakari_api_default_volumes + masakari_api_extra_volumes }}"
    dimensions: "{{ masakari_api_dimensions }}"
    haproxy:
      masakari_api:
        enabled: "{{ enable_masakari }}"
        mode: "http"
        external: false
        port: "{{ masakari_api_port }}"
        listen_port: "{{ masakari_api_listen_port }}"
      masakari_api_external:
        enabled: "{{ enable_masakari }}"
        mode: "http"
        external: true
        external_fqdn: "{{ masakari_external_fqdn }}"
        port: "{{ masakari_api_public_port }}"
        listen_port: "{{ masakari_api_listen_port }}"
  masakari-engine:
    container_name: masakari_engine
    group: masakari-engine
    enabled: true
    image: "{{ masakari_engine_image_full }}"
    volumes: "{{ masakari_engine_default_volumes + masakari_engine_extra_volumes }}"
    dimensions: "{{ masakari_engine_dimensions }}"
  masakari-instancemonitor:
    container_name: masakari_instancemonitor
    group: masakari-instancemonitor
    enabled: "{{ enable_masakari_instancemonitor | bool }}"
    image: "{{ masakari_monitors_image_full }}"
    volumes: "{{ masakari_instancemonitor_default_volumes + masakari_instancemonitor_extra_volumes }}"
    privileged: True
    dimensions: "{{ masakari_instancemonitor_dimensions }}"
  masakari-hostmonitor:
    container_name: masakari_hostmonitor
    group: masakari-hostmonitor
    enabled: "{{ enable_masakari_hostmonitor | bool }}"
    ipc_mode: host
    image: "{{ masakari_monitors_image_full }}"
    volumes: "{{ masakari_hostmonitor_default_volumes + masakari_hostmonitor_extra_volumes }}"
    dimensions: "{{ masakari_hostmonitor_dimensions }}"

####################
# Config Validate
####################
masakari_config_validation:
  - generator: "/masakari/etc/masakari/masakari-config-generator.conf"
    config: "/etc/masakari/masakari.conf"

####################
# Database
####################
masakari_database_name: "masakari"
masakari_database_user: "{% if use_preconfigured_databases | bool and use_common_mariadb_user | bool %}{{ database_user }}{% else %}masakari{% endif %}"
masakari_database_address: "{{ database_address | put_address_in_context('url') }}:{{ database_port }}"

####################
# Database sharding
####################
masakari_database_shard_root_user: "{% if enable_proxysql | bool %}root_shard_{{ masakari_database_shard_id }}{% else %}{{ database_user }}{% endif %}"
masakari_database_shard_id: "{{ mariadb_default_database_shard_id | int }}"
masakari_database_shard:
  users:
    - user: "{{ masakari_database_user }}"
      password: "{{ masakari_database_password }}"
  rules:
    - schema: "{{ masakari_database_name }}"
      shard_id: "{{ masakari_database_shard_id }}"


####################
# Docker
####################
masakari_tag: "{{ openstack_tag }}"

masakari_api_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/masakari-api"
masakari_api_tag: "{{ masakari_tag }}"
masakari_api_image_full: "{{ masakari_api_image }}:{{ masakari_api_tag }}"

masakari_engine_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/masakari-engine"
masakari_engine_tag: "{{ masakari_tag }}"
masakari_engine_image_full: "{{ masakari_engine_image }}:{{ masakari_engine_tag }}"

masakari_monitors_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/masakari-monitors"
masakari_monitors_tag: "{{ masakari_tag }}"
masakari_monitors_image_full: "{{ masakari_monitors_image }}:{{ masakari_monitors_tag }}"

masakari_api_dimensions: "{{ default_container_dimensions }}"
masakari_engine_dimensions: "{{ default_container_dimensions }}"
# NOTE(mgoddard): Allow masakari_monitors_dimensions for backwards
# compatibility.
masakari_instancemonitor_dimensions: "{{ masakari_monitors_dimensions | default(default_container_dimensions) }}"
masakari_hostmonitor_dimensions: "{{ default_container_dimensions }}"

masakari_extra_volumes: "{{ default_extra_volumes }}"
masakari_api_extra_volumes: "{{ masakari_extra_volumes }}"
masakari_engine_extra_volumes: "{{ masakari_extra_volumes }}"
masakari_instancemonitor_extra_volumes: "{{ masakari_extra_volumes }}"
masakari_hostmonitor_extra_volumes: "{{ masakari_extra_volumes }}"

masakari_api_default_volumes:
  - "{{ node_config_directory }}/masakari-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' if om_enable_queue_manager | bool else '' }}"
  - "{{ kolla_dev_repos_directory ~ '/masakari/masakari:/var/lib/kolla/venv/lib/python' ~ distro_python_version ~ '/site-packages/masakari' if masakari_dev_mode | bool else '' }}"
masakari_engine_default_volumes:
  - "{{ node_config_directory }}/masakari-engine/:{{ 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' if om_enable_queue_manager | bool else '' }}"
  - "{{ kolla_dev_repos_directory ~ '/masakari/masakari:/var/lib/kolla/venv/lib/python' ~ distro_python_version ~ '/site-packages/masakari' if masakari_dev_mode | bool else '' }}"
  - "masakari:/var/lib/masakari/"
masakari_instancemonitor_default_volumes:
  - "{{ node_config_directory }}/masakari-instancemonitor/:{{ 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' if om_enable_queue_manager | bool else '' }}"
  - "{{ kolla_dev_repos_directory ~ '/masakari-monitors/masakarimonitors:/var/lib/kolla/venv/lib/python' ~ distro_python_version ~ '/site-packages/masakarimonitors' if masakari_dev_mode | bool else '' }}"
masakari_hostmonitor_default_volumes:
  - "{{ node_config_directory }}/masakari-hostmonitor/:{{ 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' if om_enable_queue_manager | bool else '' }}"
  - "{{ kolla_dev_repos_directory ~ '/masakari-monitors/masakarimonitors:/var/lib/kolla/venv/lib/python' ~ distro_python_version ~ '/site-packages/masakarimonitors' if masakari_dev_mode | bool else '' }}"


####################
# OpenStack
####################
masakari_internal_endpoint: "{{ masakari_internal_fqdn | kolla_url(internal_protocol, masakari_api_port) }}"
masakari_public_endpoint: "{{ masakari_external_fqdn | kolla_url(public_protocol, masakari_api_public_port) }}"

masakari_logging_debug: "{{ openstack_logging_debug }}"

masakari_keystone_user: "masakari"

openstack_masakari_auth: "{{ openstack_auth }}"

masakari_api_workers: "{{ openstack_service_workers }}"

####################
# Kolla
####################
masakari_git_repository: "{{ kolla_dev_repos_git }}/{{ project_name }}"
masakari_dev_repos_pull: "{{ kolla_dev_repos_pull }}"
masakari_dev_mode: "{{ kolla_dev_mode }}"
masakari_source_version: "{{ kolla_source_version }}"

masakari_monitors_git_repository: "{{ kolla_dev_repos_git }}/masakari-monitors"
masakari_monitors_dev_repos_pull: "{{ kolla_dev_repos_pull }}"
masakari_monitors_dev_mode: "{{ kolla_dev_mode }}"
masakari_monitors_source_version: "{{ kolla_source_version }}"

####################
# Keystone
####################
masakari_ks_services:
  - name: "masakari"
    type: "instance-ha"
    description: "OpenStack High Availability"
    endpoints:
      - {'interface': 'internal', 'url': '{{ masakari_internal_endpoint }}'}
      - {'interface': 'public', 'url': '{{ masakari_public_endpoint }}'}

masakari_ks_users:
  - project: "service"
    user: "{{ masakari_keystone_user }}"
    password: "{{ masakari_keystone_password }}"
    role: "admin"

####################
# libvirt
####################
# Whether to enable libvirt SASL authentication.
libvirt_enable_sasl: true
# Username for libvirt SASL.
libvirt_sasl_authname: "nova"
# List of enabled libvirt SASL authentication mechanisms.
libvirt_sasl_mech_list:
  - "{{ 'SCRAM-SHA-256' if libvirt_tls | bool else 'DIGEST-MD5' }}"
