---
placement_services:
  placement-api:
    container_name: "placement_api"
    group: "placement-api"
    image: "{{ placement_api_image_full }}"
    enabled: True
    volumes: "{{ placement_api_default_volumes + placement_api_extra_volumes }}"
    dimensions: "{{ placement_api_dimensions }}"
    healthcheck: "{{ placement_api_healthcheck }}"
    haproxy:
      placement_api:
        enabled: "{{ enable_placement }}"
        mode: "http"
        external: false
        port: "{{ placement_api_port }}"
        listen_port: "{{ placement_api_listen_port }}"
        tls_backend: "{{ placement_enable_tls_backend }}"
      placement_api_external:
        enabled: "{{ enable_placement }}"
        mode: "http"
        external: true
        external_fqdn: "{{ placement_external_fqdn }}"
        port: "{{ placement_api_public_port }}"
        listen_port: "{{ placement_api_listen_port }}"
        tls_backend: "{{ placement_enable_tls_backend }}"

####################
# Config Validate
####################
placement_config_validation:
  - generator: "/placement/etc/placement/config-generator.conf"
    config: "/etc/placement/placement.conf"

####################
# Database
####################
placement_database_name: "placement"
placement_database_user: "{% if use_preconfigured_databases | bool and use_common_mariadb_user | bool %}{{ database_user }}{% else %}placement{% endif %}"
placement_database_address: "{{ database_address | put_address_in_context('url') }}:{{ database_port }}"

####################
# Database sharding
####################
placement_database_shard_root_user: "{% if enable_proxysql | bool %}root_shard_{{ placement_database_shard_id }}{% else %}{{ database_user }}{% endif %}"
placement_database_shard_id: "{{ mariadb_default_database_shard_id | int }}"
placement_database_shard:
  users:
    - user: "{{ placement_database_user }}"
      password: "{{ placement_database_password }}"
  rules:
    - schema: "{{ placement_database_name }}"
      shard_id: "{{ placement_database_shard_id }}"


####################
# Docker
####################
placement_tag: "{{ openstack_tag }}"

placement_api_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/placement-api"
placement_api_tag: "{{ placement_tag }}"
placement_api_image_full: "{{ placement_api_image }}:{{ placement_api_tag }}"

placement_api_dimensions: "{{ default_container_dimensions }}"

placement_api_enable_healthchecks: "{{ enable_container_healthchecks }}"
placement_api_healthcheck_interval: "{{ default_container_healthcheck_interval }}"
placement_api_healthcheck_retries: "{{ default_container_healthcheck_retries }}"
placement_api_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}"
placement_api_healthcheck_test: ["CMD-SHELL", "healthcheck_curl {{ 'https' if placement_enable_tls_backend | bool else 'http' }}://{{ api_interface_address | put_address_in_context('url') }}:{{ placement_api_listen_port }}"]
placement_api_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}"
placement_api_healthcheck:
  interval: "{{ placement_api_healthcheck_interval }}"
  retries: "{{ placement_api_healthcheck_retries }}"
  start_period: "{{ placement_api_healthcheck_start_period }}"
  test: "{% if placement_api_enable_healthchecks | bool %}{{ placement_api_healthcheck_test }}{% else %}NONE{% endif %}"
  timeout: "{{ placement_api_healthcheck_timeout }}"

placement_api_default_volumes:
  - "{{ node_config_directory }}/placement-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/"
  - "{{ kolla_dev_repos_directory ~ '/placement/placement:/var/lib/kolla/venv/lib/python' ~ distro_python_version ~ '/site-packages/placement' if placement_dev_mode | bool else '' }}"

placement_api_extra_volumes: "{{ default_extra_volumes }}"

####################
# OpenStack
####################
placement_internal_endpoint: "{{ placement_internal_fqdn | kolla_url(internal_protocol, placement_api_port) }}"
placement_public_endpoint: "{{ placement_external_fqdn | kolla_url(public_protocol, placement_api_public_port) }}"

placement_logging_debug: "{{ openstack_logging_debug }}"

openstack_placement_auth: "{{ openstack_auth }}"

placement_api_workers: "{{ openstack_service_workers }}"

####################
# Notification
####################
placement_notification_topics:
  - name: notifications
    enabled: "{{ enable_ceilometer | bool or enable_neutron_infoblox_ipam_agent | bool }}"

placement_enabled_notification_topics: "{{ placement_notification_topics | selectattr('enabled', 'equalto', true) | list }}"


####################
# Kolla
####################
placement_git_repository: "{{ kolla_dev_repos_git }}/{{ project_name }}"
placement_dev_repos_pull: "{{ kolla_dev_repos_pull }}"
placement_dev_mode: "{{ kolla_dev_mode }}"
placement_source_version: "{{ kolla_source_version }}"

####################
# Upgrade
####################
nova_api_database_name: "nova_api"
nova_api_database_user: "{% if use_preconfigured_databases | bool and use_common_mariadb_user | bool %}{{ database_user }}{% else %}nova_api{% endif %}"
nova_api_database_host: "{{ database_address }}"
placement_database_host: "{{ database_address }}"

####################
# Keystone
####################
placement_ks_services:
  - name: "placement"
    type: "placement"
    description: "Placement Service"
    endpoints:
      - {'interface': 'internal', 'url': '{{ placement_internal_endpoint }}'}
      - {'interface': 'public', 'url': '{{ placement_public_endpoint }}'}

placement_ks_users:
  - project: "service"
    user: "{{ placement_keystone_user }}"
    password: "{{ placement_keystone_password }}"
    role: "admin"

####################
# TLS
####################
placement_enable_tls_backend: "{{ kolla_enable_tls_backend }}"
