---
vitrage_services:
  vitrage-api:
    container_name: vitrage_api
    group: vitrage-api
    enabled: true
    image: "{{ vitrage_api_image_full }}"
    volumes: "{{ vitrage_api_default_volumes + vitrage_api_extra_volumes }}"
    dimensions: "{{ vitrage_api_dimensions }}"
    healthcheck: "{{ vitrage_api_healthcheck }}"
    haproxy:
      vitrage_api:
        enabled: "{{ enable_vitrage }}"
        mode: "http"
        external: false
        port: "{{ vitrage_api_port }}"
      vitrage_api_external:
        enabled: "{{ enable_vitrage }}"
        mode: "http"
        external: true
        port: "{{ vitrage_api_port }}"
  vitrage-notifier:
    container_name: vitrage_notifier
    group: vitrage-notifier
    enabled: true
    image: "{{ vitrage_notifier_image_full }}"
    volumes: "{{ vitrage_notifier_default_volumes + vitrage_notifier_extra_volumes }}"
    dimensions: "{{ vitrage_notifier_dimensions }}"
    healthcheck: "{{ vitrage_notifier_healthcheck }}"
  vitrage-graph:
    container_name: vitrage_graph
    group: vitrage-graph
    enabled: true
    image: "{{ vitrage_graph_image_full }}"
    volumes: "{{ vitrage_graph_default_volumes + vitrage_graph_extra_volumes }}"
    dimensions: "{{ vitrage_graph_dimensions }}"
    healthcheck: "{{ vitrage_graph_healthcheck }}"
  vitrage-ml:
    container_name: vitrage_ml
    group: vitrage-ml
    enabled: true
    image: "{{ vitrage_ml_image_full }}"
    volumes: "{{ vitrage_ml_default_volumes + vitrage_ml_extra_volumes }}"
    dimensions: "{{ vitrage_ml_dimensions }}"
    healthcheck: "{{ vitrage_ml_healthcheck }}"
  vitrage-persistor:
    container_name: vitrage_persistor
    group: vitrage-persistor
    enabled: true
    image: "{{ vitrage_persistor_image_full }}"
    volumes: "{{ vitrage_persistor_default_volumes + vitrage_persistor_extra_volumes }}"
    dimensions: "{{ vitrage_persistor_dimensions }}"
    healthcheck: "{{ vitrage_persistor_healthcheck }}"

####################
# Config Validate
####################
vitrage_config_validation:
  - generator: "/vitrage/etc/vitrage/vitrage-config-generator.conf"
    config: "/etc/vitrage/vitrage.conf"

####################
## Database
#####################
vitrage_database_name: "vitrage"
vitrage_database_user: "{% if use_preconfigured_databases | bool and use_common_mariadb_user | bool %}{{ database_user }}{% else %}vitrage{% endif %}"
vitrage_database_address: "{{ database_address | put_address_in_context('url') }}:{{ database_port }}"

####################
# Database sharding
####################
vitrage_database_shard_root_user: "{% if enable_proxysql | bool %}root_shard_{{ vitrage_database_shard_id }}{% else %}{{ database_user }}{% endif %}"
vitrage_database_shard_id: "{{ mariadb_default_database_shard_id | int }}"
vitrage_database_shard:
  users:
    - user: "{{ vitrage_database_user }}"
      password: "{{ vitrage_database_password }}"
  rules:
    - schema: "{{ vitrage_database_name }}"
      shard_id: "{{ vitrage_database_shard_id }}"


####################
# Docker
####################

vitrage_tag: "{{ openstack_tag }}"

vitrage_graph_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/vitrage-graph"
vitrage_graph_tag: "{{ vitrage_tag }}"
vitrage_graph_image_full: "{{ vitrage_graph_image }}:{{ vitrage_graph_tag }}"

vitrage_api_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/vitrage-api"
vitrage_api_tag: "{{ vitrage_tag }}"
vitrage_api_image_full: "{{ vitrage_api_image }}:{{ vitrage_api_tag }}"

vitrage_notifier_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/vitrage-notifier"
vitrage_notifier_tag: "{{ vitrage_tag }}"
vitrage_notifier_image_full: "{{ vitrage_notifier_image }}:{{ vitrage_notifier_tag }}"

