Allow service definition non dependent on predefined types
diff --git a/haproxy/files/haproxy.cfg b/haproxy/files/haproxy.cfg
index 338fe92..e3ad387 100644
--- a/haproxy/files/haproxy.cfg
+++ b/haproxy/files/haproxy.cfg
@@ -58,19 +58,17 @@
{%- for bind in listen.binds %}
bind {{ bind.address }}:{{ bind.port }}
{%- endfor %}
- {%- if listen.type == 'http' %}
+ {%- if listen.get('type', None) == 'http' %}
mode http
balance roundrobin
option httplog
- {%- endif %}
- {%- if listen.type == 'rabbitmq' %}
+ {%- elif listen.get('type', None) == 'rabbitmq' %}
balance roundrobin
mode tcp
option tcpka
timeout client 48h
timeout server 48h
- {%- endif %}
- {%- if listen.type == 'mysql' %}
+ {%- elif listen.get('type', None) == 'mysql' %}
balance leastconn
mode tcp
option httpchk
@@ -80,8 +78,7 @@
timeout client 28801s
timeout server 28801s
option mysql-check user haproxy
- {%- endif %}
- {%- if listen.type == 'horizon' %}
+ {%- elif listen.get('type', None) == 'horizon' %}
balance source
capture cookie vgnvisitor= len 32
cookie SERVERID insert indirect nocache
@@ -91,49 +88,41 @@
option httpclose
option httplog
rspidel ^Set-cookie:\ IP=
- {%- endif %}
- {%- if listen.type == 'general-service' %}
+ {%- elif listen.get('type', None) == 'general-service' %}
mode http
balance roundrobin
option httplog
- {%- endif %}
- {%- if listen.type == 'openstack-service' %}
+ {%- elif listen.get('type', None) == 'openstack-service' %}
option httpchk
option httplog
option httpclose
- {%- endif %}
- {%- if listen.type == 'heat' %}
+ {%- elif listen.get('type', None) == 'heat' %}
balance source
option tcpka
option httpchk
option tcplog
- {%- endif %}
- {%- if listen.type == 'contrail-config' %}
+ {%- elif listen.get('type', None) == 'contrail-config' %}
mode http
stats enable
stats uri /
stats auth {{ listen.user }}:{{ listen.password }}
- {%- endif %}
- {%- if listen.type == 'contrail-api' %}
+ {%- elif listen.get('type', None) == 'contrail-api' %}
option nolinger
balance roundrobin
- {%- endif %}
- {%- if listen.type == 'contrail-analytics' %}
+ {%- elif listen.get('type', None) == 'contrail-analytics' %}
option nolinger
balance roundrobin
option tcp-check
tcp-check connect port 6379
default-server error-limit 1 on-error mark-down
- {%- endif %}
- {%- if listen.type == 'stats' %}
+ {%- elif listen.get('type', None) == 'stats' %}
mode http
stats enable
stats uri /
{%- if listen.user is defined %}
stats auth {{ listen.user }}:{{ listen.password }}
{%- endif %}
- {%- endif %}
- {%- if listen.type == 'admin' %}
+ {%- elif listen.get('type', None) == 'admin' %}
mode http
acl AuthOkay_ReadOnly http_auth(STATSUSERS)
acl AuthOkay_Admin http_auth_group(STATSUSERS) {{ listen.user }}
@@ -142,6 +131,16 @@
stats uri /
stats http-request auth realm admin_page unless AuthOkay_ReadOnly
stats admin if AuthOkay_Admin
+ {%- else %}
+ {# no type specified #}
+ mode {{ listen.mode|default('tcp') }}
+ {%- for acl in listen.get('acl', []) %}
+ acl {{ acl }}
+ {%- endfor %}
+ balance {{ listen.balance|default('roundrobin') }}
+ {%- for option in listen.get('options', []) %}
+ option {{ option }}
+ {%- endfor %}
{%- endif %}
{%- for server in listen.get('servers', []) %}
server {{ server.name }} {{ server.host }}:{{ server.port }} {{ server.get('params', '') }}
@@ -162,7 +161,7 @@
default_backend {{ listen_name }}-backend
backend {{ listen_name }}-backend
- {%- if listen.type == 'http' %}
+ {%- if listen.get('type', None) == 'http' %}
balance roundrobin
{%- endif %}
{%- for server in listen.get('servers', []) %}