---
redis_services:
  redis:
    container_name: redis
    group: redis
    enabled: true
    image: "{{ redis_image_full }}"
    volumes: "{{ redis_default_volumes + redis_extra_volumes }}"
    dimensions: "{{ redis_dimensions }}"
    healthcheck: "{{ redis_healthcheck }}"
  redis-sentinel:
    container_name: redis_sentinel
    group: redis
    environment:
      REDIS_CONF: "{{ redis_conf_path }}"
      REDIS_GEN_CONF: "{{ redis_generated_conf_path }}"
    enabled: true
    image: "{{ redis_sentinel_image_full }}"
    volumes: "{{ redis_sentinel_default_volumes + redis_sentinel_extra_volumes }}"
    dimensions: "{{ redis_sentinel_dimensions }}"
    healthcheck: "{{ redis_sentinel_healthcheck }}"

####################
# Docker
####################
redis_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ docker_image_name_prefix }}redis"
redis_tag: "{{ openstack_tag }}"
redis_image_full: "{{ redis_image }}:{{ redis_tag }}"

redis_sentinel_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ docker_image_name_prefix }}redis-sentinel"
redis_sentinel_tag: "{{ openstack_tag }}"
redis_sentinel_image_full: "{{ redis_sentinel_image }}:{{ redis_tag }}"
redis_dimensions: "{{ default_container_dimensions }}"
redis_sentinel_dimensions: "{{ default_container_dimensions }}"

redis_enable_healthchecks: "{{ enable_container_healthchecks }}"
redis_healthcheck_interval: "{{ default_container_healthcheck_interval }}"
redis_healthcheck_retries: "{{ default_container_healthcheck_retries }}"
redis_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}"
redis_healthcheck_test: ["CMD-SHELL", "healthcheck_listen redis-server {{ redis_port }}"]
redis_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}"
redis_healthcheck:
  interval: "{{ redis_healthcheck_interval }}"
  retries: "{{ redis_healthcheck_retries }}"
  start_period: "{{ redis_healthcheck_start_period }}"
  test: "{% if redis_enable_healthchecks | bool %}{{ redis_healthcheck_test }}{% else %}NONE{% endif %}"
  timeout: "{{ redis_healthcheck_timeout }}"

redis_sentinel_enable_healthchecks: "{{ enable_container_healthchecks }}"
redis_sentinel_healthcheck_interval: "{{ default_container_healthcheck_interval }}"
redis_sentinel_healthcheck_retries: "{{ default_container_healthcheck_retries }}"
redis_sentinel_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}"
redis_sentinel_healthcheck_test: ["CMD-SHELL", "healthcheck_listen redis-sentinel {{ redis_sentinel_port }}"]
redis_sentinel_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}"
redis_sentinel_healthcheck:
  interval: "{{ redis_sentinel_healthcheck_interval }}"
  retries: "{{ redis_sentinel_healthcheck_retries }}"
  start_period: "{{ redis_sentinel_healthcheck_start_period }}"
  test: "{% if redis_sentinel_enable_healthchecks | bool %}{{ redis_sentinel_healthcheck_test }}{% else %}NONE{% endif %}"
  timeout: "{{ redis_sentinel_healthcheck_timeout }}"

redis_default_volumes:
  - "{{ node_config_directory }}/redis/:{{ container_config_directory }}/:ro"
  - "/etc/localtime:/etc/localtime:ro"
  - "{{ '/etc/timezone:/etc/timezone:ro' if ansible_facts.os_family == 'Debian' else '' }}"
  - "{{ project_name }}:/var/lib/redis/"
  - "kolla_logs:/var/log/kolla/"
redis_sentinel_default_volumes:
  - "{{ node_config_directory }}/redis-sentinel/:{{ 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/"

redis_extra_volumes: "{{ default_extra_volumes }}"
redis_sentinel_extra_volumes: "{{ default_extra_volumes }}"

redis_conf_path: "/etc/redis/redis.conf"
redis_generated_conf_path: "/etc/redis/redis-regenerated-by-config-rewrite.conf"