vitrage_ml_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/vitrage-ml"
vitrage_ml_tag: "{{ vitrage_tag }}"
vitrage_ml_image_full: "{{ vitrage_ml_image }}:{{ vitrage_ml_tag }}"

vitrage_persistor_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/vitrage-persistor"
vitrage_persistor_tag: "{{ vitrage_tag }}"
vitrage_persistor_image_full: "{{ vitrage_persistor_image }}:{{ vitrage_persistor_tag }}"

vitrage_api_dimensions: "{{ default_container_dimensions }}"
vitrage_notifier_dimensions: "{{ default_container_dimensions }}"
vitrage_graph_dimensions: "{{ default_container_dimensions }}"
vitrage_ml_dimensions: "{{ default_container_dimensions }}"
vitrage_persistor_dimensions: "{{ default_container_dimensions }}"

vitrage_api_enable_healthchecks: "{{ enable_container_healthchecks }}"
vitrage_api_healthcheck_interval: "{{ default_container_healthcheck_interval }}"
vitrage_api_healthcheck_retries: "{{ default_container_healthcheck_retries }}"
vitrage_api_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}"
vitrage_api_healthcheck_test: ["CMD-SHELL", "healthcheck_curl http://{{ api_interface_address | put_address_in_context('url') }}:{{ vitrage_api_port }}"]
vitrage_api_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}"
vitrage_api_healthcheck:
  interval: "{{ vitrage_api_healthcheck_interval }}"
  retries: "{{ vitrage_api_healthcheck_retries }}"
  start_period: "{{ vitrage_api_healthcheck_start_period }}"
  test: "{% if vitrage_api_enable_healthchecks | bool %}{{ vitrage_api_healthcheck_test }}{% else %}NONE{% endif %}"
  timeout: "{{ vitrage_api_healthcheck_timeout }}"

vitrage_notifier_enable_healthchecks: "{{ enable_container_healthchecks }}"
vitrage_notifier_healthcheck_interval: "{{ default_container_healthcheck_interval }}"
vitrage_notifier_healthcheck_retries: "{{ default_container_healthcheck_retries }}"
vitrage_notifier_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}"
vitrage_notifier_healthcheck_test: ["CMD-SHELL", "healthcheck_port vitrage-notifier {{ om_rpc_port }}"]
vitrage_notifier_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}"
vitrage_notifier_healthcheck:
  interval: "{{ vitrage_notifier_healthcheck_interval }}"
  retries: "{{ vitrage_notifier_healthcheck_retries }}"
  start_period: "{{ vitrage_notifier_healthcheck_start_period }}"
  test: "{% if vitrage_notifier_enable_healthchecks | bool %}{{ vitrage_notifier_healthcheck_test }}{% else %}NONE{% endif %}"
  timeout: "{{ vitrage_notifier_healthcheck_timeout }}"

vitrage_graph_enable_healthchecks: "{{ enable_container_healthchecks }}"
vitrage_graph_healthcheck_interval: "{{ default_container_healthcheck_interval }}"
vitrage_graph_healthcheck_retries: "{{ default_container_healthcheck_retries }}"
vitrage_graph_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}"
vitrage_graph_healthcheck_test: ["CMD-SHELL", "healthcheck_port vitrage-graph {{ om_rpc_port }}"]
vitrage_graph_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}"
vitrage_graph_healthcheck:
  interval: "{{ vitrage_graph_healthcheck_interval }}"
  retries: "{{ vitrage_graph_healthcheck_retries }}"
  start_period: "{{ vitrage_graph_healthcheck_start_period }}"
  test: "{% if vitrage_graph_enable_healthchecks | bool %}{{ vitrage_graph_healthcheck_test }}{% else %}NONE{% endif %}"
  timeout: "{{ vitrage_graph_healthcheck_timeout }}"

