---
zun_services:
  zun-api:
    container_name: zun_api
    group: zun-api
    enabled: true
    image: "{{ zun_api_image_full }}"
    volumes: "{{ zun_api_default_volumes + zun_api_extra_volumes }}"
    dimensions: "{{ zun_api_dimensions }}"
    healthcheck: "{{ zun_api_healthcheck }}"
    haproxy:
      zun_api:
        enabled: "{{ enable_zun }}"
        mode: "http"
        external: false
        port: "{{ zun_api_port }}"
        listen_port: "{{ zun_api_listen_port }}"
      zun_api_external:
        enabled: "{{ enable_zun }}"
        mode: "http"
        external: true
        external_fqdn: "{{ zun_external_fqdn }}"
        port: "{{ zun_api_public_port }}"
        listen_port: "{{ zun_api_listen_port }}"
  zun-wsproxy:
    container_name: zun_wsproxy
    group: zun-wsproxy
    enabled: true
    image: "{{ zun_wsproxy_image_full }}"
    volumes: "{{ zun_wsproxy_default_volumes + zun_wsproxy_extra_volumes }}"
    dimensions: "{{ zun_wsproxy_dimensions }}"
    healthcheck: "{{ zun_wsproxy_healthcheck }}"
    haproxy:
      zun_wsproxy:
        enabled: "{{ enable_zun }}"
        mode: "http"
        external: false
        port: "{{ zun_wsproxy_port }}"
      zun_wsproxy_external:
        enabled: "{{ enable_zun }}"
        mode: "http"
        external: true
        port: "{{ zun_wsproxy_port }}"
  zun-compute:
    container_name: zun_compute
    group: zun-compute
    enabled: true
    image: "{{ zun_compute_image_full }}"
    privileged: True
    volumes: "{{ zun_compute_default_volumes + zun_compute_extra_volumes + lookup('vars', 'run_default_volumes_' + kolla_container_engine) }}"
    dimensions: "{{ zun_compute_dimensions }}"
    healthcheck: "{{ zun_compute_healthcheck }}"
  zun-cni-daemon:
    container_name: zun_cni_daemon
    group: zun-cni-daemon
    enabled: true
    image: "{{ zun_cni_daemon_image_full }}"
    privileged: True
    volumes: "{{ zun_cni_daemon_default_volumes + zun_cni_daemon_extra_volumes + lookup('vars', 'run_default_volumes_' + kolla_container_engine) }}"
    dimensions: "{{ zun_cni_daemon_dimensions }}"
    healthcheck: "{{ zun_cni_daemon_healthcheck }}"

####################
# Config Validate
####################
zun_config_validation:
  - generator: "/zun/etc/zun/zun-config-generator.conf"
    config: "/etc/zun/zun.conf"

####################
## Database
####################
zun_database_name: "zun"
zun_database_user: "{% if use_preconfigured_databases | bool and use_common_mariadb_user | bool %}{{ database_user }}{% else %}zun{% endif %}"
zun_database_address: "{{ database_address | put_address_in_context('url') }}:{{ database_port }}"

####################
# Database sharding
####################
zun_database_shard_root_user: "{% if enable_proxysql | bool %}root_shard_{{ zun_database_shard_id }}{% else %}{{ database_user }}{% endif %}"
zun_database_shard_id: "{{ mariadb_default_database_shard_id | int }}"
zun_database_shard:
  users:
    - user: "{{ zun_database_user }}"
      password: "{{ zun_database_password }}"
  rules:
    - schema: "{{ zun_database_name }}"
      shard_id: "{{ zun_database_shard_id }}"


####################
## Docker
####################
zun_tag: "{{ openstack_tag }}"

zun_api_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/zun-api"
zun_api_tag: "{{ zun_tag }}"
zun_api_image_full: "{{ zun_api_image }}:{{ zun_api_tag }}"

zun_wsproxy_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/zun-wsproxy"
zun_wsproxy_tag: "{{ zun_tag }}"
zun_wsproxy_image_full: "{{ zun_wsproxy_image }}:{{ zun_wsproxy_tag }}"

zun_compute_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/zun-compute"
zun_compute_tag: "{{ zun_tag }}"
zun_compute_image_full: "{{ zun_compute_image }}:{{ zun_compute_tag }}"

