[buildout]
extends = {{ software_parameter_dict['profile_common'] }}

parts =
  software-py
  switch-softwaretype

[software-py]
recipe = software

[jinja2-template-base]
recipe = slapos.recipe.template:jinja2
output = ${buildout:directory}/${:filename}
extensions = jinja2.ext.do
extra-context =
context =
    import json_module json
    key slapparameter_dict slap-configuration:configuration
    section instance_parameter_dict slap-configuration
    section software_parameter_dict software-parameter-section
    ${:extra-context}
caucase-jinja2-library = {{ software_parameter_dict['caucase_jinja2_library'] }}
import-list =
  file caucase :caucase-jinja2-library

[switch-softwaretype]
recipe = slapos.cookbook:switch-softwaretype
default = dynamic-profile-master:output
RootSoftwareInstance = ${:default}
custom-personal = dynamic-profile-master:output
single-default = dynamic-profile-frontend:output
single-custom-personal = dynamic-profile-frontend:output
replicate = dynamic-profile-master:output
kedifa = dynamic-profile-kedifa:output

[software-parameter-section]
{% for key,value in software_parameter_dict.items() %}
{{ key }} = {{ dumps(value) }}
{% endfor -%}

[dynamic-profile-frontend]
< = jinja2-template-base
url = {{ software_parameter_dict['profile_frontend'] }}
filename = instance-frontend.cfg
extra-context =
  import furl_module furl
  raw software_type single-custom-personal

[dynamic-profile-master]
< = jinja2-template-base
depends = ${software-py:recipe}
url = {{ software_parameter_dict['profile_master'] }}
filename = instance-master.cfg
extra-context =
    import subprocess_module subprocess
    import functools_module functools
    import operator_module operator
    import validators validators
    import software software
# Must match the key id in [switch-softwaretype] which uses this section.
    raw software_type RootSoftwareInstance-default-custom-personal-replicate

[dynamic-profile-kedifa]
< = jinja2-template-base
url = {{ software_parameter_dict['profile_kedifa'] }}
filename = instance-kedifa.cfg
extra-context =
  raw software_type kedifa

[slap-configuration]
# Fetches parameters defined in SlapOS Master for this instance.
# Always the same.
recipe = slapos.cookbook:slapconfiguration.serialised
computer = ${slap-connection:computer-id}
partition = ${slap-connection:partition-id}
url = ${slap-connection:server-url}
key = ${slap-connection:key-file}
cert = ${slap-connection:cert-file}
# Define default parameter(s) that will be used later, in case user didn't
# specify it
# All parameters are available through the configuration.XX syntax.
# All possible parameters should have a default.
configuration.domain = example.org
configuration.port = 4443
configuration.plain_http_port = 8080
configuration.plain_nginx_port = 8081
configuration.nginx_port = 9443
configuration.kedifa_port = 7879
# Warning: Caucase takes also cacuase_port+1
configuration.caucase_port = 8890
configuration.caucase_backend_client_port = 8990
configuration.apache-key =
configuration.apache-certificate =
configuration.disk-cache-size = 8G
configuration.ram-cache-size = 1G
configuration.re6st-verification-url =
configuration.enable-http2-by-default = true
configuration.enable-http3 = false
configuration.http3-port = 443
configuration.ciphers = ECDHE-ECDSA-AES256-GCM-SHA384 ECDHE-RSA-AES256-GCM-SHA384 ECDHE-ECDSA-AES128-GCM-SHA256 ECDHE-RSA-AES128-GCM-SHA256 ECDHE-ECDSA-AES256-SHA ECDHE-ECDSA-CHACHA20-POLY1305 ECDHE-RSA-CHACHA20-POLY1305 ECDHE-RSA-AES256-SHA ECDHE-RSA-AES128-SHA ECDHE-ECDSA-AES256-SHA ECDHE-ECDSA-AES128-SHA AES256-SHA AES128-SHA ECDHE-RSA-DES-CBC3-SHA DES-CBC3-SHA
configuration.request-timeout = 600
configuration.frontend-name =
configuration.backend-connect-timeout = 5
configuration.backend-connect-retries = 3
configuration.backend-haproxy-http-port = 21080
configuration.backend-haproxy-https-port = 21443
configuration.backend-haproxy-statistic-port = 21444
configuration.authenticate-to-backend = False
configuration.rotate-num = 4000
configuration.slave-introspection-https-port = 22443
