instance-zope.cfg.in 12.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
[zope-base]
recipe = slapos.cookbook:generic.zope.zeo.client
180
inituser = ${directory:instance}/inituser
181 182 183
user = {{ dumps(slapparameter_dict['inituser-login']) }}
password = {{ dumps(slapparameter_dict['inituser-password']) }}
timezone = {{ dumps(slapparameter_dict['timezone']) }}
184
tmp-path = ${directory:tmp}
185 186
instancehome-path = ${directory:instance}
home-path = ${buildout:directory}
187
bin-path = ${directory:bin}:{{ parameter_dict['coreutils'] }}/bin
188
site-zcml = ${directory:instance-etc}/site.zcml
189
runzope-binary = ${preload-userhosts-runzope:rendered}
190
bt5-repository =
191 192 193 194

[zope-conf-parameter-base]
ip = {{ ipv4 }}
site-id = {{ site_id }}
195 196 197
{% set storage_dict = {'neo': {}, 'zeo': slapparameter_dict.get('zodb-zeo', {})} -%}
{% for name, zodb in zodb_dict.iteritems() -%}
{%   do zodb.setdefault('storage-dict', {}).update(storage_dict[zodb['type']].get(name, {})) -%}
198
{% endfor -%}
199
developer-list = {{ dumps(slapparameter_dict['developer-list']) }}
200 201 202 203
instance = ${directory:instance}
instance-products = ${directory:instance-products}
deadlock-path = /manage_debug_threads
deadlock-debugger-password = {{ dumps(slapparameter_dict['deadlock-debugger-password']) }}
204 205 206 207
{% if slapparameter_dict.get('tidstorage-ip') -%}
tidstorage-ip = {{ dumps(slapparameter_dict['tidstorage-ip']) }}
tidstorage-port = {{ dumps(slapparameter_dict['tidstorage-port']) }}
{% endif -%}
208
promise-path = ${erp5-promise:promise-path}
209 210
{% set thread_amount = slapparameter_dict['thread-amount'] -%}
thread-amount = {{ thread_amount }}
211 212 213 214 215 216 217 218
{% 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) }}
219 220 221 222 223 224 225 226 227 228 229

[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(
230
  index,
231 232 233 234
  port,
  longrequest_logger_timeout,
  longrequest_logger_interval
) -%}
235
{% set name = 'zope-' ~ index -%}
236 237 238 239 240 241 242 243 244 245 246
{% 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
247
node-id = {{ dumps(node_id_base ~ '-' ~ index) }}
248
{% set log_list = [] -%}
249 250 251 252 253
{% set import_set = set() -%}
{% for db_name, zodb in zodb_dict.iteritems() -%}
{%   if zodb['type'] == 'neo' -%}
{%     do import_set.add('neo.client') -%}
{%     set log = buildout_directory ~ '/var/log/' ~ name ~ '-neo-' ~ db_name ~ '.log' -%}
254
{%     do log_list.append(log) -%}
255
{%     do zodb['storage-dict'].__setitem__('logfile', log) -%}
256
{%     if db_name == slapparameter_dict.get('neo-name') -%}
257
{%       do zodb['storage-dict'].__setitem__('name', slapparameter_dict['neo-cluster']) -%}
258 259
{%       do zodb['storage-dict'].__setitem__('master_nodes', slapparameter_dict['neo-masters']) -%}
{%     endif -%}
260
{{     assert(zodb['storage-dict']['master_nodes'], db_name) }}
261 262
{%   endif -%}
{% endfor -%}
263 264
import-list = {{ dumps(list(import_set)) }}
zodb-dict = {{ dumps(zodb_dict) }}
265 266 267 268

[{{ conf_name }}]
< = zope-conf-base
rendered = ${directory:etc}/{{ name }}.conf
269
context =
270 271
  section parameter_dict {{ conf_parameter_name }}

272
[{{ section(name) }}]
273 274 275 276 277 278 279
< = 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" }}
280 281
longrequest-logger-timeout = {{ longrequest_logger_timeout }}
longrequest-logger-interval = {{ longrequest_logger_interval }}
282 283 284 285 286 287
{% endif -%}
wrapper = ${directory:services}/{{ name }}
configuration-file = {{ '${' ~ conf_name ~ ':rendered}' }}

[{{ section("promise-" ~ name) }}]
recipe = slapos.cookbook:check_port_listening
288 289
hostname = {{ ipv4 }}
port = {{ port }}
290 291 292 293 294 295 296 297
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 }}
298
{%   do publish_list.append(("[" ~ ipv6 ~ "]:" ~ port, thread_amount, webdav)) -%}
299 300 301 302 303 304 305

[{{ 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 -%}
306
{%   do publish_list.append((ipv4 ~ ":" ~ port, thread_amount, webdav)) -%}
307 308 309 310 311
{% endif -%}

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

316 317 318 319 320 321 322
{% for i in range(slapparameter_dict['instance-count']) -%}
{{   zope(
       i,
       next_port,
       slapparameter_dict['longrequest-logger-timeout'],
       slapparameter_dict['longrequest-logger-interval'],
     ) }}
323 324 325 326 327 328
{%   set next_port = next_port + 1 -%}
{% endfor -%}

[publish-zope]
recipe = slapos.cookbook:publish.serialised
zope-address-list = {{ dumps(publish_list) }}
329 330 331 332 333 334 335 336
{#
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) }}
337 338 339 340

[erp5-promise]
recipe = slapos.cookbook:erp5.promise
promise-path = ${directory:etc}/erp5promise.cfg
341 342 343 344 345 346
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']) }}
347 348

[buildout]
349
extends = {{ logrotate_cfg }}
350 351 352 353
parts +=
  erp5-promise
  {{ part_list | join('\n  ') }}
  publish-zope
354
versions = versions
355

356 357
[versions]
slapos.core = {{ slapos_core_version }}