zun_cni_daemon_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/zun-cni-daemon"
zun_cni_daemon_tag: "{{ zun_tag }}"
zun_cni_daemon_image_full: "{{ zun_cni_daemon_image }}:{{ zun_cni_daemon_tag }}"


zun_api_dimensions: "{{ default_container_dimensions }}"
zun_wsproxy_dimensions: "{{ default_container_dimensions }}"
zun_compute_dimensions: "{{ default_container_dimensions }}"
zun_cni_daemon_dimensions: "{{ default_container_dimensions }}"

zun_api_enable_healthchecks: "{{ enable_container_healthchecks }}"
zun_api_healthcheck_interval: "{{ default_container_healthcheck_interval }}"
zun_api_healthcheck_retries: "{{ default_container_healthcheck_retries }}"
zun_api_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}"
zun_api_healthcheck_test: ["CMD-SHELL", "healthcheck_curl http://{{ api_interface_address | put_address_in_context('url') }}:{{ zun_api_port }}"]
zun_api_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}"
zun_api_healthcheck:
  interval: "{{ zun_api_healthcheck_interval }}"
  retries: "{{ zun_api_healthcheck_retries }}"
  start_period: "{{ zun_api_healthcheck_start_period }}"
  test: "{% if zun_api_enable_healthchecks | bool %}{{ zun_api_healthcheck_test }}{% else %}NONE{% endif %}"
  timeout: "{{ zun_api_healthcheck_timeout }}"

zun_wsproxy_enable_healthchecks: "{{ enable_container_healthchecks }}"
zun_wsproxy_healthcheck_interval: "{{ default_container_healthcheck_interval }}"
zun_wsproxy_healthcheck_retries: "{{ default_container_healthcheck_retries }}"
zun_wsproxy_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}"
zun_wsproxy_healthcheck_test: ["CMD-SHELL", "healthcheck_listen zun-wsproxy {{ zun_wsproxy_port }}"]
zun_wsproxy_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}"
zun_wsproxy_healthcheck:
  interval: "{{ zun_wsproxy_healthcheck_interval }}"
  retries: "{{ zun_wsproxy_healthcheck_retries }}"
  start_period: "{{ zun_wsproxy_healthcheck_start_period }}"
  test: "{% if zun_wsproxy_enable_healthchecks | bool %}{{ zun_wsproxy_healthcheck_test }}{% else %}NONE{% endif %}"
  timeout: "{{ zun_wsproxy_healthcheck_timeout }}"

zun_compute_enable_healthchecks: "{{ enable_container_healthchecks }}"
zun_compute_healthcheck_interval: "{{ default_container_healthcheck_interval }}"
zun_compute_healthcheck_retries: "{{ default_container_healthcheck_retries }}"
zun_compute_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}"
zun_compute_healthcheck_test: ["CMD-SHELL", "healthcheck_port zun-compute {{ om_rpc_port }}"]
zun_compute_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}"
zun_compute_healthcheck:
  interval: "{{ zun_compute_healthcheck_interval }}"
  retries: "{{ zun_compute_healthcheck_retries }}"
  start_period: "{{ zun_compute_healthcheck_start_period }}"
  test: "{% if zun_compute_enable_healthchecks | bool %}{{ zun_compute_healthcheck_test }}{% else %}NONE{% endif %}"
  timeout: "{{ zun_compute_healthcheck_timeout }}"

zun_cni_daemon_enable_healthchecks: "{{ enable_container_healthchecks }}"
zun_cni_daemon_healthcheck_interval: "{{ default_container_healthcheck_interval }}"
zun_cni_daemon_healthcheck_retries: "{{ default_container_healthcheck_retries }}"
zun_cni_daemon_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}"
zun_cni_daemon_healthcheck_test: ["CMD-SHELL", "healthcheck_listen zun-cni-daemon {{ zun_cni_daemon_port }}"]
zun_cni_daemon_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}"
zun_cni_daemon_healthcheck:
  interval: "{{ zun_cni_daemon_healthcheck_interval }}"
  retries: "{{ zun_cni_daemon_healthcheck_retries }}"
  start_period: "{{ zun_cni_daemon_healthcheck_start_period }}"
  test: "{% if zun_cni_daemon_enable_healthchecks | bool %}{{ zun_cni_daemon_healthcheck_test }}{% else %}NONE{% endif %}"
  timeout: "{{ zun_cni_daemon_healthcheck_timeout }}"