vitrage_ml_enable_healthchecks: "{{ enable_container_healthchecks }}"
vitrage_ml_healthcheck_interval: "{{ default_container_healthcheck_interval }}"
vitrage_ml_healthcheck_retries: "{{ default_container_healthcheck_retries }}"
vitrage_ml_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}"
vitrage_ml_healthcheck_test: ["CMD-SHELL", "healthcheck_port vitrage-ml {{ om_rpc_port }}"]
vitrage_ml_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}"
vitrage_ml_healthcheck:
  interval: "{{ vitrage_ml_healthcheck_interval }}"
  retries: "{{ vitrage_ml_healthcheck_retries }}"
  start_period: "{{ vitrage_ml_healthcheck_start_period }}"
  test: "{% if vitrage_ml_enable_healthchecks | bool %}{{ vitrage_ml_healthcheck_test }}{% else %}NONE{% endif %}"
  timeout: "{{ vitrage_ml_healthcheck_timeout }}"

vitrage_persistor_enable_healthchecks: "{{ enable_container_healthchecks }}"
vitrage_persistor_healthcheck_interval: "{{ default_container_healthcheck_interval }}"
vitrage_persistor_healthcheck_retries: "{{ default_container_healthcheck_retries }}"
vitrage_persistor_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}"
vitrage_persistor_healthcheck_test: ["CMD-SHELL", "healthcheck_port vitrage-persistor {{ om_rpc_port }}"]
vitrage_persistor_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}"
vitrage_persistor_healthcheck:
  interval: "{{ vitrage_persistor_healthcheck_interval }}"
  retries: "{{ vitrage_persistor_healthcheck_retries }}"
  start_period: "{{ vitrage_persistor_healthcheck_start_period }}"
  test: "{% if vitrage_persistor_enable_healthchecks | bool %}{{ vitrage_persistor_healthcheck_test }}{% else %}NONE{% endif %}"
  timeout: "{{ vitrage_persistor_healthcheck_timeout }}"

vitrage_api_default_volumes:
  - "{{ node_config_directory }}/vitrage-api/:{{ container_config_directory }}/:ro"
  - "/etc/localtime:/etc/localtime:ro"
  - "{{ '/etc/timezone:/etc/timezone:ro' if ansible_facts.os_family == 'Debian' else '' }}"
  - "{{ kolla_dev_repos_directory ~ '/vitrage/vitrage:/var/lib/kolla/venv/lib/python' ~ distro_python_version ~ '/site-packages/vitrage' if vitrage_dev_mode | bool else '' }}"
  - "kolla_logs:/var/log/kolla/"
vitrage_notifier_default_volumes:
  - "{{ node_config_directory }}/vitrage-notifier/:{{ container_config_directory }}/:ro"
  - "/etc/localtime:/etc/localtime:ro"
  - "{{ '/etc/timezone:/etc/timezone:ro' if ansible_facts.os_family == 'Debian' else '' }}"
  - "{{ kolla_dev_repos_directory ~ '/vitrage/vitrage:/var/lib/kolla/venv/lib/python' ~ distro_python_version ~ '/site-packages/vitrage' if vitrage_dev_mode | bool else '' }}"
  - "kolla_logs:/var/log/kolla/"
vitrage_graph_default_volumes:
  - "{{ node_config_directory }}/vitrage-graph/:{{ container_config_directory }}/:ro"
  - "/etc/localtime:/etc/localtime:ro"
  - "{{ '/etc/timezone:/etc/timezone:ro' if ansible_facts.os_family == 'Debian' else '' }}"
  - "{{ kolla_dev_repos_directory ~ '/vitrage/vitrage:/var/lib/kolla/venv/lib/python' ~ distro_python_version ~ '/site-packages/vitrage' if vitrage_dev_mode | bool else '' }}"
  - "kolla_logs:/var/log/kolla/"
vitrage_ml_default_volumes:
  - "{{ node_config_directory }}/vitrage-ml/:{{ container_config_directory }}/:ro"
  - "/etc/localtime:/etc/localtime:ro"
  - "{{ '/etc/timezone:/etc/timezone:ro' if ansible_facts.os_family == 'Debian' else '' }}"
  - "{{ kolla_dev_repos_directory ~ '/vitrage/vitrage:/var/lib/kolla/venv/lib/python' ~ distro_python_version ~ '/site-packages/vitrage' if vitrage_dev_mode | bool else '' }}"
  - "kolla_logs:/var/log/kolla/"
