[buildout]

parts =
  switch_softwaretype

eggs-directory = {{ buildout_egg_directory }}
develop-eggs-directory = {{ buildout_develop_directory }}
offline = true

[switch_softwaretype]
recipe = slapos.cookbook:switch-softwaretype
default = dynamic-template-lamp:output
RootSoftwareInstance = ${:default}
mariadb = dynamic-template-mariadb:output
apache = dynamic-template-apache-php:output

[slap-configuration]
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}

[jinja2-template-base]
recipe = slapos.recipe.template:jinja2
output = ${buildout:directory}/${:filename}
extensions = jinja2.ext.do
extra-context =
context =
  key develop_eggs_directory buildout:develop-eggs-directory
  key eggs_directory buildout:eggs-directory
  key ipv4 slap-configuration:ipv4
  key ipv6 slap-configuration:ipv6
  key slapparameter_dict slap-configuration:configuration
  key computer_id slap-configuration:computer
  raw template_monitor {{ template_monitor }}
  raw openssl_location {{ openssl_location }}
  raw logrotate_cfg {{ logrotate_cfg }}
  ${:extra-context}


[dynamic-template-lamp-parameters]


[dynamic-template-lamp]
<= jinja2-template-base
url = {{ template_lamp }}
filename = template-lamp.cfg
extra-context =
  section parameter_dict dynamic-template-lamp-parameters

[dynamic-template-apache-php-parameters]
application-location = {{ application_location }}
application-part-list = {{ application_deployment_part_list }}
template-apache-conf = {{ template_apache_conf }}
apache-location = {{ apache_location }}
apache-php-location = {{ apache_php_location }}
template-php-ini = {{ template_php_ini }}

# XXX no failure if `custom_application_template` is empty
[application-parameters]
custom-application-template = {{ custom_application_template }}

[dynamic-template-apache-php]
<= jinja2-template-base
url = {{ template_apache_php }}
filename = template-apache-php.cfg
extra-context =
  key custom_application_template application-parameters:custom-application-template
  section parameter_dict dynamic-template-apache-php-parameters

[dynamic-template-mariadb-parameters]
bash = {{ bash_location }}
coreutils-location = {{ coreutils_location }}
dash-location = {{ dash_location }}
findutils-location = {{ findutils_location }}
gzip-location = {{ gzip_location }}
xz-utils-location = {{ xz_utils_location }}
mariadb-location = {{ mariadb_location }}
template-my-cnf = {{ template_my_cnf }}
template-mariadb-initial-setup = {{ template_mariadb_initial_setup }}
template-mysqld-wrapper = {{ template_mysqld_wrapper }}
link-binary = {{ dumps(mariadb_link_binary) }}
mariadb-resiliency-after-import-script = {{ mariadb_resiliency_after_import_script }}
mariadb-slow-query-report-script = {{ mariadb_slow_query_report_script }}
mariadb-start-clone-from-backup = {{ mariadb_start_clone_from_backup }}
promise-check-slow-queries-digest-result = {{ bin_directory }}/check-slow-queries-digest-result
percona-tools-location = {{ percona_toolkit_location }}
unixodbc-location = {{ unixodbc_location }}
mroonga-mariadb-install-sql = {{ mroonga_mariadb_install_sql }}
mroonga-mariadb-plugin-dir = {{ mroonga_mariadb_plugin_dir }}
groonga-plugins-path = {{ groonga_plugin_dir }}:{{ groonga_mysql_normalizer_plugin_dir }}
check-computer-memory-binary = {{ bin_directory }}/check-computer-memory
bin-directory = {{ bin_directory }}

[dynamic-template-mariadb]
<= jinja2-template-base
url = {{ template_mariadb }}
filename = instance-mariadb.cfg
extra-context =
    key ipv4_set slap-configuration:ipv4
    key ipv6_set slap-configuration:ipv6
    raw bin_directory {{ bin_directory }}
    section parameter_dict dynamic-template-mariadb-parameters
