1 {% if software_type == slap_software_type -%}
3 Note: all port counters are pre-incremented. No idea why base port is skipped.
5 {% set current_zeo_port = zeo_port_base | int -%}
6 {% set zope_port_base = zope_port_base | int -%}
7 {% set zope_dummy_list = [] -%}
8 {% set current_apache_port = apache_port_base | int -%}
9 {% set current_haproxy_port = haproxy_port_base | int -%}
10 {% set json = json_module.loads(slapparameter_dict['json']) -%}
11 {% set bin_directory = parameter_dict['buildout-bin-directory'] -%}
13 XXX: This template only supports exactly one IPv4 and one IPv6 per
14 partition. No more (undefined result), no less (IndexError).
16 {% set ipv4 = (ipv4_set | list)[0] -%}
17 {% set ipv6 = (ipv6_set | list)[0] -%}
19 BBB: erp5-ca['state'] has been configured as string by mistake. Keep this for
20 backward compatibility with existing automatically setup CAs.
22 {% set erp5_ca = json.get('erp5-ca', {
24 'email': 'nobody@example.com',
25 'state': "('State',)",
29 {% set site_id = json['site-id'] -%}
30 {% set part_list = [] -%}
31 {% set known_tid_storage_identifier_dict = {} -%}
32 {% set zodb_connection_list = [] -%}
33 {% macro section(name) %}{% do part_list.append(name) %}{{ name }}{% endmacro -%}
37 timerserver_interval=0,
38 longrequest_logger_file='',
39 longrequest_logger_timeout='',
40 longrequest_logger_interval=''
42 {% set conf_name = name ~ '-conf' -%}
43 {% set conf_parameter_name = conf_name ~ '-param' -%}
44 [{{ conf_parameter_name }}]
45 < = zope-conf-parameter-base
46 pid-file = ${directory:run}/{{ name }}.pid
47 lock-file = ${directory:run}/{{ name }}.lock
48 {% do zope_dummy_list.append(None) -%}
49 {% set offset = zope_dummy_list | length -%}
50 port = {{ zope_port_base + offset }}
51 thread-amount = {{ thread_amount }}
52 {% if timerserver_interval -%}
53 timerserver-interval = {{ timerserver_interval }}
55 event-log = ${directory:log}/{{ name }}-event.log
56 z2-log = ${directory:log}/{{ name }}-Z2.log
60 rendered = ${directory:etc}/{{ name }}.conf
62 section parameter_dict {{ conf_parameter_name }}
66 longrequest-logger-file = {{ longrequest_logger_file }}
67 longrequest-logger-timeout = {{ longrequest_logger_timeout }}
68 longrequest-logger-interval = {{ longrequest_logger_interval }}
69 wrapper = ${directory:services}/{{ name }}
70 configuration-file = {{ '${' ~ conf_name ~ ':rendered}' }}
71 port = {{ '${' ~ conf_parameter_name ~ ':port}' }}
73 [{{ section('logrotate-entry-' ~ name) }}]
75 recipe = slapos.cookbook:logrotate.d
77 log = {{ '${' ~ conf_parameter_name ~ ':event-log}' }} {{ '${' ~ conf_parameter_name ~ ':z2-log}' }}
78 post = {{ bin_directory }}/killpidfromfile {{ '${' ~ conf_parameter_name ~ ':pid-file}' }} SIGUSR2
80 #############################
82 #############################
84 recipe = slapos.cookbook:mkdirectory
85 apache-conf = ${:etc}/apache
86 backup = ${:srv}/backup
87 bin = ${buildout:directory}/bin
89 cron-entries = ${:etc}/cron.d
90 cronstamps = ${:etc}/cronstamps
91 crontabs = ${:etc}/crontabs
92 erp5-ca-dir = ${:srv}/erp5-ssl
93 etc = ${buildout:directory}/etc
94 instance = ${:srv}/erp5shared
95 instance-constraint = ${:instance}/Constraint
96 instance-document = ${:instance}/Document
97 instance-etc = ${:instance}/etc
98 instance-etc-package-include = ${:instance}/etc/package-include
99 instance-extensions = ${:instance}/Extensions
100 instance-import = ${:instance}/import
101 instance-lib = ${:instance}/lib
102 instance-products = ${:instance}/Products
103 instance-propertysheet = ${:instance}/PropertySheet
104 instance-tests = ${:instance}/tests
106 logrotate-backup = ${:backup}/logrotate
107 logrotate-entries = ${:etc}/logrotate.d
109 services = ${:etc}/run
110 srv = ${buildout:directory}/srv
111 tidstorage = ${:srv}/tidstorage
112 tmp = ${buildout:directory}/tmp
113 var = ${buildout:directory}/var
115 zodb-backup = ${:backup}/zodb
117 #############################
119 #############################
121 recipe = slapos.cookbook:symbolic.link
122 target-directory = ${directory:bin}
124 {{ parameter_dict['coreutils'] }}/bin/basename
125 {{ parameter_dict['coreutils'] }}/bin/cat
126 {{ parameter_dict['coreutils'] }}/bin/cp
127 {{ parameter_dict['coreutils'] }}/bin/ls
128 {{ parameter_dict['coreutils'] }}/bin/tr
129 {{ parameter_dict['coreutils'] }}/bin/uname
130 {{ parameter_dict['git'] }}/bin/git
131 {{ parameter_dict['graphviz'] }}/bin/dot
132 {{ parameter_dict['grep'] }}/bin/grep
133 {{ parameter_dict['imagemagick'] }}/bin/convert
134 {{ parameter_dict['imagemagick'] }}/bin/identify
135 {{ parameter_dict['mariadb'] }}/bin/mysql
136 {{ parameter_dict['mariadb'] }}/bin/mysqldump
137 {{ parameter_dict['sed'] }}/bin/sed
138 {{ parameter_dict['tesseract'] }}/bin/tesseract
139 {{ parameter_dict['w3m'] }}/bin/w3m
140 {{ parameter_dict['openssl'] }}/bin/openssl
141 {{ parameter_dict['poppler'] }}/bin/pdfinfo
142 {{ parameter_dict['poppler'] }}/bin/pdfseparate
143 {{ parameter_dict['poppler'] }}/bin/pdftotext
144 {{ parameter_dict['poppler'] }}/bin/pdftohtml
145 {{ parameter_dict['poppler'] }}/bin/pdfunite
146 {{ parameter_dict['dmtx-utils'] }}/bin/dmtxwrite
148 #############################
150 #############################
152 recipe = slapos.cookbook:mkdirectory
153 requests = ${directory:ca-dir}/requests
154 private = ${directory:ca-dir}/private
155 certs = ${directory:ca-dir}/certs
156 newcerts = ${directory:ca-dir}/newcerts
157 crl = ${directory:ca-dir}/crl
159 [certificate-authority]
160 recipe = slapos.cookbook:certificate_authority
161 openssl-binary = {{ parameter_dict['openssl'] }}/bin/openssl
162 ca-dir = ${directory:ca-dir}
163 requests-directory = ${cadirectory:requests}
164 wrapper = ${directory:services}/ca
165 ca-private = ${cadirectory:private}
166 ca-certs = ${cadirectory:certs}
167 ca-newcerts = ${cadirectory:newcerts}
168 ca-crl = ${cadirectory:crl}
170 #############################
172 #############################
174 recipe = slapos.cookbook:mkdirectory
175 requests = ${directory:erp5-ca-dir}/requests
176 private = ${directory:erp5-ca-dir}/private
177 certs = ${directory:erp5-ca-dir}/certs
178 newcerts = ${directory:erp5-ca-dir}/newcerts
179 crl = ${directory:erp5-ca-dir}/crl
181 [erp5-certificate-authority]
182 recipe = slapos.cookbook:certificate_authority
183 openssl-binary = {{ parameter_dict['openssl'] }}/bin/openssl
184 ca-dir = ${directory:erp5-ca-dir}
185 requests-directory = ${erp5-cadirectory:requests}
186 wrapper = ${directory:services}/erp5-ca
187 ca-private = ${erp5-cadirectory:private}
188 ca-certs = ${erp5-cadirectory:certs}
189 ca-newcerts = ${erp5-cadirectory:newcerts}
190 ca-crl = ${erp5-cadirectory:crl}
191 country-code = {{ erp5_ca['country-code'] }}
192 email = {{ erp5_ca['email'] }}
193 state = {{ erp5_ca['state'] }}
194 city = {{ erp5_ca['city'] }}
195 company = {{ erp5_ca['company'] }}
197 #############################
199 #############################
201 cron-entries = ${directory:cron-entries}
205 recipe = slapos.cookbook:cron
206 dcrond-binary = {{ parameter_dict['dcron'] }}/sbin/crond
207 crontabs = ${directory:crontabs}
208 cronstamps = ${directory:cronstamps}
209 catcher = ${cron-simplelogger:wrapper}
210 binary = ${directory:services}/crond
213 recipe = slapos.cookbook:simplelogger
214 wrapper = ${directory:bin}/cron_simplelogger
215 log = ${directory:log}/cron.log
217 #############################
219 #############################
221 logrotate-entries = ${directory:logrotate-entries}
222 backup = ${directory:logrotate-backup}
226 recipe = slapos.cookbook:logrotate
228 logrotate-binary = {{ parameter_dict['logrotate'] }}/usr/sbin/logrotate
229 gzip-binary = {{ parameter_dict['gzip'] }}/bin/gzip
230 gunzip-binary = {{ parameter_dict['gzip'] }}/bin/gunzip
232 wrapper = ${directory:bin}/logrotate
233 conf = ${directory:etc}/logrotate.conf
234 state-file = ${directory:srv}/logrotate.status
236 [cron-entry-logrotate]
238 recipe = slapos.cookbook:cron.d
240 frequency = 0 0 * * *
241 command = ${logrotate:wrapper}
243 #############################
245 #############################
247 recipe = slapos.cookbook:erp5.bootstrap
248 runner-path = ${directory:services}/erp5-bootstrap
249 mysql-url = {{ slapparameter_dict['mysql-url'] }}
250 zope-url = http://${zope-admin:user}:${zope-admin:password}@${zope-admin:ip}:${zope-admin:port}/{{ site_id }}
252 #############################
254 #############################
256 recipe = slapos.cookbook:erp5.promise
257 promise-path = ${directory:etc}/erp5promise.cfg
258 kumofs-url = {{ slapparameter_dict['kumofs-url'] }}
259 memcached-url = {{ slapparameter_dict['memcached-url'] }}
260 cloudooo-url = {{ slapparameter_dict['cloudooo-url'] }}
261 smtp-url = ${slap-parameter:smtp-url}
262 bt5 = ${slap-parameter:bt5}
263 bt5-repository-url = ${slap-parameter:bt5-repository-url}
265 #############################
267 #############################
268 [zeo-instance-entry-common]
269 recipe = slapos.cookbook:zeo
271 binary-path = {{ bin_directory }}/runzeo
273 {% for zeo_id, zeo_configuration_list in json['zeo'].iteritems() -%}
274 {% set current_zeo_port = current_zeo_port + 1 -%}
275 {% set storage_list = [] -%}
276 {% for zeo_slave in zeo_configuration_list -%}
277 {% do zodb_connection_list.append((
278 zeo_slave['storage-name'],
279 zeo_slave['mount-point'] % {'site-id': site_id},
280 zeo_slave['zope-cache-size'],
283 'cache-size': zeo_slave['zeo-cache-size'],
284 'server': ipv4 ~ ':' ~ current_zeo_port,
285 'storage': zeo_slave['storage-name'],
286 'name': zeo_slave['storage-name'],
289 {% set zodb_path = '${directory:zodb}/' ~ zeo_slave['storage-name'] ~ '.fs' -%}
290 {% do storage_list.append('storage-name=%(storage-name)s zodb-path=%(zodb-path)s' % {'zodb-path': zodb_path, 'storage-name': zeo_slave['storage-name']}) -%}
291 {% do known_tid_storage_identifier_dict.__setitem__("((('${zeo-instance-%(zeo_id)s:ip}', ${zeo-instance-%(zeo_id)s:port}),), '%(storage_name)s')" % {
293 'storage_name': zeo_slave['storage-name']
294 }, (zodb_path, '${directory:zodb-backup}/%s/' % zeo_slave['storage-name'], zeo_slave['serialize-path'] % {'site-id': site_id})) -%}
296 [{{ section('zeo-instance-%s' % zeo_id) }}]
297 < = zeo-instance-entry-common
298 log-path = ${directory:log}/zeo-{{ zeo_id }}.log
299 pid-path = ${directory:run}/zeo-{{ zeo_id }}.pid
300 conf-path = ${directory:etc}/zeo-{{ zeo_id }}.conf
301 port = {{ current_zeo_port }}
303 {{ storage_list | join('\n ') }}
304 wrapper-path = ${directory:services}/zeo-{{ zeo_id }}
306 [{{ section('logrotate-entry-zeo-%s' % zeo_id) }}]
308 recipe = slapos.cookbook:logrotate.d
309 name = zeo-{{ zeo_id }}
310 log = ${zeo-instance-{{ zeo_id }}:log-path}
311 post = {{ bin_directory }}/killpidfromfile ${zeo-instance-{{ zeo_id }}:pid-path} SIGUSR2
314 #############################
316 #############################
318 recipe = slapos.cookbook:generic.zope.zeo.client
321 timezone = {{ json['timezone'] }}
322 tidstorage-ip = ${tidstorage:ip}
323 tidstorage-port = ${tidstorage:port}
324 instance-etc = ${directory:instance-etc}
325 bt5-repository = ${directory:var}/bt5_repository
326 tmp-path = ${directory:tmp}
327 bin-path = ${directory:bin}
328 site-zcml = ${:instance-etc}/site.zcml
329 inituser = ${directory:instance}/inituser
330 runzope-binary = {{ bin_directory }}/runzope
331 bt5-repository-list =
333 [deadlock-debugger-password]
334 recipe = slapos.cookbook:pwgen.stable
336 [zope-conf-parameter-base]
338 site-id = {{ site_id }}
339 zodb-list = {{ dumps(zodb_connection_list) }}
342 recipe = slapos.recipe.template:jinja2
343 template = {{ parameter_dict['zope-conf-template'] }}
346 key instance directory:instance
347 key instance_products directory:instance-products
348 raw deadlock_path /manage_debug_threads
349 key deadlock_debugger_password deadlock-debugger-password:password
350 key tidstorage_ip tidstorage:ip
351 key tidstorage_port tidstorage:port
352 key promise_path erp5-promise:promise-path
356 {{ zope('zope-distribution', timerserver_interval=1) }}
358 {{ zope('zope-admin') }}
360 {% for q in range(1, json['activity']['zopecount'] + 1) -%}
361 {{ zope('zope-activity-%s' % q, timerserver_interval=1) }}
363 # Other zopes, apaches and haproxies
364 {% set publish_url_list = [] -%}
365 {% for backend_name, backend_configuration in json['backend'].iteritems() -%}
366 {% set haproxy_backend_list = [] -%}
367 {% set longrequest_logger = backend_configuration.get('longrequest-logger') -%}
368 {% for q in range(1, backend_configuration['zopecount'] + 1) -%}
369 {% set part_name = 'zope-%s-%s' % (backend_name, q) -%}
370 {% if longrequest_logger != None -%}
371 {% set longrequest_logger_file = '${directory:log}/%s-longrequest.log' % (part_name, ) -%}
372 {% set longrequest_logger_timeout = longrequest_logger.get('timeout', '4') -%}
373 {% set longrequest_logger_interval = longrequest_logger.get('interval', '2') -%}
375 {% set longrequest_logger_file = '' -%}
376 {% set longrequest_logger_timeout = '' -%}
377 {% set longrequest_logger_interval = '' -%}
381 thread_amount=backend_configuration['thread-amount'],
382 longrequest_logger_file=longrequest_logger_file,
383 longrequest_logger_timeout=longrequest_logger_timeout,
384 longrequest_logger_interval=longrequest_logger_interval,
386 {% do haproxy_backend_list.append('${%(part_name)s:ip}:${%(part_name)s:port}' % {'part_name': part_name}) -%}
388 {% set scheme = backend_configuration.get('scheme', ['https']) -%}
389 {% set current_apache_port = current_apache_port + 2 -%}
390 {% set current_haproxy_port = current_haproxy_port + 1 -%}
391 {% if 'http' in scheme -%}
392 {% set section_name = 'apache-public-' ~ backend_name -%}
393 {% do publish_url_list.append(
394 'url-public-%(backend_name)s = http://[${%(section_name)s:ip}]:${%(section_name)s:port}' % {
395 'backend_name': backend_name,
396 'section_name': section_name,
398 [{{ section(section_name) }}]
399 recipe = slapos.cookbook:apache.zope.backend
400 backend = http://${haproxy-{{ backend_name }}:ip}:${haproxy-{{ backend_name }}:port}
402 port = {{ current_apache_port }}
404 wrapper = ${directory:services}/apache-public-{{ backend_name }}
405 configuration-file = ${directory:apache-conf}/apache-public-{{ backend_name }}.conf
406 access-control-string = {{ backend_configuration['access-control-string'] }}
407 pid-file = ${directory:run}/apache-public-{{ backend_name }}.pid
408 lock-file = ${directory:run}/apache-public-{{ backend_name }}.lock
409 error-log = ${directory:log}/apache-public-{{ backend_name }}-error.log
410 access-log = ${directory:log}/apache-public-{{ backend_name }}-access.log
411 apache-binary = {{ parameter_dict['apache'] }}/bin/httpd
413 [{{ section('logrotate-entry-apache-public-' ~ backend_name) }}]
415 recipe = slapos.cookbook:logrotate.d
416 name = apache-public-{{ backend_name }}
417 log = ${apache-public-{{ backend_name }}:error-log} ${apache-public-{{ backend_name }}:access-log}
418 post = {{ bin_directory }}/killpidfromfile ${apache-public-{{ backend_name }}:pid-file} SIGUSR1
420 {% if 'https' in scheme -%}
421 {% set section_name = 'apache-' ~ backend_name -%}
422 {% do publish_url_list.append(
423 'url-%(backend_name)s = https://[${%(section_name)s:ip}]:${%(section_name)s:port}' % {
424 'backend_name': backend_name,
425 'section_name': section_name,
427 [{{ section(section_name) }}]
428 recipe = slapos.cookbook:apache.zope.backend
429 backend = http://${haproxy-{{ backend_name }}:ip}:${haproxy-{{ backend_name }}:port}
431 port = {{ current_apache_port - 1 }}
432 wrapper = ${directory:bin}/apache-{{ backend_name }}
434 key-file = ${directory:apache-conf}/apache-{{ backend_name }}.key
435 cert-file = ${directory:apache-conf}/apache-{{ backend_name }}.crt
436 configuration-file = ${directory:apache-conf}/apache-{{ backend_name }}.conf
437 access-control-string = {{ backend_configuration['access-control-string'] }}
438 pid-file = ${directory:run}/apache-{{ backend_name }}.pid
439 lock-file = ${directory:run}/apache-{{ backend_name }}.lock
440 ssl-session-cache = $${directory:log}/apache-ssl-session-cache
441 error-log = ${directory:log}/apache-{{ backend_name }}-error.log
442 access-log = ${directory:log}/apache-{{ backend_name }}-access.log
443 apache-binary = {{ parameter_dict['apache'] }}/bin/httpd
444 ssl-authentication = {{ backend_configuration.get('ssl-authentication', False) }}
445 backend-path = {{ backend_configuration.get('backend-path', '/') % {'site-id': site_id} }}
446 # Note: Without erp5-certificate-authority main certificate have to be hardcoded
447 ssl-authentication-certificate = ${erp5-certificate-authority:ca-dir}/cacert.pem
448 ssl-authentication-crl = ${erp5-certificate-authority:ca-crl}
450 [{{ section('ca-apache-' ~ backend_name) }}]
451 < = certificate-authority
452 recipe = slapos.cookbook:certificate_authority.request
453 key-file = ${apache-{{ backend_name }}:key-file}
454 cert-file = ${apache-{{ backend_name }}:cert-file}
455 executable = ${apache-{{ backend_name }}:wrapper}
456 wrapper = ${directory:services}/apache-{{ backend_name }}
458 [{{ section('logrotate-entry-apache-' ~ backend_name) }}]
460 recipe = slapos.cookbook:logrotate.d
461 name = apache-{{ backend_name }}
462 log = ${apache-{{ backend_name }}:error-log} ${apache-{{ backend_name }}:access-log}
463 post = {{ bin_directory }}/killpidfromfile ${apache-{{ backend_name }}:pid-file} SIGUSR1
465 [{{ section('haproxy-' ~ backend_name) }}]
466 recipe = slapos.cookbook:haproxy
467 name = {{ backend_name }}
468 conf-path = ${directory:etc}/haproxy-{{ backend_name }}.cfg
470 port = {{ current_haproxy_port }}
471 maxconn = {{ backend_configuration['maxconn'] }}
472 server-check-path = /{{ site_id }}/getId
473 wrapper-path = ${directory:services}/haproxy-{{ backend_name }}
474 binary-path = {{ parameter_dict['haproxy'] }}/sbin/haproxy
475 backend-list = {{ haproxy_backend_list | join(' ')}}
478 [{{ section('publish-apache-backend-list') }}]
479 recipe = slapos.cookbook:publish
480 {{ publish_url_list | join('\n') }}
482 #############################
484 #############################
486 recipe = slapos.cookbook:tidstorage
487 known-tid-storage-identifier-dict = {{ known_tid_storage_identifier_dict }}
488 configuration-path = ${directory:etc}/tidstorage.py
491 timestamp-file-path = ${directory:tidstorage}/repozo_tidstorage_timestamp.log
492 logfile-name = ${directory:log}/tidstorage.log
493 pidfile-name = ${directory:run}/tidstorage.pid
494 status-file = ${directory:tidstorage}/tidstorage.tid
495 tidstorage-repozo-binary = {{ bin_directory }}/tidstorage_repozo
496 tidstoraged-binary = {{ bin_directory }}/tidstoraged
497 repozo-binary = {{ bin_directory }}/repozo
498 tidstorage-wrapper = ${directory:services}/tidstoraged
499 repozo-wrapper = ${buildout:bin-directory}/tidstorage-repozo
501 [cron-entry-tidstorage-backup]
503 recipe = slapos.cookbook:cron.d
505 frequency = 0 0 * * *
506 command = ${tidstorage:repozo-wrapper}
508 [logrotate-entry-tidstorage]
510 recipe = slapos.cookbook:logrotate.d
512 log = ${tidstorage:logfile-name}
513 post = {{ bin_directory }}/killpidfromfile ${tidstorage:pidfile-name} SIGHUP
515 #############################
516 # buildout main section
517 #############################
523 certificate-authority
524 erp5-certificate-authority
526 cron-entry-tidstorage-backup
527 logrotate-entry-tidstorage
531 {{ part_list | join('\n ') }}
533 eggs-directory = {{ eggs_directory }}
534 develop-eggs-directory = {{ develop_eggs_directory }}