vitrage_persistor_default_volumes:
  - "{{ node_config_directory }}/vitrage-persistor/:{{ container_config_directory }}/:ro"
  - "/etc/localtime:/etc/localtime:ro"
  - "{{ '/etc/timezone:/etc/timezone:ro' if ansible_facts.os_family == 'Debian' else '' }}"
  - "{{ kolla_dev_repos_directory ~ '/vitrage/vitrage:/var/lib/kolla/venv/lib/python' ~ distro_python_version ~ '/site-packages/vitrage' if vitrage_dev_mode | bool else '' }}"
  - "kolla_logs:/var/log/kolla/"

vitrage_extra_volumes: "{{ default_extra_volumes }}"
vitrage_api_extra_volumes: "{{ vitrage_extra_volumes }}"
vitrage_notifier_extra_volumes: "{{ vitrage_extra_volumes }}"
vitrage_graph_extra_volumes: "{{ vitrage_extra_volumes }}"
vitrage_ml_extra_volumes: "{{ vitrage_extra_volumes }}"
vitrage_persistor_extra_volumes: "{{ vitrage_extra_volumes }}"

####################
# OpenStack
####################
vitrage_logging_debug: "{{ openstack_logging_debug }}"

vitrage_keystone_user: "vitrage"

openstack_vitrage_auth: "{{ openstack_auth }}"

vitrage_api_workers: "{{ openstack_service_workers }}"

#####################
# Datasources
#####################
vitrage_notifier:
  - name: "aodh"
    enabled: "{{ enable_aodh | bool }}"
  - name: "mistral"
    enabled: "{{ enable_mistral | bool }}"
  - name: "nova"
    enabled: "{{ enable_nova | bool }}"

vitrage_notifiers: "{{ vitrage_notifier | selectattr('enabled', 'equalto', true) | list }}"

vitrage_datasource:
  - name: "static"
    enabled: true
  - name: "nova.host,nova.instance,nova.zone"
    enabled: "{{ enable_nova | bool }}"
  - name: "aodh"
    enabled: "{{ enable_aodh | bool }}"
  - name: "collectd"
    enabled: "{{ enable_collectd | bool }}"
  - name: "cinder.volume"
    enabled: "{{ enable_cinder | bool }}"
  - name: "neutron.network,neutron.port"
    enabled: "{{ enable_neutron | bool }}"
  # TODO(egonzalez) Heat cannot be used with default policy.json due stacks:global_index=rule:deny_everybody.
  # Document process to deploy vitrage+heat.
  - name: "heat.stack"
    enabled: "no"
  - name: "prometheus"
    enabled: "{{ enable_vitrage_prometheus_datasource | bool }}"

vitrage_datasources: "{{ vitrage_datasource | selectattr('enabled', 'equalto', true) | list }}"


####################
# Kolla
####################
vitrage_git_repository: "{{ kolla_dev_repos_git }}/{{ project_name }}"
vitrage_dev_repos_pull: "{{ kolla_dev_repos_pull }}"
vitrage_dev_mode: "{{ kolla_dev_mode }}"
vitrage_source_version: "{{ kolla_source_version }}"

####################
# Notifications
####################
vitrage_notification_topics:
  - name: notifications
    enabled: "{{ enable_ceilometer | bool }}"
  - name: vitrage_notifications
    enabled: True

vitrage_enabled_notification_topics: "{{ vitrage_notification_topics | selectattr('enabled', 'equalto', true) | list }}"

####################
# Keystone
####################
vitrage_ks_services:
  - name: "vitrage"
    type: "rca"
    description: "Root Cause Analysis Service"
    endpoints:
      - {'interface': 'internal', 'url': '{{ vitrage_internal_endpoint }}'}
      - {'interface': 'public', 'url': '{{ vitrage_public_endpoint }}'}

vitrage_ks_users:
  - project: "service"
    user: "{{ vitrage_keystone_user }}"
    password: "{{ vitrage_keystone_password }}"
    role: "admin"
