instance-erp5.cfg.in 9.85 KB
Newer Older
1
{% import "root_common" as root_common with context %}
2
{% set frontend_dict = slapparameter_dict.get('frontend', {}) -%}
3 4
{% set has_frontend = frontend_dict.get('software-url', '') != '' -%}
{% set site_id = slapparameter_dict.get('site-id', 'erp5') -%}
5 6
{% set inituser_login = slapparameter_dict.get('inituser-login', 'zope') -%}
{% set publish_dict = {'site-id': site_id, 'inituser-login': inituser_login} -%}
7
[request-common]
8
<= request-common-base
9
config-use-ipv6 = {{ dumps(slapparameter_dict.get('use-ipv6', False)) }}
10

11
{% macro request(name, software_type, config_key, config, ret={'url': True}) -%}
12 13 14
{% do config.update(slapparameter_dict.get(config_key, {})) -%}
{% set section = 'request-' ~ name -%}
[{{ section }}]
15
<= request-common
16 17
name = {{ name }}
software-type = {{ software_type }}
18 19
return = {{ ' '.join(ret) }}
{% for ret, publish in ret.iteritems() -%}
20 21 22 23
{%   if publish -%}
{%     do publish_dict.__setitem__(name ~ '-' ~ ret, '${' ~ section ~ ':connection-' ~ ret ~ '}')%}
{%   endif -%}
{% endfor -%}
24
{{ root_common.sla(name) }}
25 26
{% for k, v in config.iteritems() -%}
config-{{ k }} = {{ dumps(v) }}
27 28
{% endfor -%}
{% endmacro -%}
29

30 31 32
{{ request('memcached-persistent', 'kumofs', 'kumofs', {'tcpv4-port': 2000}) }}
{{ request('memcached-volatile', 'kumofs', 'memcached', {'tcpv4-port': 2010, 'ram-storage-size': 64}) }}
{{ request('cloudooo', 'cloudooo', 'cloudooo', {'tcpv4-port': 2020}) }}
33
{{ request('mariadb', 'mariadb', 'mariadb', {'tcpv4-port': 2099}, {'database-list': True, 'test-database-list': True}) }}
34
{{ request('postfix', 'postfix', 'postfix', {'tcpv4-port': 2025}) }}
35 36 37 38 39 40 41 42

