---
solum_services:
  solum-api:
    container_name: solum_api
    group: solum-api
    enabled: true
    image: "{{ solum_api_image_full }}"
    volumes: "{{ solum_api_default_volumes + solum_api_extra_volumes }}"
    dimensions: "{{ solum_api_dimensions }}"
    healthcheck: "{{ solum_api_healthcheck }}"
  solum-worker:
    container_name: solum_worker
    group: solum-worker
    enabled: true
    image: "{{ solum_worker_image_full }}"
    volumes: "{{ solum_worker_default_volumes + solum_worker_extra_volumes }}"
    dimensions: "{{ solum_worker_dimensions }}"
    healthcheck: "{{ solum_worker_healthcheck }}"
  solum-deployer:
    container_name: solum_deployer
    group: solum-deployer
    enabled: true
    image: "{{ solum_deployer_image_full }}"
    volumes: "{{ solum_deployer_default_volumes + solum_deployer_extra_volumes }}"
    dimensions: "{{ solum_deployer_dimensions }}"
    healthcheck: "{{ solum_deployer_healthcheck }}"
    haproxy:
      solum_application_deployment:
        enabled: "{{ enable_solum }}"
        mode: "http"
        external: false
        port: "{{ solum_application_deployment_port }}"
        host_group: "solum-application-deployment"
      solum_application_deployment_external:
        enabled: "{{ enable_solum }}"
        mode: "http"
        external: true
        port: "{{ solum_application_deployment_port }}"
        host_group: "solum-application-deployment"
      solum_image_builder:
        enabled: "{{ enable_solum }}"
        mode: "http"
        external: false
        port: "{{ solum_image_builder_port }}"
        host_group: "solum-image-builder"
      solum_image_builder_external:
        enabled: "{{ enable_solum }}"
        mode: "http"
        external: true
        port: "{{ solum_image_builder_port }}"
        host_group: "solum-image-builder"
  solum-conductor:
    container_name: solum_conductor
    group: solum-conductor
    enabled: true
    image: "{{ solum_conductor_image_full }}"
    volumes: "{{ solum_conductor_default_volumes + solum_conductor_extra_volumes }}"
    dimensions: "{{ solum_conductor_dimensions }}"
    healthcheck: "{{ solum_conductor_healthcheck }}"

####################
# Config Validate
####################
solum_config_validation:
  - generator: "/solum/etc/solum/config-generator.conf"
    config: "/etc/solum/solum.conf"

####################
# Database
####################
solum_database_name: "solum"
solum_database_user: "{% if use_preconfigured_databases | bool and use_common_mariadb_user | bool %}{{ database_user }}{% else %}solum{% endif %}"
solum_database_address: "{{ database_address | put_address_in_context('url') }}:{{ database_port }}"

####################
# Database sharding
####################
solum_database_shard_root_user: "{% if enable_proxysql | bool %}root_shard_{{ solum_database_shard_id }}{% else %}{{ database_user }}{% endif %}"
solum_database_shard_id: "{{ mariadb_default_database_shard_id | int }}"
solum_database_shard:
  users:
    - user: "{{ solum_database_user }}"
      password: "{{ solum_database_password }}"
  rules:
    - schema: "{{ solum_database_name }}"
      shard_id: "{{ solum_database_shard_id }}"


####################
# Docker
####################
solum_tag: "{{ openstack_tag }}"

solum_worker_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/solum-worker"
solum_worker_tag: "{{ solum_tag }}"
solum_worker_image_full: "{{ solum_worker_image }}:{{ solum_worker_tag }}"

solum_deployer_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/solum-deployer"
solum_deployer_tag: "{{ solum_tag }}"
solum_deployer_image_full: "{{ solum_deployer_image }}:{{ solum_deployer_tag }}"

solum_conductor_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/solum-conductor"
solum_conductor_tag: "{{ solum_tag }}"
solum_conductor_image_full: "{{ solum_conductor_image }}:{{ solum_conductor_tag }}"