zun_api_default_volumes:
  - "{{ node_config_directory }}/zun-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 ~ '/zun/zun:/var/lib/kolla/venv/lib/python' ~ distro_python_version ~ '/site-packages/zun' if zun_dev_mode | bool else '' }}"
  - "kolla_logs:/var/log/kolla/"
  - "{{ '/dev/shm:/dev/shm' if om_enable_queue_manager | bool else '' }}"
zun_wsproxy_default_volumes:
  - "{{ node_config_directory }}/zun-wsproxy/:{{ 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 ~ '/zun/zun:/var/lib/kolla/venv/lib/python' ~ distro_python_version ~ '/site-packages/zun' if zun_dev_mode | bool else '' }}"
  - "kolla_logs:/var/log/kolla/"
  - "{{ '/dev/shm:/dev/shm' if om_enable_queue_manager | bool else '' }}"
zun_compute_default_volumes:
  - "{{ node_config_directory }}/zun-compute/:{{ 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 ~ '/zun/zun:/var/lib/kolla/venv/lib/python' ~ distro_python_version ~ '/site-packages/zun' if zun_dev_mode | bool else '' }}"
  - "/run:/run{{ ':shared' if kolla_container_engine == 'docker' else '' }}"
  - "/usr/lib/docker:/usr/lib/docker"
  - "/var/lib/docker:/var/lib/docker"
  - "/lib/modules:/lib/modules:ro"
  - "/dev:/dev"
  - "{% if enable_iscsid | bool %}iscsi_info:/etc/iscsi{% endif %}"
  - "{% if zun_configure_for_cinder_ceph | bool %}/var/lib/zun:/var/lib/zun:shared{% endif %}"
zun_cni_daemon_default_volumes:
  - "{{ node_config_directory }}/zun-cni-daemon/:{{ 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 ~ '/zun/zun:/var/lib/kolla/venv/lib/python' ~ distro_python_version ~ '/site-packages/zun' if zun_dev_mode | bool else '' }}"
  - "/run:/run{{ ':shared' if kolla_container_engine == 'docker' else '' }}"

zun_extra_volumes: "{{ default_extra_volumes }}"
zun_api_extra_volumes: "{{ zun_extra_volumes }}"
zun_wsproxy_extra_volumes: "{{ zun_extra_volumes }}"
zun_compute_extra_volumes: "{{ zun_extra_volumes }}"
zun_cni_daemon_extra_volumes: "{{ zun_extra_volumes }}"

####################
## OpenStack
####################
zun_internal_endpoint: "{{ zun_internal_fqdn | kolla_url(internal_protocol, zun_api_port, '/v1/') }}"
zun_public_endpoint: "{{ zun_external_fqdn | kolla_url(public_protocol, zun_api_public_port, '/v1/') }}"

zun_logging_debug: "{{ openstack_logging_debug }}"

zun_keystone_user: "zun"

openstack_zun_auth: "{{ openstack_auth }}"

zun_api_workers: "{{ openstack_service_workers }}"

####################
# Kolla
####################
zun_git_repository: "{{ kolla_dev_repos_git }}/{{ project_name }}"
zun_dev_repos_pull: "{{ kolla_dev_repos_pull }}"
zun_dev_mode: "{{ kolla_dev_mode }}"
zun_source_version: "{{ kolla_source_version }}"

####################
# Keystone
####################
zun_ks_services:
  - name: "zun"
    type: "container"
    description: "Container Service"
    endpoints:
      - {'interface': 'internal', 'url': '{{ zun_internal_endpoint }}'}
      - {'interface': 'public', 'url': '{{ zun_public_endpoint }}'}

zun_ks_users:
  - project: "service"
    user: "{{ zun_keystone_user }}"
    password: "{{ zun_keystone_password }}"
    role: "admin"

zun_ceph_cluster: "ceph"