{# ZODB -#}
{% set zodb_dict = {} -%}
{% set storage_dict = {} -%}
{% set mountpoints = set() -%}
{% for zodb in slapparameter_dict.get('zodb') or ({'type': 'zeo', 'server': {}},) -%}
{%   do mountpoints.add(zodb.setdefault('mount-point', '/')) -%}
{%   set name = zodb.pop('name', 'root') -%}
43
{%   do assert(name not in zodb_dict, name, zodb_dict) -%}
44 45 46 47 48
{%   do zodb_dict.__setitem__(name, zodb) -%}
{%   if 'server' in zodb -%}
{%     do storage_dict.setdefault(zodb['type'], {}).__setitem__(name, zodb.pop('server')) -%}
{%   endif -%}
{% endfor -%}
49 50
{% do assert(len(mountpoints) == len(zodb_dict)) -%}
{% set neo = [] -%}
51
{% for server_type, server_dict in storage_dict.iteritems() -%}
52 53
{%   if server_type == 'neo' -%}
{%     set ((name, server_dict),) = server_dict.items() -%}
54 55
{%     do neo.append(server_dict.get('cluster')) -%}
{%     do server_dict.__setitem__('cluster', '${publish-early:neo-cluster}') -%}
56 57 58
{{     root_common.request_neo(server_dict, 'zodb-neo', 'neo-') }}
{%   else -%}
{{     assert(server_type == 'zeo', server_type) -}}
59
{# BBB: for compatibility, keep 'zodb' as partition_reference for ZEO -#}
60 61
{{     request('zodb', 'zodb-' ~ server_type, 'zodb-' ~ server_type, {'tcpv4-port': 2100, 'zodb-dict': server_dict}, dict.fromkeys(('storage-dict', 'tidstorage-ip', 'tidstorage-port'))) }}
{%   endif -%}
62
{% endfor -%}
63

64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
[publish-early]
recipe = slapos.cookbook:publish-early
-init =
  inituser-password gen-password:passwd
  deadlock-debugger-password gen-deadlock-debugger-password:passwd
{%- if neo %}
  neo-cluster gen-neo-cluster:name
{%-  if neo[0] %}
neo-cluster = {{ neo[0] }}
{%-  endif %}
{%- endif %}
{%- set inituser_password = slapparameter_dict.get('inituser-password') %}
{%- if inituser_password %}
inituser-password = {{ inituser_password }}
{%- endif %}
{%- set deadlock_debugger_password = slapparameter_dict.get('deadlock-debugger-password') -%}
{%- if deadlock_debugger_password %}
deadlock-debugger-password = {{ deadlock_debugger_password }}
{%- endif %}
83

84
[gen-password]
85
recipe = slapos.cookbook:generate.password
86 87 88 89 90 91 92 93 94 95
storage-path =

[gen-deadlock-debugger-password]
<= gen-password

[gen-neo-cluster-base]
<= gen-password

[gen-neo-cluster]
name = neo-${gen-neo-cluster-base:passwd}
96

97
[request-zope-base]
98
<= request-common
99 100
return =
  zope-address-list
101
  hosts-dict
102 103
config-bt5 = {{ dumps(slapparameter_dict.get('bt5', 'erp5_full_text_myisam_catalog erp5_configurator_standard erp5_configurator_maxma_demo erp5_configurator_ung erp5_configurator_run_my_doc')) }}
config-bt5-repository-url = {{ dumps(slapparameter_dict.get('bt5-repository-url', local_bt5_repository)) }}
104
config-cloudooo-url = ${request-cloudooo:connection-url}
105
config-deadlock-debugger-password = ${publish-early:deadlock-debugger-password}
106
config-developer-list = {{ dumps(slapparameter_dict.get('developer-list', [inituser_login])) }}
107
config-hosts-dict = {{ dumps(slapparameter_dict.get('hosts-dict', {})) }}
108
config-hostalias-dict = {{ dumps(slapparameter_dict.get('hostalias-dict', {})) }}
109
config-inituser-login = {{ dumps(inituser_login) }}
110
config-inituser-password = ${publish-early:inituser-password}
111 112 113 114 115
config-kumofs-url = ${request-memcached-persistent:connection-url}
config-memcached-url = ${request-memcached-volatile:connection-url}
config-mysql-test-url-list = ${request-mariadb:connection-test-database-list}
config-mysql-url-list = ${request-mariadb:connection-database-list}
config-site-id = {{ dumps(site_id) }}
116
config-smtp-url = {{ dumps(slapparameter_dict.get('smtp-url', 'smtp://localhost:25/')) }}
117
config-timezone = {{ dumps(slapparameter_dict.get('timezone', 'UTC')) }}
118
config-zodb-dict = {{ dumps(zodb_dict) }}
119 120
{% for server_type, server_dict in storage_dict.iteritems() -%}
{%   if server_type == 'neo' -%}
121
config-neo-cluster = ${publish-early:neo-cluster}
122 123 124
config-neo-name = {{ server_dict.keys()[0] }}
config-neo-masters = ${neo-0-final:connection-masters}
{%   else -%}
125
config-zodb-zeo = ${request-zodb:connection-storage-dict}
126 127
config-tidstorage-ip = ${request-zodb:connection-tidstorage-ip}
config-tidstorage-port = ${request-zodb:connection-tidstorage-port}
128 129
{%   endif -%}
{% endfor -%}
130
software-type = zope
131 132 133

{% set zope_family_dict = {} -%}
{% for custom_name, zope_parameter_dict in slapparameter_dict.get('zope-partition-dict', {'1': {}}).items() -%}
134 135 136 137
{%   set partition_name = 'zope-' ~ custom_name -%}
{%   set section_name = 'request-' ~ partition_name -%}
{%   do zope_family_dict.setdefault(zope_parameter_dict.get('family', 'default'), []).append(section_name) -%}
[{{ section_name }}]
138
<= request-zope-base
139
name = {{ partition_name }}
140
{{ root_common.sla(partition_name) }}
141
config-name = {{ dumps(custom_name) }}
142
config-instance-count = {{ dumps(zope_parameter_dict.get('instance-count', 1)) }}
143
config-thread-amount = {{ dumps(zope_parameter_dict.get('thread-amount', 4)) }}
144 145 146 147
config-timerserver-interval = {{ dumps(zope_parameter_dict.get('timerserver-interval', 5)) }}
config-longrequest-logger-interval = {{ dumps(zope_parameter_dict.get('longrequest-logger-interval', -1)) }}
config-longrequest-logger-timeout = {{ dumps(zope_parameter_dict.get('longrequest-logger-timeout', 1)) }}
config-port-base = {{ dumps(zope_parameter_dict.get('port-base', 2200)) }}
148
config-webdav = {{ dumps(zope_parameter_dict.get('webdav', False)) }}
149 150 151 152 153 154 155 156 157 158 159 160 161
{% endfor -%}

{# We need to concatenate lists that we cannot read as lists, so this gets hairy. -#}
{% set zope_address_list_id_dict = {} -%}
{% set zope_family_parameter_dict = {} -%}
{% for family_name, zope_section_id_list in zope_family_dict.items() -%}
{%   for zope_section_id in zope_section_id_list -%}
{%     set parameter_name = 'zope-family-entry-' ~ zope_section_id -%}
{%     do zope_address_list_id_dict.__setitem__(zope_section_id, parameter_name) -%}
{%     do zope_family_parameter_dict.setdefault(family_name, []).append(parameter_name) -%}
{%   endfor -%}
{%   if has_frontend -%}
{%     set frontend_name = 'frontend-' ~ family_name -%}
162
{%     do publish_dict.__setitem__('family-' ~ family_name, '${' ~ frontend_name ~ ':connection-site_url}' ) -%}
163
[{{ frontend_name }}]
164
<= request-frontend-base
165
name = {{ frontend_name }}
166
config-url = ${request-balancer:{{ family_name }}-v6}
167
{%   else -%}
168 169
{%     do publish_dict.__setitem__('family-' ~ family_name, '${request-balancer:connection-' ~ family_name ~ '}' ) -%}
{%     do publish_dict.__setitem__('family-' ~ family_name ~ '-v6', '${request-balancer:connection-' ~ family_name ~ '-v6}' ) -%}
170 171 172
{%   endif -%}
{% endfor -%}

173
{% set balancer_dict = slapparameter_dict.get('balancer', {}) -%}
174
[request-balancer]
175
<= request-common
176 177
name = balancer
software-type = balancer
178
{{ root_common.sla('balancer') }}
179
return =
180 181 182 183
{%- for family in zope_family_dict %}
  {{ family }}
  {{ family }}-v6
{% endfor -%}
184
config-zope-family-dict = {{ dumps(zope_family_parameter_dict) }}
185
config-tcpv4-port = {{ dumps(balancer_dict.get('tcpv4-port', 2150)) }}
186 187 188 189
{% for zope_section_id, name in zope_address_list_id_dict.items() -%}
config-{{ name }} = {{ ' ${' ~ zope_section_id ~ ':connection-zope-address-list}' }}
{% endfor -%}
# XXX: should those really be same for all families ?
190
config-haproxy-server-check-path = {{ dumps(balancer_dict.get('haproxy-server-check-path', '/') % {'site-id': site_id}) }}
191 192
config-backend-path = {{ dumps(balancer_dict.get('apache-backend-path', '/') % {'site-id': site_id}) }}
config-ssl = {{ dumps(balancer_dict.get('ssl', {})) }}
193

194 195
[request-frontend-base]
{% if has_frontend -%}
196
<= request-common
197 198
software-url = {{ dumps(frontend_dict['software-url']) }}
software-type = {{ dumps(frontend_dict.get('software-type', 'RootSoftwareInstance')) }}
199
{{ root_common.sla('frontend', True) }}
200 201 202 203 204 205 206 207 208 209 210 211
slave = true
{% set config_dict = {
  'type': 'zope',
} -%}
{%   if frontend_dict.get('domain') -%}
{%     do config_dict.__setitem__('custom_domain', frontend_dict['domain']) -%}
{%   endif -%}
{%   for name, value in config_dict.items() -%}
config-{{ name }} = {{ value }}
{%   endfor -%}
return = site_url
{% endif -%}
212

213 214
[publish]
recipe = slapos.cookbook:publish.serialised
215
-extends = publish-early
216 217 218 219
{% if 'neo' in storage_dict -%}
neo-masters = ${neo-0-final:connection-masters}
neo-admins = ${neo-0-final:connection-admins}
{% endif  -%}
220 221 222 223 224
{#
Pick any published hosts-dict, they are expected to be identical - and there is
no way to check here.
-#}
hosts-dict = {{ '${' ~ zope_address_list_id_dict.keys()[0] ~ ':connection-hosts-dict}' }}
225
{% for name, value in publish_dict.items() -%}
226
{{   name }} = {{ value }}
227
{% endfor -%}
228

229
{{ root_common.common_section() }}