solum_api_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/solum-api"
solum_api_tag: "{{ solum_tag }}"
solum_api_image_full: "{{ solum_api_image }}:{{ solum_api_tag }}"

solum_api_dimensions: "{{ default_container_dimensions }}"
solum_worker_dimensions: "{{ default_container_dimensions }}"
solum_deployer_dimensions: "{{ default_container_dimensions }}"
solum_conductor_dimensions: "{{ default_container_dimensions }}"

solum_api_enable_healthchecks: "{{ enable_container_healthchecks }}"
solum_api_healthcheck_interval: "{{ default_container_healthcheck_interval }}"
solum_api_healthcheck_retries: "{{ default_container_healthcheck_retries }}"
solum_api_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}"
solum_api_healthcheck_test: ["CMD-SHELL", "healthcheck_curl http://{{ api_interface_address | put_address_in_context('url') }}:{{ solum_application_deployment_port }}"]
solum_api_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}"
solum_api_healthcheck:
  interval: "{{ solum_api_healthcheck_interval }}"
  retries: "{{ solum_api_healthcheck_retries }}"
  start_period: "{{ solum_api_healthcheck_start_period }}"
  test: "{% if solum_api_enable_healthchecks | bool %}{{ solum_api_healthcheck_test }}{% else %}NONE{% endif %}"
  timeout: "{{ solum_api_healthcheck_timeout }}"

solum_worker_enable_healthchecks: "{{ enable_container_healthchecks }}"
solum_worker_healthcheck_interval: "{{ default_container_healthcheck_interval }}"
solum_worker_healthcheck_retries: "{{ default_container_healthcheck_retries }}"
solum_worker_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}"
solum_worker_healthcheck_test: ["CMD-SHELL", "healthcheck_port solum-worker {{ om_rpc_port }}"]
solum_worker_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}"
solum_worker_healthcheck:
  interval: "{{ solum_worker_healthcheck_interval }}"
  retries: "{{ solum_worker_healthcheck_retries }}"
  start_period: "{{ solum_worker_healthcheck_start_period }}"
  test: "{% if solum_worker_enable_healthchecks | bool %}{{ solum_worker_healthcheck_test }}{% else %}NONE{% endif %}"
  timeout: "{{ solum_worker_healthcheck_timeout }}"

solum_deployer_enable_healthchecks: "{{ enable_container_healthchecks }}"
solum_deployer_healthcheck_interval: "{{ default_container_healthcheck_interval }}"
solum_deployer_healthcheck_retries: "{{ default_container_healthcheck_retries }}"
solum_deployer_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}"
solum_deployer_healthcheck_test: ["CMD-SHELL", "healthcheck_port solum-deployer {{ om_rpc_port }}"]
solum_deployer_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}"
solum_deployer_healthcheck:
  interval: "{{ solum_deployer_healthcheck_interval }}"
  retries: "{{ solum_deployer_healthcheck_retries }}"
  start_period: "{{ solum_deployer_healthcheck_start_period }}"
  test: "{% if solum_deployer_enable_healthchecks | bool %}{{ solum_deployer_healthcheck_test }}{% else %}NONE{% endif %}"
  timeout: "{{ solum_deployer_healthcheck_timeout }}"

solum_conductor_enable_healthchecks: "{{ enable_container_healthchecks }}"
solum_conductor_healthcheck_interval: "{{ default_container_healthcheck_interval }}"
solum_conductor_healthcheck_retries: "{{ default_container_healthcheck_retries }}"
solum_conductor_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}"
solum_conductor_healthcheck_test: ["CMD-SHELL", "healthcheck_port solum-conductor {{ om_rpc_port }}"]
solum_conductor_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}"
solum_conductor_healthcheck:
  interval: "{{ solum_conductor_healthcheck_interval }}"
  retries: "{{ solum_conductor_healthcheck_retries }}"
  start_period: "{{ solum_conductor_healthcheck_start_period }}"
  test: "{% if solum_conductor_enable_healthchecks | bool %}{{ solum_conductor_healthcheck_test }}{% else %}NONE{% endif %}"
  timeout: "{{ solum_conductor_healthcheck_timeout }}"

