Commit 2d3959df authored by Alain Takoudjou's avatar Alain Takoudjou

Sozu fixup for slave instance

parent 274e336d
......@@ -14,16 +14,16 @@
# not need these here).
[instance.cfg]
filename = instance.cfg.in
md5sum = 5b6d18ff660516bf583cf4fe2c2b8059
md5sum = 8a714ed894c0eb99cd8de49e588d0af4
[template-sozu]
filename = instance-sozu.cfg.jinja2.in
md5sum = ea453374e67377ce5b9acda7976a0a0e
md5sum = 5ec499b5cab85d9aa2b55ea6ff3cf701
[config.toml]
filename = config.toml.in
md5sum = 6d15b97ae88f6a6529cc7d993a58a163
md5sum = 3b407e5ee362e51de60ffb9f850f9cc0
[publish-sozu-slave-parameters.cfg]
filename = publish-sozu-slave-parameters.cfg.in
md5sum = 92f4dc0e8c08d9a66a2833ed035a07f6
md5sum = ee8dcb866fbe3b8916c6d2e5a28e19e3
......@@ -248,7 +248,7 @@ protocol = "{{ cluster_dict.get('protocol', 'http') }}"
# "ROUND_ROBIN", "RANDOM", "LEAST_LOADED" and "POWER_OF_TWO". Defaults to "ROUND_ROBIN"
load_balancing = "{{ cluster_dict.get('load-balancing', 'ROUND_ROBIN') }}"
# metric evaluating the load on the backend. available options: connections, requests, connection_time
load_metric = "{{ cluster_dict.get('load-metric', 'connections') }}"
load_metric = "{{ cluster_dict.get('load-metric', 'CONNECTIONS') }}"
# frontends configuration
# this specifies which listeners; domains, certificates that will be configured for a cluster
......@@ -264,12 +264,13 @@ load_metric = "{{ cluster_dict.get('load-metric', 'connections') }}"
frontends = [
{% for _, frontend_dict in cluster_dict['frontend-dict'].items() -%}
{% set enable_https = frontend_dict.get("certificate") and frontend_dict.get("key") and frontend_dict.get("chain") -%}
{% set tag_dict = {} -%}
{% for tag in frontend_dict['tag-list'] -%}
{% set tag_list = [] -%}
{% set user_tag_list = frontend_dict.get('tag-list', []) -%}
{% for tag in user_tag_list -%}
{% set k, v = tag.split('=') -%}
do tag_dict.__setitem__(k.strip(), v.strip()) -%}
{% do tag_list.append(k.strip() ~ '="' ~ v.strip() ~ '"') -%}
{% endfor -%}
{ address = "{{ frontend_dict['address'] }}", hostname = "{{ frontend_dict.get('hostname') }}", tags = tag_dict, path = "{{ frontend_dict.get('path', '') }}", path_type = {{ frontend_dict.get("path-type", "PREFIX") }}, sticky_session = {{ frontend_dict.get("sticky-session", "false") }}, https_redirect = {{ frontend_dict.get("https-redirect", "false") }}{% if enable_https -%}, tls_versions = {{ frontend_dict.get("tls-versions", []) }}, certificate = "{{ frontend_dict['certificate'] }}", key = "{{ frontend_dict['key'] }}", certificate_chain = "{{ frontend_dict['chain'] }}" {% endif -%} },
{ address = "{{ frontend_dict['address'] }}", hostname = "{{ frontend_dict.get('hostname') }}", {% if user_tag_list -%} tags = {{ tag_list | join(',') }}, {%- endif %} path = "{{ frontend_dict.get('path', '') }}", path_type = "{{ frontend_dict.get("path-type", "PREFIX") }}", sticky_session = {{ frontend_dict.get("sticky-session", "false") }}, https_redirect = {{ frontend_dict.get("https-redirect", "false") }}{% if enable_https -%}, tls_versions = {{ frontend_dict.get("tls-versions", []) }}, certificate = "{{ frontend_dict['certificate'] }}", key = "{{ frontend_dict['key'] }}", certificate_chain = "{{ frontend_dict['chain'] }}" {% endif -%} },
{% endfor -%}
]
......
......@@ -29,11 +29,11 @@
"title": "Load metric",
"description": "Metric evaluating the load on the backend. available options: connections, requests, connection_time.",
"type": "string",
"default": "connections",
"default": "CONNECTIONS",
"enum": [
"connections",
"requests",
"connection_time"
"CONNECTIONS",
"REQUESTS",
"CONNECTION_TIME"
]
},
"frontend-dict": {
......
......@@ -41,8 +41,10 @@ cert-file = ${ca-directory:certs}/${:name}.key
executable = echo "request certificate"
wrapper = ${directory:tmp}/ca-${:name}
{% for instance_dict in slave_instance_list -%}
{% set name = instance_dict['slave_reference'] -%}
{% for slave_dict in slave_instance_list %}
{% set instance_dict = json_module.loads(slave_dict['_']) -%}
{% set name = slave_dict['slave_reference'] -%}
{% set slave_title = slave_dict['slave_title'] -%}
{% set cert_section_name = '${' ~ name ~ '-ssl:cert-file}' -%}
{% set key_section_name = '${' ~ name ~ '-ssl:key-file}' -%}
......@@ -66,7 +68,7 @@ name = {{ name }}
{% do instance_dict['frontend-dict'][cluster_name].__setitem__('certificate-chain', '${' ~ name ~ cluster_name~ '-chain:output}') -%}
{% endif -%}
{% endfor -%}
{% do cluster_definition_dict.__setitem__(instance_dict['name'], instance_dict) -%}
{% do cluster_definition_dict.__setitem__(name, instance_dict) -%}
{% endfor -%}
[sozu-parameters]
......
......@@ -43,6 +43,7 @@ extra-context =
<= jinja2-template-base
url = {{ template_sozu_cfg }}
extra-context =
import json_module json
key slave_instance_list slap-configuration:slave-instance-list
raw sozu_bin {{ sozu_location }}/bin/sozu
......@@ -50,3 +51,8 @@ extra-context =
raw config_toml_in {{ config_toml }}
raw template_publish_slave {{ template_publish_slave }}
[slave-output.cfg]
recipe = slapos.recipe.template:jinja2
output= ${buildout:directory}/${:_buildout_section_name_}
inline =
${slap-configuration:configuration}
......@@ -10,13 +10,19 @@ key_file = ${slap-connection:key-file}
cert_file = ${slap-connection:cert-file}
{% for _, cluster in slave_dict.items() -%}
{% set slave_reference = cluster['slave_reference'] -%}
{% do part_list.append('publish-slave-' ~ slave_reference) -%}
[publish-slave-{{ slave_reference }}]
{% for reference, cluster_dict in slave_dict.items() -%}
{% do part_list.append('publish-slave-' ~ reference) -%}
{% set protocol = cluster_dict['protocol'] -%}
[publish-slave-{{ reference }}]
recipe = slapos.cookbook:publish
-slave-reference = {{ slave_reference }}
-slave-reference = {{ reference }}
{% for _, backend_dict in cluster_dict['backend-dict'].items() -%}
backend-url-{{ backend_dict['backend-id'] }} = https://{{ backend_dict['address'] }}
{% endfor %}
{% for _, frontend_dict in cluster_dict['frontend-dict'].items() -%}
frontend-url-{{ loop.index }} = {% if protocol == 'http' -%} https://{% endif %}{{ frontend_dict['address'] }}
{% endfor %}
{% endfor %}
[buildout]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment