instance-zope.cfg.in 13.8 KB
Newer Older
1
{% set use_ipv6 = slapparameter_dict.get('use-ipv6', False) -%}
2 3
{% set next_port = slapparameter_dict['port-base'] -%}
{% set site_id = slapparameter_dict['site-id'] -%}
4
{% set zodb_dict = slapparameter_dict['zodb-dict'] -%}
5
{% set node_id_base = slapparameter_dict['name'] -%}
6 7 8 9 10 11 12 13 14 15 16
{% set part_list = [] -%}
{% set publish_list = [] -%}
{% set longrequest_logger_base_path = buildout_directory ~ '/var/log/longrequest_logger_' -%}
{% macro section(name) %}{% do part_list.append(name) %}{{ name }}{% endmacro -%}
{% set bin_directory = parameter_dict['buildout-bin-directory'] -%}
{#
XXX: This template only supports exactly one IPv4 and one IPv6 per
partition. No more (undefined result), no less (IndexError).
-#}
{% set ipv4 = (ipv4_set | list)[0] -%}

17 18
{% if slapparameter_dict['mysql-test-url-list'] -%}
[{{ section('test-runner') }}]
19 20 21
recipe = slapos.cookbook:erp5.test
certificate-authority-path = ${test-certificate-authority:ca-dir}
mysql-url-list = {{ dumps(slapparameter_dict['mysql-test-url-list']) }}
22 23 24
kumofs-url = {{ dumps(slapparameter_dict['kumofs-url']) }}
memcached-url = {{ dumps(slapparameter_dict['memcached-url']) }}
cloudooo-url = {{ dumps(slapparameter_dict['cloudooo-url']) }}
25 26 27 28 29 30 31 32 33 34
test-instance-path = ${directory:unit-test-path}
prepend-path = ${buildout:bin-directory}
run-unit-test = ${buildout:bin-directory}/runUnitTest
run-test-suite = ${buildout:bin-directory}/runTestSuite
openssl-binary = ${test-certificate-authority:openssl-binary}
run-unit-test-binary = {{ parameter_dict['bin-directory'] }}/runUnitTest
run-test-suite-binary = {{ parameter_dict['bin-directory'] }}/runTestSuite

[test-certificate-authority]
recipe = slapos.cookbook:certificate_authority
35
openssl-binary = ${binary-link:target-directory}/openssl
36
ca-dir = ${directory:test-ca-dir}
37
requests-directory = ${directory:test-ca-requests}
38
wrapper = ${directory:services}/test-ca
39 40 41 42
ca-private = ${directory:test-ca-private}
ca-certs = ${directory:test-ca-certs}
ca-newcerts = ${directory:test-ca-newcerts}
ca-crl = ${directory:test-ca-crl}
43
{%- endif %}
44

45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
[directory]
recipe = slapos.cookbook:mkdirectory
bin = ${buildout:directory}/bin
etc = ${buildout:directory}/etc
instance = ${:srv}/erp5shared
instance-constraint = ${:instance}/Constraint
instance-document = ${:instance}/Document
instance-etc = ${:instance}/etc
instance-etc-package-include = ${:instance}/etc/package-include
instance-extensions = ${:instance}/Extensions
instance-import = ${:instance}/import
instance-lib = ${:instance}/lib
instance-products = ${:instance}/Products
instance-propertysheet = ${:instance}/PropertySheet
instance-tests = ${:instance}/tests
log = ${:var}/log
run = ${:var}/run
services = ${:etc}/run
srv = ${buildout:directory}/srv
tmp = ${buildout:directory}/tmp
var = ${buildout:directory}/var
promises = ${:etc}/promise
67 68
unit-test-path = ${:srv}/test-instance/unit_test
test-ca-dir = ${:srv}/test-ca
69 70 71 72 73 74 75 76 77 78 79
test-ca-requests = ${:test-ca-dir}/requests
test-ca-private = ${:test-ca-dir}/private
test-ca-certs = ${:test-ca-dir}/certs
test-ca-newcerts = ${:test-ca-dir}/newcerts
test-ca-crl = ${:test-ca-dir}/crl
ca-dir = ${:srv}/ca
ca-requests = ${:ca-dir}/requests
ca-private = ${:ca-dir}/private
ca-certs = ${:ca-dir}/certs
ca-newcerts = ${:ca-dir}/newcerts
ca-crl = ${:ca-dir}/crl
80 81 82 83

[binary-link]
recipe = slapos.cookbook:symbolic.link
target-directory = ${directory:bin}
84
link-binary = {{ dumps(parameter_dict['link-binary']) }}
85 86

[certificate-authority-common]
87
requests-directory = ${directory:ca-requests}
88
ca-dir = ${directory:ca-dir}
89 90 91 92
ca-private = ${directory:ca-private}
ca-certs = ${directory:ca-certs}
ca-newcerts = ${directory:ca-newcerts}
ca-crl = ${directory:ca-crl}
93

94
[{{ section('certificate-authority') }}]
95 96
< = certificate-authority-common
recipe = slapos.cookbook:certificate_authority
97
openssl-binary = ${binary-link:target-directory}/openssl
98 99 100 101 102 103 104 105 106 107 108 109 110 111
wrapper = ${directory:services}/ca

{% if use_ipv6 -%}
{%   set ipv6 = (ipv6_set | list)[0] -%}

[ipv6toipv4-base]
recipe = slapos.cookbook:ipv6toipv4
runner-path = ${directory:services}/${:base-name}
6tunnel-path = {{ parameter_dict['6tunnel'] }}/bin/6tunnel
shell-path = {{ parameter_dict['dash'] }}/bin/dash
ipv4 = {{ ipv4 }}
ipv6 = {{ ipv6 }}
{% endif -%}

112 113 114 115 116
{% set hosts_dict = {} -%}
{% for alias, url in (
    ('erp5-memcached-volatile', slapparameter_dict['memcached-url']),
    ('erp5-memcached-persistent', slapparameter_dict['kumofs-url']),
    ('erp5-cloudooo', slapparameter_dict['cloudooo-url']),
117
    ('erp5-smtp', slapparameter_dict['smtp-url']),
118 119 120 121 122 123
  ) -%}
{%   do hosts_dict.__setitem__(
       alias,
       urlparse.urlparse(url).hostname,
     )  -%}
{%- endfor %}
124
{% for i, url in enumerate(slapparameter_dict['mysql-url-list']) -%}
125
{%   do hosts_dict.__setitem__(
126
       'erp5-catalog-' ~ i,
127 128 129 130
       urlparse.urlparse(url).hostname,
     ) -%}
{%- endfor %}
{% do hosts_dict.update(slapparameter_dict['hosts-dict']) -%}
131 132
[host-common]

133
[hosts-parameter]
134
# Used for both hosts and hostaliases sections.
135
host-dict = {{ dumps(hosts_dict) }}
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
hostalias-dict = {{ dumps(slapparameter_dict['hostalias-dict']) }}

# Note: there is a subtle difference between hosts and hostaliases files:
# - hosts files start with resolved, followed by alias(es) (only one alias per
#   line in this case)
# - hostaliases start with alias, followed by resolved
# ...so it's not possible to merge these templates (not a big deal anyway).

[hostaliases]
recipe = slapos.recipe.template:jinja2
template = inline: {{ '
  {% for alias, aliased in host_dict.items() -%}
  {{ alias }} {{ aliased }}
  {% endfor %}
' }}
rendered = ${directory:etc}/hostaliases
context = key host_dict hosts-parameter:hostalias-dict
153 154 155 156 157 158 159 160 161 162 163 164 165

[hosts]
recipe = slapos.recipe.template:jinja2
template = inline: {{ '
  {% for alias, aliased in host_dict.items() -%}
  {{ aliased }} {{ alias }}
  {% endfor %}
' }}
rendered = ${directory:etc}/hosts
context = key host_dict hosts-parameter:host-dict

[preload-userhosts-runzope-parameter]
runzope-binary = {{ bin_directory }}/runzope
166
userhosts = {{ parameter_dict['userhosts'] }}
167 168
shell-path = {{ parameter_dict['dash'] }}/bin/dash
hosts = ${hosts:rendered}
169
hostaliases = ${hostaliases:rendered}
170 171 172 173 174 175 176 177

[preload-userhosts-runzope]
recipe = slapos.recipe.template:jinja2
rendered = ${directory:bin}/runzope_userhosts_preloaded
context = section parameter_dict preload-userhosts-runzope-parameter
template = {{ parameter_dict['runzope-userhosts-preloaded-template'] }}
mode = 755

178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
{# Hack to deploy SSL certs via instance parameters -#}
{% for zodb in zodb_dict.itervalues() -%}
{%   set storage_dict = zodb.setdefault('storage-dict', {}) -%}
{%   if zodb['type'] == 'neo' and storage_dict.get('ssl', 1) -%}
{%     for k, v in (('_ca', 'ca.crt'),
                    ('_cert', 'neo.crt'),
                    ('_key', 'neo.key')) -%}
{%       if k in storage_dict -%}
[{{ section('neo-ssl-' + k[1:]) }}]
recipe = slapos.recipe.template:jinja2
rendered = ${directory:etc}/{{v}}
template = inline:{{'{{'}}pem}}
context = key pem :pem
pem = {{dumps(storage_dict.pop(k))}}

{%       endif -%}
{%     endfor -%}
{%   endif -%}
{% endfor -%}
{# endhack -#}

199 200
[zope-base]
recipe = slapos.cookbook:generic.zope.zeo.client
201
inituser = ${directory:instance}/inituser
202 203 204
user = {{ dumps(slapparameter_dict['inituser-login']) }}
password = {{ dumps(slapparameter_dict['inituser-password']) }}
timezone = {{ dumps(slapparameter_dict['timezone']) }}
205
tmp-path = ${directory:tmp}
206 207
instancehome-path = ${directory:instance}
home-path = ${buildout:directory}
208
bin-path = ${directory:bin}:{{ parameter_dict['coreutils'] }}/bin
209
site-zcml = ${directory:instance-etc}/site.zcml
210
runzope-binary = ${preload-userhosts-runzope:rendered}
211
bt5-repository =
212 213 214 215

[zope-conf-parameter-base]
ip = {{ ipv4 }}
site-id = {{ site_id }}
216
{% set zeo_dict = slapparameter_dict.get('zodb-zeo', {}) -%}
217
{% for name, zodb in zodb_dict.iteritems() -%}
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232
{%   set storage_dict = zodb.setdefault('storage-dict', {}) -%}
{%   if zodb['type'] == 'zeo' -%}
{%     do storage_dict.update(zeo_dict.get(name, ())) -%}
{%   else -%}
{%     if name == slapparameter_dict.get('neo-name') -%}
{%       do storage_dict.update(master_nodes=slapparameter_dict['neo-masters'],
                                name=slapparameter_dict['neo-cluster']) -%}
{%     endif -%}
{{     assert(storage_dict['master_nodes'], name) }}
{%     if storage_dict.pop('ssl', 1) -%}
{%       do storage_dict.update(ca='~/etc/ca.crt',
                                cert='~/etc/neo.crt',
                                key='~/etc/neo.key') -%}
{%     endif -%}
{%   endif -%}
233
{% endfor -%}
234
developer-list = {{ dumps(slapparameter_dict['developer-list']) }}
235 236 237 238
instance = ${directory:instance}
instance-products = ${directory:instance-products}
deadlock-path = /manage_debug_threads
deadlock-debugger-password = {{ dumps(slapparameter_dict['deadlock-debugger-password']) }}
239 240 241 242
{% if slapparameter_dict.get('tidstorage-ip') -%}
tidstorage-ip = {{ dumps(slapparameter_dict['tidstorage-ip']) }}
tidstorage-port = {{ dumps(slapparameter_dict['tidstorage-port']) }}
{% endif -%}
243
promise-path = ${erp5-promise:promise-path}
244 245
{% set thread_amount = slapparameter_dict['thread-amount'] -%}
thread-amount = {{ thread_amount }}
246 247 248 249 250 251 252 253
{% set webdav = slapparameter_dict['webdav'] -%}
webdav = {{ dumps(webdav) }}
{% if webdav -%}
{%   set timerserver_interval = 0 -%}
{% else -%}
{%   set timerserver_interval = slapparameter_dict['timerserver-interval'] -%}
{%- endif %}
timerserver-interval = {{ dumps(timerserver_interval) }}
254 255 256 257 258 259 260 261 262 263 264

[zope-conf-base]
recipe = slapos.recipe.template:jinja2
template = {{ parameter_dict['zope-conf-template'] }}

[logrotate-entry-base]
recipe = slapos.cookbook:logrotate.d
logrotate-entries = ${logrotate:logrotate-entries}
backup = ${logrotate:backup}

{% macro zope(
265
  index,
266 267 268 269
  port,
  longrequest_logger_timeout,
  longrequest_logger_interval
) -%}
270
{% set name = 'zope-' ~ index -%}
271 272 273 274 275 276 277 278 279 280 281
{% set conf_name = name ~ '-conf' -%}
{% set conf_parameter_name = conf_name ~ '-param' -%}
{% set zope_tunnel_section_name = name ~ '-ipv6toipv4' -%}
{% set zope_tunnel_base_name = zope_tunnel_section_name -%}
[{{ conf_parameter_name }}]
< = zope-conf-parameter-base
pid-file = ${directory:run}/{{ name }}.pid
lock-file = ${directory:run}/{{ name }}.lock
port = {{ port }}
event-log = ${directory:log}/{{ name }}-event.log
z2-log = ${directory:log}/{{ name }}-Z2.log
282
node-id = {{ dumps(node_id_base ~ '-' ~ index) }}
283
{% set log_list = [] -%}
284 285 286 287
{% set import_set = set() -%}
{% for db_name, zodb in zodb_dict.iteritems() -%}
{%   if zodb['type'] == 'neo' -%}
{%     do import_set.add('neo.client') -%}
288
{%     set log = '~/var/log/' ~ name ~ '-neo-' ~ db_name ~ '.log' -%}
289
{%     do log_list.append(log) -%}
290
{%     do zodb['storage-dict'].update(logfile=log) -%}
291 292
{%   endif -%}
{% endfor -%}
293 294
import-list = {{ dumps(list(import_set)) }}
zodb-dict = {{ dumps(zodb_dict) }}
295 296 297 298

[{{ conf_name }}]
< = zope-conf-base
rendered = ${directory:etc}/{{ name }}.conf
299
context =
300 301
  section parameter_dict {{ conf_parameter_name }}

302
[{{ section(name) }}]
303 304 305 306 307 308 309
< = zope-base
{% if longrequest_logger_interval < 0 -%}
longrequest-logger-file =
longrequest-logger-timeout =
longrequest-logger-interval =
{% else -%}
longrequest-logger-file = {{ longrequest_logger_base_path ~ name ~ ".log" }}
310 311
longrequest-logger-timeout = {{ longrequest_logger_timeout }}
longrequest-logger-interval = {{ longrequest_logger_interval }}
312 313 314 315 316 317
{% endif -%}
wrapper = ${directory:services}/{{ name }}
configuration-file = {{ '${' ~ conf_name ~ ':rendered}' }}

[{{ section("promise-" ~ name) }}]
recipe = slapos.cookbook:check_port_listening
318 319
hostname = {{ ipv4 }}
port = {{ port }}
320 321 322 323 324 325 326 327
path = ${directory:promises}/{{ name }}

{% if use_ipv6 -%}
[{{ zope_tunnel_section_name }}]
< = ipv6toipv4-base
base-name = {{ zope_tunnel_base_name }}
ipv6-port = {{ port }}
ipv4-port = {{ port }}
328
{%   do publish_list.append(("[" ~ ipv6 ~ "]:" ~ port, thread_amount, webdav)) -%}
329 330 331 332 333 334 335

[{{ section("promise-tunnel-" ~ name) }}]
recipe = slapos.cookbook:check_port_listening
hostname = {{ '${' ~ zope_tunnel_section_name ~ ':ipv6}' }}
port = {{ '${' ~ zope_tunnel_section_name ~ ':ipv6-port}' }}
path = ${directory:promises}/{{ zope_tunnel_base_name }}
{% else -%}
336
{%   do publish_list.append((ipv4 ~ ":" ~ port, thread_amount, webdav)) -%}
337 338 339 340 341
{% endif -%}

[{{ section('logrotate-entry-' ~ name) }}]
< = logrotate-entry-base
name = {{ name }}
342
log = {{ '${' ~ conf_parameter_name ~ ':event-log}' }} {{ '${' ~ conf_parameter_name ~ ':z2-log}' }} {{ '${' ~ name ~ ':longrequest-logger-file}' }} {{ ' '.join(log_list) }}
343
post = {{ bin_directory }}/slapos-kill --pidfile {{ '${' ~ conf_parameter_name ~ ':pid-file}' }} -s USR2
344 345
{% endmacro -%}

346 347 348 349 350 351 352
{% for i in range(slapparameter_dict['instance-count']) -%}
{{   zope(
       i,
       next_port,
       slapparameter_dict['longrequest-logger-timeout'],
       slapparameter_dict['longrequest-logger-interval'],
     ) }}
353 354 355
{%   set next_port = next_port + 1 -%}
{% endfor -%}

356
[publish]
357 358
recipe = slapos.cookbook:publish.serialised
zope-address-list = {{ dumps(publish_list) }}
359 360 361 362 363 364 365 366
{#
Note: hosts_dist is generated at zope level rather than at erp5 (root partition)
level, as it is easier: we can access urls as python values trivially here.
This has the downside of making each zope partition publish the (hopefuly) same
dict toward erp5 partition, violating the DRY principle and making the intent
hard to guess.
-#}
hosts-dict = {{ dumps(hosts_dict) }}
367 368 369 370

[erp5-promise]
recipe = slapos.cookbook:erp5.promise
promise-path = ${directory:etc}/erp5promise.cfg
371 372 373 374 375 376
kumofs-url = {{ dumps(slapparameter_dict['kumofs-url']) }}
memcached-url = {{ dumps(slapparameter_dict['memcached-url']) }}
cloudooo-url = {{ dumps(slapparameter_dict['cloudooo-url']) }}
smtp-url = {{ dumps(slapparameter_dict['smtp-url']) }}
bt5 = {{ dumps(slapparameter_dict['bt5']) }}
bt5-repository-url = {{ dumps(slapparameter_dict['bt5-repository-url']) }}
377

378 379 380 381 382
[monitor-instance-parameter]
monitor-httpd-ipv6 = {{ (ipv6_set | list)[0] }}
monitor-httpd-port = {{ next_port }}
monitor-title = Zope monitor

383
[buildout]
384 385 386
extends =
  {{ logrotate_cfg }}
  {{ parameter_dict['template-monitor'] }}
387 388 389
parts +=
  erp5-promise
  {{ part_list | join('\n  ') }}
390
  publish
391
versions = versions
392

393 394
[versions]
slapos.core = {{ slapos_core_version }}