solum_api_default_volumes:
  - "{{ node_config_directory }}/solum-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 ~ '/solum/solum:/var/lib/kolla/venv/lib/python' ~ distro_python_version ~ '/site-packages/solum' if solum_dev_mode | bool else '' }}"
solum_worker_default_volumes:
  - "{{ node_config_directory }}/solum-worker/:{{ 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 ~ '/solum/solum:/var/lib/kolla/venv/lib/python' ~ distro_python_version ~ '/site-packages/solum' if solum_dev_mode | bool else '' }}"
solum_deployer_default_volumes:
  - "{{ node_config_directory }}/solum-deployer/:{{ 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 ~ '/solum/solum:/var/lib/kolla/venv/lib/python' ~ distro_python_version ~ '/site-packages/solum' if solum_dev_mode | bool else '' }}"
solum_conductor_default_volumes:
  - "{{ node_config_directory }}/solum-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/"
  - "{{ kolla_dev_repos_directory ~ '/solum/solum:/var/lib/kolla/venv/lib/python' ~ distro_python_version ~ '/site-packages/solum' if solum_dev_mode | bool else '' }}"

solum_extra_volumes: "{{ default_extra_volumes }}"
solum_api_extra_volumes: "{{ solum_extra_volumes }}"
solum_worker_extra_volumes: "{{ solum_extra_volumes }}"
solum_deployer_extra_volumes: "{{ solum_extra_volumes }}"
solum_conductor_extra_volumes: "{{ solum_extra_volumes }}"

####################
# OpenStack
####################
solum_image_builder_internal_endpoint: "{{ internal_protocol }}://{{ kolla_internal_fqdn | put_address_in_context('url') }}:{{ solum_image_builder_port }}"
solum_image_builder_public_endpoint: "{{ public_protocol }}://{{ kolla_external_fqdn | put_address_in_context('url') }}:{{ solum_image_builder_port }}"

solum_application_deployment_internal_endpoint: "{{ internal_protocol }}://{{ kolla_internal_fqdn | put_address_in_context('url') }}:{{ solum_application_deployment_port }}"
solum_application_deployment_public_endpoint: "{{ public_protocol }}://{{ kolla_external_fqdn | put_address_in_context('url') }}:{{ solum_application_deployment_port }}"

solum_logging_debug: "{{ openstack_logging_debug }}"

solum_keystone_user: "solum"

openstack_solum_auth: "{{ openstack_auth }}"

solum_api_workers: "{{ openstack_service_workers }}"

####################
# Kolla
####################
solum_git_repository: "{{ kolla_dev_repos_git }}/{{ project_name }}"
solum_dev_repos_pull: "{{ kolla_dev_repos_pull }}"
solum_dev_mode: "{{ kolla_dev_mode }}"
solum_source_version: "{{ kolla_source_version }}"

####################
# Keystone
####################
solum_ks_services:
  - name: "solum_image_builder"
    type: "image_builder"
    description: "Openstack Solum Image Builder"
    endpoints:
      - {'interface': 'internal', 'url': '{{ solum_image_builder_internal_endpoint }}'}
      - {'interface': 'public', 'url': '{{ solum_image_builder_public_endpoint }}'}
  - name: "solum_application_deployment"
    type: "application_deployment"
    description: "Openstack Solum Application Deployment"
    endpoints:
      - {'interface': 'internal', 'url': '{{ solum_application_deployment_internal_endpoint }}'}
      - {'interface': 'public', 'url': '{{ solum_application_deployment_public_endpoint }}'}

solum_ks_users:
  - project: "service"
    user: "{{ solum_keystone_user }}"
    password: "{{ solum_keystone_password }}"
    role: "admin"
