{#   Copyright (c) 2015 Rackspace
#
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.
#
#}
# Configuration for loadbalancer {{ loadbalancer_id }}
global
    daemon
    user nobody
    log {{ log_http | default('/run/rsyslog/octavia/log', true)}} local{{ user_log_facility }}
    log {{ log_server | default('/run/rsyslog/octavia/log', true)}} local{{ administrative_log_facility }} notice
    stats socket {{ sock_path }} mode 0666 level user
    {% if state_file %}
    server-state-file {{ state_file }}
    {% endif %}
    {% if loadbalancer.global_connection_limit is defined %}
    maxconn {{ loadbalancer.global_connection_limit }}
    {% endif %}
    {% if ssl_cache is defined %}
    tune.ssl.cachesize {{ ssl_cache }}
    {% endif %}
    {%- if cpu_count is defined and cpu_count > 1 %}
    nbthread {{ cpu_count - 1 }}
    cpu-map auto:1/1-{{ cpu_count - 1 }} 1-{{ cpu_count - 1 }}
    {%- endif %}
    {% set found_ns = namespace(found=false) %}
    {% for listener in loadbalancer.listeners if listener.enabled %}
        {% for pool in listener.pools if pool.enabled %}
            {% if pool.health_monitor and pool.health_monitor.enabled and
                  pool.health_monitor.type == constants.HEALTH_MONITOR_PING and
                  found_ns.found == false %}
                {% set found_ns.found = true %}
    external-check
                {% if require_insecure_fork %}
    insecure-fork-wanted
                {% endif %}
            {% endif %}
        {% endfor %}
    {% endfor %}

defaults
    {% if connection_logging %}
    log global
    {% else %}
    no log
    {% endif %}
    retries 3
    option redispatch
    option splice-request
    option splice-response
    option http-keep-alive

{% block peers %}{% endblock peers %}

{% block prometheus %}{% endblock prometheus %}

{% block proxies %}{% endblock proxies %}
