instance-runner.cfg 33.4 KB
Newer Older
1
[buildout]
2
common-runner-parts =
3 4 5 6
  nginx_conf
  nginx-launcher
  certificate-authority
  ca-nginx
7 8
  certificate-authority-service
  ca-nginx-service
9
  logrotate-entry-nginx
10 11
  gunicorn-launcher
  gunicorn-graceful
12
  publish-connection-information
13
  slaprunner-promise
14
  logrotate-entry-apache-httpd
15
  apache-httpd-promise
16
  slaprunner-supervisord-wrapper
17 18 19
  runner-sshd-add-authorized-key
  runner-sshd-graceful
  runner-sshd-promise
20
  runner-sshkeys-authority
21
  runner-sshkeys-authority-service
22
  runner-sshkeys-sshd
23
  runner-sshkeys-sshd-service
24
  runtestsuite
25
  symlinks
26
  shellinabox
27
  shellinabox-service
28
  slapos-cfg
29
  cron-entry-prepare-software
30
  deploy-instance-parameters
31
  instance-software
32
  instance-software-type
33
  minishell-cwd
34
  bash-profile
35
  supervisord-wrapper
36
  supervisord-promise
37
  logrotate-entry-supervisord
38
  logrotate-entry-slapgrid
39
  httpd-graceful-wrapper
40 41 42 43
{% if slapparameter_dict.get('no-ipv4-frontend', 'false') == 'false' %}
  slaprunner-frontend-promise
  httpd-frontend-promise
{% endif %}
44
{% if slapparameter_dict.get('custom-frontend-backend-url') and slapparameter_dict.get('check-custom-frontend-promise', 'false') == 'true' %}
45 46
  custom-frontend-promise
{% endif %}
47
## Monitoring part
48
  monitor-base
49
  monitor-check-webrunner-internal-instance
50 51
## Usability part
  template-slapuser-script
52

53
parts = $${:common-runner-parts}
54 55 56
extends =
  ${monitor2-template:rendered}
  ${template-logrotate-base:rendered}
57 58 59 60 61

eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory}
offline = true

62 63
{% if slapparameter_dict.get('custom-frontend-backend-url') -%}
[request-custom-frontend]
64
recipe = slapos.cookbook:requestoptional
65
software-url = {{ slapparameter_dict.get('custom-frontend-software-url', 'http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD:/software/apache-frontend/software.cfg') }}
66 67 68 69
software-type = {{ slapparameter_dict.get('custom-frontend-software-type', 'RootSoftwareInstance') }}
slave = true
name = Custom Web Frontend

70 71 72 73 74
server-url = $${slap-connection:server-url}
key-file = $${slap-connection:key-file}
cert-file = $${slap-connection:cert-file}
computer-id = $${slap-connection:computer-id}
partition-id = $${slap-connection:partition-id}
75

76
{% if slapparameter_dict.get('custom-frontend-instance-guid') -%}
77
sla-instance_guid = $${slap-parameter:frontend-instance-guid}
78 79
{% endif -%}

80 81
{% set custom_frontend_backend_type = slapparameter_dict.get('custom-frontend-backend-type') -%}
{% if custom_frontend_backend_type -%}
82 83
config-type = {{ custom_frontend_backend_type }}
{% endif -%}
84
config-url = {{ slapparameter_dict.get('custom-frontend-backend-url') }}
85
return = site_url domain
86 87 88

[custom-frontend-promise]
recipe = slapos.cookbook:check_url_available
89 90 91 92 93
path = $${directory:promises}/custom_frontend_promise
url = https://$${request-custom-frontend:connection-domain}
{% if slapparameter_dict.get('custom-frontend-basic-auth') -%}
check-secure = 1
{% endif -%}
94 95 96
dash_path = {{ dash_executable_location }}
curl_path = {{ curl_executable_location }}

97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
[custom-frontend-url-ready-promise]
recipe = slapos.recipe.template:jinja2
path = $${directory:promises}/custom_frontend_ready_promise
url = https://$${request-custom-frontend:connection-domain}
rendered = $${directory:promises}/custom_frontend_ready_promise
template = inline:
  #!{{ dash_executable_location }}

  URL="$${:url}"
  CODE=$({{ curl_executable_location }} -g -k -sL $URL -w %{http_code} --max-time 5 -o /dev/null)

  if [ $? -eq 3 ]; then
    echo "Custom frontend URL malformed: $URL." >&2
    exit 1
  fi

113
[publish-connection-information]
114
custom-frontend-url = $${custom-frontend-url-ready-promise:url}
115
{% endif %}
116

117
# Create all needed directories
118
[directory]
119
recipe = slapos.cookbook:mkdirectory
120 121 122
home = $${buildout:directory}
etc = $${:home}/etc/
var = $${:home}/var/
123 124 125 126
# This srv path has an extra slash, which will cause runnerdirectory:home
# to be .../srv//runner/.. but for compatibility reasons we don't fix this,
# because this is the path that will be used as software URL installed by
# webrunner and would cause software release hash to become different.
127 128 129
srv = $${:home}/srv/
bin = $${:home}/bin/
tmp = $${:home}/tmp/
130

131 132 133 134 135 136 137 138 139
sshkeys = $${:srv}/sshkeys
services = $${:etc}/service/
scripts = $${:etc}/run/
ssh = $${:etc}/ssh/
log = $${:var}/log/
run = $${:var}/run/
backup = $${:srv}/backup/
promises = $${:etc}/promise/
test = $${:etc}/test/
140
nginx-data = $${:srv}/nginx
141
ca-dir = $${:srv}/ssl
142
project = $${:srv}/runner/project
143
cgi-bin = $${:srv}/cgi-bin
144 145 146

[runnerdirectory]
recipe = slapos.cookbook:mkdirectory
147 148
home = $${directory:srv}/runner/
test = $${directory:srv}/test/
149
project = $${:home}/project
150
public = $${:home}/public
151
software-root = {{ slapparameter_dict.get('software-root', '$${:home}/software') }}
152
instance-root = $${:home}/instance
153
shared-root = $${:home}/shared
154 155 156
project-test = $${:test}/project
software-test = $${:test}/software
instance-test = $${:test}/instance
157
sessions = $${buildout:directory}/.sessions
158 159
private-project = $${:home}/.git-private
public-project = $${:home}/.git-public
160 161

[slaprunner]
162
slaprunner = ${buildout:directory}/bin/slaprunner
163
slapos = ${buildout:directory}/bin/slapos
164 165
slapproxy = ${buildout:directory}/bin/slapproxy
supervisor = ${buildout:directory}/bin/slapgrid-supervisorctl
166
git-binary = ${git:location}/bin/git
167
root_check = false
168
slapos.cfg = $${directory:etc}/slapos.cfg
169 170
working-directory = $${runnerdirectory:home}
project-directory = $${runnerdirectory:project}
171 172
instance_root = $${runnerdirectory:instance-root}
software_root = $${runnerdirectory:software-root}
173 174
shared_root = $${runnerdirectory:shared-root}
buildout-shared-part-list-dump = ${template-buildout-shared-part-list:output}
175 176
pidfile-software = $${directory:run}/slapgrid-cp.pid
pidfile-instance = $${directory:run}/slapgrid-sr.pid
177
ssh_client = ${openssh:location}/bin/ssh
178 179
public_key = $${runner-sshd-raw-server:rsa-keyfile}.pub
private_key = $${runner-sshd-raw-server:rsa-keyfile}
180
instance-monitor-url = https://[$${:ipv6}]:$${slap-parameter:monitor-httpd-port}
181 182 183
etc_dir = $${directory:etc}
log_dir =  $${directory:log}
run_dir = $${directory:run}
184 185
ipv4 = $${slap-network-information:local-ipv4}
ipv6 = $${slap-network-information:global-ipv6}
186
instance_root = $${runnerdirectory:instance-root}
187 188
proxy_port = 50000
runner_port = 50005
189
partition-amount = $${slap-parameter:instance-amount}
190
wrapper = $${directory:services}/slaprunner
191
debug = $${slap-parameter:debug}
192
access-url = https://[$${:ipv6}]:$${:runner_port}
193
supervisord_config = $${directory:etc}/supervisord.conf
194
supervisord_server = http://$${supervisord:server}
195
proxy_database = $${slaprunner:working-directory}/proxy.db
196 197 198
console = False
verbose = False
debug = False
199 200 201
auto_deploy = $${slap-parameter:auto-deploy}
auto_deploy_instance = $${slap-parameter:auto-deploy-instance}
autorun = $${slap-parameter:autorun}
202
knowledge0_file = $${monitor-instance-parameter:configuration-file-path}
203
minishell_cwd_file = $${directory:etc}/.minishell-cwd
204
minishell_history_file = $${directory:etc}/.minishell_history
205 206
software_info_json = $${runnerdirectory:home}/software_info.json
instance_info_json = $${runnerdirectory:home}/instance_info.json
207
path = $${shell-environment:path}
208
instance_name = $${slap-parameter:instance-name}
209

210 211 212
default_repository = $${slap-parameter:slapos-repository}
default_repository_branch = $${slap-parameter:slapos-reference}

213 214 215 216 217 218 219

#---------------------------
#--
#-- supervisord managing slaprunner instance processes
[slaprunner-supervisord-wrapper]
recipe = slapos.cookbook:wrapper
# XXX hardcoded locations
220
command-line = $${directory:bin}/slapos node supervisord --cfg $${directory:etc}/slapos.cfg -n
221
wrapper-path = $${directory:services}/slaprunner-supervisord
222
hash-existing-files = $${buildout:directory}/software_release/buildout.cfg
223 224


225 226
[test-runner]
<= slaprunner
227
slapos.cfg = $${directory:etc}/slapos-test.cfg
228 229
working-directory = $${runnerdirectory:test}
project-directory = $${runnerdirectory:project-test}
230 231
software_root = $${runnerdirectory:software-test}
instance_root = $${runnerdirectory:instance-test}
232
proxy_port = 8602
233
etc_dir = $${directory:test}
234 235
autorun = False
auto_deploy = True
236

237 238
[runtestsuite]
recipe = slapos.cookbook:wrapper
239 240
arguments = --server_url=$${slap-connection:server-url} --key_file=$${slap-connection:key-file} --cert_file=$${slap-connection:cert-file} --computer_id=$${slap-connection:computer-id} --partition_id=$${slap-connection:partition-id}
command-line = ${buildout:directory}/bin/slaprunnertest $${:arguments}
241
wrapper-path = $${directory:bin}/runTestSuite
242
environment = PATH=$${shell-environment:path}
243
  RUNNER_CONFIG=$${slapos-cfg:rendered}
244

245 246 247 248 249 250 251 252 253 254 255
# Deploy openssh-server
[runner-sshd-port]
recipe = slapos.cookbook:free_port
minimum = 22222
maximum = 22231
ip = $${slap-network-information:global-ipv6}

[runner-sshd-config]
recipe = slapos.recipe.template:jinja2
rendered = $${directory:etc}/runner-sshd.conf
path_pid = $${directory:run}/runner-sshd.pid
256
host_key = $${directory:ssh}/runner_server_key.rsa
257 258 259 260 261 262
template = inline:
  PidFile $${:path_pid}
  Port $${runner-sshd-port:port}
  ListenAddress $${slap-network-information:global-ipv6}
  Protocol 2
  UsePrivilegeSeparation no
263
  HostKey $${:host_key}
264 265 266
  PasswordAuthentication no
  PubkeyAuthentication yes
  AuthorizedKeysFile $${buildout:directory}/.ssh/authorized_keys
Jérome Perrin's avatar
Jérome Perrin committed
267
  ForceCommand cd $${directory:home}; if [ -z "$SSH_ORIGINAL_COMMAND" ]; then HOME=$${directory:home} $${shell-environment:shell} -l; else HOME=$${directory:home} SHELL=$${shell-environment:shell} PATH=$${shell-environment:path} eval "$SSH_ORIGINAL_COMMAND"; fi
268
  Subsystem sftp ${openssh:location}/libexec/sftp-server
269

270
[runner-sshd-raw-server]
271
recipe = slapos.cookbook:wrapper
272
host = $${slap-network-information:global-ipv6}
273
rsa-keyfile = $${runner-sshd-config:host_key}
274
home = $${directory:ssh}
275
command-line = ${openssh:location}/sbin/sshd -D -e -f $${runner-sshd-config:rendered}
276 277 278 279 280 281 282 283 284
wrapper-path = $${directory:bin}/runner_raw_sshd

[runner-sshd-authorized-key]
<= runner-sshd-raw-server
recipe = slapos.cookbook:dropbear.add_authorized_key
key = $${slap-parameter:user-authorized-key}

[runner-sshd-server]
recipe = collective.recipe.template
285
log = $${directory:log}/runner-sshd.log
286 287 288
input = inline:#!/bin/sh
    exec $${runner-sshd-raw-server:wrapper-path} >> $${:log} 2>&1

289
output = $${directory:bin}/runner_raw_sshd_log
290
mode = 700
291 292 293 294 295 296

[runner-sshd-graceful]
recipe = slapos.cookbook:wrapper
command-line = $${directory:bin}/killpidfromfile $${runner-sshd-config:path_pid} SIGHUP
wrapper-path = $${directory:scripts}/runner-sshd-graceful

297
[runner-sshkeys-directory]
298
recipe = slapos.cookbook:mkdirectory
299 300
requests = $${directory:sshkeys}/runner-requests/
keys = $${directory:sshkeys}/runner-keys/
301 302 303

[runner-sshkeys-authority]
recipe = slapos.cookbook:sshkeys_authority
304 305
request-directory = $${runner-sshkeys-directory:requests}
keys-directory = $${runner-sshkeys-directory:keys}
306
wrapper = $${directory:bin}/runner_sshkeys_authority
307 308
keygen-binary = ${openssh:location}/bin/ssh-keygen

309 310 311 312
[runner-sshkeys-authority-service]
recipe = slapos.cookbook:wrapper
command-line = $${runner-sshkeys-authority:wrapper}
wrapper-path = $${directory:services}/runner-sshkeys-authority
313
hash-existing-files = $${buildout:directory}/software_release/buildout.cfg
314

315 316 317
[runner-sshkeys-sshd]
<= runner-sshkeys-authority
recipe = slapos.cookbook:sshkeys_authority.request
318
name = sshd
319 320 321 322
type = rsa
executable = $${runner-sshd-server:output}
public-key = $${runner-sshd-raw-server:rsa-keyfile}.pub
private-key = $${runner-sshd-raw-server:rsa-keyfile}
323 324 325 326 327 328
wrapper = $${directory:bin}/runner-sshd

[runner-sshkeys-sshd-service]
recipe = slapos.cookbook:wrapper
command-line = $${runner-sshkeys-sshd:wrapper}
wrapper-path = $${directory:services}/runner-sshd
329
hash-existing-files = $${buildout:directory}/software_release/buildout.cfg
330

331
[runner-sshd-add-authorized-key]
332
recipe = slapos.cookbook:dropbear.add_authorized_key
333
home = $${buildout:directory}
334
key = $${slap-parameter:user-authorized-key}
335

336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356
[runner-sshkeys-publickey-fingerprint-cmd]
recipe = plone.recipe.command
command = bash -o pipefail -c "$${runner-sshkeys-authority:keygen-binary} -lf $${runner-sshkeys-sshd:public-key} | cut  -f 2 -d\ | sed 's/+/%2B/g' | sed 's/\//%2F/g' | sed 's/SHA256://'"

[runner-sshkeys-publickey-fingerprint-shelloutput]
recipe = collective.recipe.shelloutput
# XXX because collective.recipe.shelloutput ignore errors, we run the same
# command in a plone.recipe.command so that if fails if something goes wrong.
commands =
  fingerprint = $${runner-sshkeys-publickey-fingerprint-cmd:command}

[runner-sshkeys-publickey-fingerprint]
# fingerprint for ssh url, see
# https://tools.ietf.org/id/draft-salowey-secsh-uri-00.html#connparam
# https://winscp.net/eng/docs/session_url#hostkey

# format is host-key-alg-fingerprint, but we know that
# $${runner-sshkeys-sshd:public-key} is rsa so for host-key-alg
# we just use use rsa.
fingerprint = ssh-rsa-$${runner-sshkeys-publickey-fingerprint-shelloutput:fingerprint}

357
#---------------------------
358
#--
359 360
#-- Set nginx frontend

361 362 363 364 365 366 367 368 369 370
[tempdirectory]
recipe = slapos.cookbook:mkdirectory
client_body_temp_path = $${directory:tmp}/client_body_temp_path
proxy_temp_path = $${directory:tmp}/proxy_temp_path
fastcgi_temp_path = $${directory:tmp}/fastcgi_temp_path
uwsgi_temp_path = $${directory:tmp}/uwsgi_temp_path
scgi_temp_path = $${directory:tmp}/scgi_temp_path

[nginx-frontend]
# Options
371
nb_workers = 5
372
# Network
373 374 375
local-ip = $${slap-network-information:local-ipv4}
global-ip = $${slap-network-information:global-ipv6}
global-port = $${slaprunner:runner_port}
376
# Backend
377 378
runner-ip = $${slaprunner:ipv4}
runner-port = $${slaprunner:runner_port}
379 380 381 382 383 384 385 386
# SSL
ssl-certificate = $${ca-nginx:cert-file}
ssl-key = $${ca-nginx:key-file}
# Log
path_pid = $${directory:run}/nginx.pid
path_log = $${directory:log}/nginx.log
path_access_log = $${directory:log}/nginx.access.log
path_error_log = $${directory:log}/nginx.error.log
387
path_tmp = $${directory:tmp}/
388
nginx_prefix = $${buildout:directory}
389 390 391
# Config files
path_nginx_conf = $${directory:etc}/nginx.conf
# Executables
392
bin_nginx = ${nginx-webdav:location}/sbin/nginx
393
bin_launcher = $${directory:bin}/launcher
394 395
# Utils
path_shell = ${dash:location}/bin/dash
396 397
# Misc.
etc_dir = $${directory:etc}
398
work_dir = $${slaprunner:working-directory}
399 400 401 402 403 404

[nginx_conf]
recipe = slapos.recipe.template:jinja2
template = ${template_nginx_conf:location}/${template_nginx_conf:filename}
rendered = $${nginx-frontend:path_nginx_conf}
context =
405
    key shellinabox_socket shellinabox:socket
406
    key socket gunicorn:socket
407 408 409 410 411 412 413 414 415 416 417
    section param_nginx_frontend nginx-frontend
    section param_tempdir tempdirectory

[nginx-launcher]
recipe = slapos.recipe.template:jinja2
template = ${template_launcher:location}/${template_launcher:filename}
rendered = $${nginx-frontend:bin_launcher}
mode = 700
context =
    section param_nginx_frontend nginx-frontend

418 419 420
[logrotate-entry-nginx]
<= logrotate-entry-base
name = nginx
Ivan Tyagov's avatar
Ivan Tyagov committed
421
log = $${directory:log}/nginx.access.log $${directory:log}/nginx.error.log
422
post = kill -USR1 $(cat $${buildout:directory}/var/run/nginx.pid)
423

424
[httpd-parameters]
425 426 427 428 429 430
path_pid = $${directory:run}/httpd.pid
path_error_log = $${directory:log}/httpd-error.log
path_access_log = $${directory:log}/httpd-access.log
# XXX Use ca-nginx, no need to regenerate certificate
cert_file = $${ca-nginx:cert-file}
key_file = $${ca-nginx:key-file}
431
global_ip = $${slap-network-information:global-ipv6}
432
global_port = $${slap-parameter:slaprunner-httpd-port}
433 434
working_directory = $${slaprunner:working-directory}
dav_lock = $${directory:var}/WebDavLock
435
htpasswd_file = $${directory:etc}/.htpasswd
436
etc_dir = $${directory:etc}
437 438
var_dir = $${directory:var}
project_folder = $${directory:project}
439
project_private_folder = $${runnerdirectory:private-project}
440
project_public_folder = $${runnerdirectory:public-project}
441
runner_home = $${runnerdirectory:home}
442
git_http_backend = ${git:location}/libexec/git-core/git-http-backend
443
cgid_sock = $${directory:run}/cgid.sock
444
httpd_cors_file = $${slaprunner-httpd-cors:location}
445 446 447 448

[httpd-conf]
recipe = slapos.recipe.template:jinja2
template = ${template_httpd_conf:location}/${template_httpd_conf:filename}
449
rendered = $${directory:etc}/httpd.conf
450
context =
451 452
    section parameters httpd-parameters

453 454 455 456 457 458 459 460 461
[apache-httpd]
recipe = slapos.cookbook:wrapper
apache-executable = ${apache:location}/bin/httpd
wrapper-path = $${directory:services}/slaprunner-httpd
command-line = $${:apache-executable} -f $${httpd-conf:rendered} -DFOREGROUND
access-url = https://[$${httpd-parameters:global_ip}]:$${httpd-parameters:global_port}
wait-for-files =
  $${ca-nginx:cert-file}
  $${ca-nginx:key-file}
462
hash-existing-files = $${buildout:directory}/software_release/buildout.cfg
463

464 465 466
[logrotate-entry-apache-httpd]
<= logrotate-entry-base
name = apache
Ivan Tyagov's avatar
Ivan Tyagov committed
467
log = $${directory:log}/httpd-access.log $${directory:log}/httpd-error.log
468 469
post = test ! -s $${buildout:directory}/var/run/httpd.pid || $${buildout:directory}/bin/slapos-kill --pidfile $${buildout:directory}/var/run/httpd.pid -s USR1

470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492
[httpd-graceful-wrapper]
recipe = collective.recipe.template
input = inline:
  #!/bin/sh
  exec kill -USR1 $(cat $${httpd-parameters:path_pid})
output = $${directory:scripts}/slaprunner-httpd-graceful
mode = 700

[apache-httpd-promise]
recipe = slapos.cookbook:check_url_available
path = $${directory:promises}/$${:filename}
filename = apache-httpd-listening-on-tcp
url = $${apache-httpd:access-url}
check-secure = 1
dash_path = {{ dash_executable_location }}
curl_path = {{ curl_executable_location }}

[slaprunner-httpd-cors]
recipe = plone.recipe.command
command = if [ ! -f $${:location} ]; then touch $${:location}; fi
location = $${directory:etc}/$${:filename}
filename = slaprunner-httpd-cors.cfg
stop-on-error = true
493

494 495 496 497
#--------------------
#--
#-- WSGI

498
[gunicorn]
499 500 501 502 503 504 505 506
bin_gunicorn = $${directory:bin}/gunicorn
bin_launcher = $${directory:services}/gunicorn
path_shell = ${dash:location}/bin/dash
socket = $${directory:tmp}/flaskserver.sock
path_pid = $${directory:run}/gunicorn.pid

[gunicorn-launcher]
recipe = slapos.cookbook:wrapper
507
command-line = $${gunicorn:bin_gunicorn} slapos.runner.run:app -p $${gunicorn:path_pid} -b unix:$${gunicorn:socket} -e RUNNER_CONFIG=$${slaprunner:slapos.cfg} --error-logfile $${directory:log}/$${:error-log-file} --timeout 200 --threads 3 --log-level error --preload
508
error-log-file = gunicorn-error.log
509
wrapper-path = $${gunicorn:bin_launcher}
510
environment = PATH=$${shell-environment:path}
511
  RUNNER_CONFIG=$${slaprunner:slapos.cfg}
512
  LANG=en_GB.UTF-8
513
hash-existing-files = $${buildout:directory}/software_release/buildout.cfg
514 515 516

[gunicorn-graceful]
recipe = slapos.cookbook:wrapper
517
command-line = $${directory:bin}/killpidfromfile $${gunicorn:path_pid} SIGHUP
518 519
wrapper-path = $${directory:scripts}/gunicorn-graceful

520
#--------------------
521
#--
522
#-- ssl certificates
523 524 525 526 527 528

[certificate-authority]
recipe = slapos.cookbook:certificate_authority
openssl-binary = ${openssl:location}/bin/openssl
ca-dir = $${directory:ca-dir}
requests-directory = $${cadirectory:requests}
529
wrapper = $${directory:bin}/certificate_authority
530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547
ca-private = $${cadirectory:private}
ca-certs = $${cadirectory:certs}
ca-newcerts = $${cadirectory:newcerts}
ca-crl = $${cadirectory:crl}

[cadirectory]
recipe = slapos.cookbook:mkdirectory
requests = $${directory:ca-dir}/requests/
private = $${directory:ca-dir}/private/
certs = $${directory:ca-dir}/certs/
newcerts = $${directory:ca-dir}/newcerts/
crl = $${directory:ca-dir}/crl/

[ca-nginx]
<= certificate-authority
recipe = slapos.cookbook:certificate_authority.request
key-file = $${cadirectory:certs}/nginx_frontend.key
cert-file = $${cadirectory:certs}/nginx_frontend.crt
548
executable = $${nginx-launcher:rendered}
549
wrapper = $${directory:bin}/nginx-frontend
550 551 552
# Put domain name
name = example.com

553 554 555 556
[ca-nginx-service]
recipe = slapos.cookbook:wrapper
command-line = $${directory:bin}/nginx-frontend
wrapper-path = $${directory:services}/nginx-frontend
557
hash-existing-files = $${buildout:directory}/software_release/buildout.cfg
558 559 560 561 562

[certificate-authority-service]
recipe = slapos.cookbook:wrapper
command-line = $${directory:bin}/certificate_authority
wrapper-path = $${directory:services}/certificate_authority
563
hash-existing-files = $${buildout:directory}/software_release/buildout.cfg
564

565
#--------------------
566 567
#--
#-- Request frontend
568

569
{% if slapparameter_dict.get('no-ipv4-frontend', 'false') == 'false' -%}
570 571
[request-frontend]
<= slap-connection
572
recipe = slapos.cookbook:requestoptional
573
name = SlapRunner Frontend
574
# XXX We have hardcoded SR URL here.
575
software-url = http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD:/software/apache-frontend/software.cfg
576
slave = true
577
config-url = $${slaprunner:access-url}
578
config-domain = $${slap-parameter:frontend-domain}
579
return = site_url domain
580

581 582 583 584 585 586 587 588
[slaprunner-frontend-promise]
recipe = slapos.cookbook:check_url_available
path = $${directory:promises}/slaprunner_frontend
url = https://$${request-frontend:connection-domain}/login
dash_path = ${dash:location}/bin/dash
curl_path = ${curl:location}/bin/curl
check-secure = 1

589 590 591
[request-httpd-frontend]
<= slap-connection
recipe = slapos.cookbook:requestoptional
592
# XXX - Unfortunately, we still call webrunner httpd frontend "Monitor Frontend" otherwise
593 594
# buildout will ignore previous frontend that was created and create a new one (in case of upgrade)
name = Monitor Frontend
595 596 597 598
# XXX We have hardcoded SR URL here.
software-url = http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD:/software/apache-frontend/software.cfg
slave = true
config-url = $${apache-httpd:access-url}
599
config-domain =
600 601 602 603 604 605 606 607 608 609
return = secure_access domain

[httpd-frontend-promise]
recipe = slapos.cookbook:check_url_available
path = $${directory:promises}/slaprunner-apache-http-frontend
url = $${request-httpd-frontend:connection-secure_access}
dash_path = {{ dash_executable_location }}
curl_path = {{ curl_executable_location }}
check-secure = 1

610
{% endif %}
611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629

[htpasswd]
recipe = slapos.cookbook:generate.password
storage-path = $${directory:etc}/.pwd
bytes = 8

[runner-htpasswd]
recipe = plone.recipe.command
stop-on-error = true
htpasswd-path = $${monitor-directory:etc}/.htpasswd
command = if [ ! -f "$${:htpasswd-path}" ]; then ${apache:location}//bin/htpasswd -cb $${:htpasswd-path} $${:user} $${:password}; fi
update-command = $${:command}
user = admin
{% if slapparameter_dict.get('monitor-password', '') -%}
password = {{ slapparameter_dict['monitor-password'] }}
{% else -%}
password = $${htpasswd:passwd}
{% endif -%}

630
#--------------------------------------
631
#--
632
#-- Send information to SlapOS Master
633

634 635 636
[user-info]
recipe = slapos.cookbook:userinfo

637
[publish-connection-information]
638
recipe = slapos.cookbook:publish
639 640 641
backend-url = $${slaprunner:access-url}
init-user = $${runner-htpasswd:user}
init-password = $${runner-htpasswd:password}
642
ssh-command = ssh $${user-info:pw-name}@$${slap-network-information:global-ipv6} -p $${runner-sshd-port:port}
643
ssh-url = ssh://$${user-info:pw-name};fingerprint=$${runner-sshkeys-publickey-fingerprint:fingerprint}@[$${slap-network-information:global-ipv6}]:$${runner-sshd-port:port}
644 645
git-public-url = https://[$${httpd-parameters:global_ip}]:$${httpd-parameters:global_port}/git-public/
git-private-url = https://[$${httpd-parameters:global_ip}]:$${httpd-parameters:global_port}/git/
646
monitor-base-url = $${monitor-publish-parameters:monitor-base-url}
647 648 649 650 651
{% if slapparameter_dict.get('no-ipv4-frontend', 'false') == 'false' -%}
url =  https://$${request-frontend:connection-domain}
webdav-url = $${request-httpd-frontend:connection-secure_access}/share/
public-url =  $${request-httpd-frontend:connection-secure_access}/public/
{% else %}
652
url =  $${slaprunner:access-url}
653 654 655 656
webdav-url = $${apache-httpd:access-url}/share/
public-url =  $${apache-httpd:access-url}/public/
{% endif %}

657 658
{% if slapparameter_dict.get('instance-type', '') != 'resilient' -%}
{% set monitor_interface_url = slapparameter_dict.get('monitor-interface-url', 'https://monitor.app.officejs.com') -%}
659
monitor-setup-url = {{ monitor_interface_url }}/#page=settings_configurator&url=$${monitor-publish-parameters:monitor-url}&username=$${monitor-publish-parameters:monitor-user}&password=$${monitor-publish-parameters:monitor-password}
660
{% else -%}
661 662 663
monitor-url = $${monitor-publish-parameters:monitor-url}
monitor-user = $${monitor-publish-parameters:monitor-user}
monitor-password = $${monitor-publish-parameters:monitor-password}
664
{% endif -%}
665 666 667
#---------------------------
#--
#-- Deploy promises scripts
Jean-Baptiste Petre's avatar
Jean-Baptiste Petre committed
668

669 670
[slaprunner-promise]
recipe = slapos.cookbook:check_port_listening
671
path = $${directory:promises}/slaprunner
672 673
hostname = $${slaprunner:ipv6}
port = $${slaprunner:runner_port}
Jean-Baptiste Petre's avatar
Jean-Baptiste Petre committed
674

675
[runner-sshd-promise]
676
recipe = slapos.cookbook:check_port_listening
677 678 679
path = $${directory:promises}/runner-sshd
hostname = $${slap-network-information:global-ipv6}
port = $${runner-sshd-port:port}
680

681 682
[symlinks]
recipe = cns.recipe.symlink
683
symlink_target = $${directory:bin}
684
symlink_base = ${buildout:directory}/bin
685 686 687

[slap-parameter]
# Default value if no ssh key is specified
688
user-authorized-key =
689
# Default value of instances number in slaprunner
690
instance-amount = 10
691 692
debug = false
frontend-domain =
693
slapos-repository = https://lab.nexedi.com/nexedi/slapos.git
694
slapos-software =
695
slapos-software-type =
696
slapos-reference = 1.0
697
auto-deploy = false
698
auto-deploy-instance = true
699
autorun = false
700
slaprunner-httpd-port = 9686
701
instance-name =
702 703
monitor-cors-domains =
monitor-interface-url =
704
monitor-httpd-port = 8386
705

706 707
[slapos-cfg]
recipe = slapos.recipe.template:jinja2
708
template = ${template-slapos-cfg:location}/${template-slapos-cfg:filename}
709 710 711
rendered = $${slaprunner:slapos.cfg}
mode = 700
context =
712
  section slaprunner slaprunner
713 714
  import codecs codecs
  raw buildout_shared_part_list_dump ${template-buildout-shared-part-list:output}
715

716 717
[slapos-test-cfg]
recipe = slapos.recipe.template:jinja2
718
template = ${template-slapos-cfg:location}/${template-slapos-cfg:filename}
719 720 721 722 723
rendered = $${test-runner:slapos.cfg}
mode = 700
context =
  section slaprunner test-runner

724
[shellinabox]
725 726 727 728
recipe = slapos.recipe.template:jinja2
# We cannot use slapos.cookbook:wrapper here because this recipe escapes too much
socket = $${directory:run}/siab.sock
mode = 0700
729
rendered = $${directory:bin}/shellinaboxd
730 731 732 733
template = inline:
  #!/bin/sh
  exec ${shellinabox:location}/bin/shellinaboxd \
    --unixdomain-only=$${:socket}:$(id -u):$(id -g):0600 \
734
    --service "/:$(id -u):$(id -g):HOME:$${shell-environment:shell} -l"
735

736 737 738 739
[shellinabox-service]
recipe = slapos.cookbook:wrapper
command-line = $${directory:bin}/shellinaboxd
wrapper-path = $${directory:services}/shellinaboxd
740
hash-existing-files = $${buildout:directory}/software_release/buildout.cfg
741

742
[shell-environment]
743
shell = ${bash:location}/bin/bash
744
path = ${nano:location}/bin:${vim:location}/bin:${screen:location}/bin:${git:location}/bin:${curl:location}/bin:${python2.7:location}/bin:${tig:location}/bin:${zip:location}/bin:${mosh:location}/bin:${bash:location}/bin:$${buildout:directory}/bin/:/usr/bin:/bin/
745

746 747
[prepare-software]
recipe = slapos.cookbook:wrapper
748
command-line = ${curl:location}/bin/curl -g https://[$${slaprunner:ipv6}]:$${slaprunner:runner_port}/isSRReady --max-time 1 --insecure
749 750
wrapper-path = $${directory:scripts}/prepareSoftware

751 752 753 754 755 756 757
[cron-entry-prepare-software]
<= cron
recipe = slapos.cookbook:cron.d
name = prepare-software
frequency = */2 * * * *
command = $${prepare-software:wrapper-path}

758 759 760
[instance-parameters]
recipe = slapos.recipe.template:jinja2
extensions = jinja2.ext.do
761
template = ${template-parameters:location}/${template-parameters:filename}
762 763
rendered = $${directory:etc}/.parameter.xml.default
mode = 0644
764
context =
765 766 767 768 769 770 771 772
  key slapparameter_dict slap-configuration:configuration

[deploy-instance-parameters]
recipe = plone.recipe.command
stop-on-error = true
parameter-xml = $${directory:etc}/.parameter.xml
command = if [ ! -f $${:parameter-xml} ]; then cp $${instance-parameters:rendered} $${:parameter-xml}; fi

773 774 775 776 777 778 779
[instance-software-type]
recipe = plone.recipe.command
stop-on-error = true
# XXX It should not be named with .xml as it is not xml
software-type-path = $${directory:etc}/.software_type.xml
command = if [ ! -f $${:software-type-path} -a "$${slap-parameter:slapos-software-type}" != "" ]; then echo "$${slap-parameter:slapos-software-type}" > $${:software-type-path}; fi

780 781 782 783 784
[instance-software]
recipe = plone.recipe.command
stop-on-error = true
command = SR=$${slap-parameter:slapos-software} && if [ -n "$SR" ] && [ ! -f "$${directory:etc}/.project" ]; then echo workspace/slapos/$${slap-parameter:slapos-software}/ > $${directory:etc}/.project; fi

785 786 787 788 789 790 791 792
[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}

793

794 795 796 797 798 799
[minishell-cwd]
recipe = plone.recipe.command
command = if [ ! -f $${slaprunner:minishell_cwd_file} ]; then echo $${runnerdirectory:home} > $${slaprunner:minishell_cwd_file}; fi
location = $${slaprunner:minishell_cwd_file}
stop-on-error = true

800
[bash-profile]
801 802 803 804
recipe = slapos.recipe.template:jinja2
template = ${template-bash-profile:location}/${template-bash-profile:filename}
rendered = $${buildout:directory}/.bash_profile
context =
805
    raw path $${shell-environment:path}
806
    raw shell $${shell-environment:shell}
807
    key terminfo terminfo:location
808
    key instance_name slap-parameter:instance-name
809
    key workdir runnerdirectory:home
Jérome Perrin's avatar
Jérome Perrin committed
810
    key home directory:home
811

812 813 814
[terminfo]
location = ${ncurses:location}/share/terminfo/

815 816 817 818
#---------------------------
#--
#-- supervisord managing slaprunner automation features

819
[supervisord]
820
autorestart = false
821 822 823 824
autostart = false
directory = $${buildout:directory}
exitcodes = 0
logfile = $${directory:log}/supervisord.log
825
no_logfile = NONE
826
numprocs = 1
827
path = $${shell-environment:path}
828
pidfile = $${directory:run}/supervisord.pid
829 830
ip = $${slaprunner:ipv4}
server = $${:ip}:$${:port}
831
port = 39986
832
slapgrid-cp = slapgrid-cp
833
slapgrid-cp-command = $${slaprunner:slapos} node instance --cfg $${:slapos-cfg} --verbose --logfile $${:slapgrid-cp-log}
834
slapgrid-cp-log = $${runnerdirectory:home}/instance.log
835
slapgrid-cp-startretries = 0
836
slapgrid-sr = slapgrid-sr
837
slapgrid-sr-command = $${slaprunner:slapos} node software --all --cfg $${:slapos-cfg} --verbose --logfile $${:slapgrid-sr-log}
838
slapgrid-sr-log = $${runnerdirectory:home}/software.log
839
slapgrid-sr-startretries = 0
840 841 842
slapproxy = slapproxy
slapproxy-autorestart = true
slapproxy-autostart = true
843
slapproxy-startsecs = 1
844
slapproxy-command = $${slaprunner:slapos} proxy start --logfile $${:slapproxy-log} --cfg $${:slapos-cfg}
845
slapproxy-log = $${directory:log}/slapproxy.log
846 847
socket_name = unix://$${:socket_path}
socket_path = $${directory:tmp}/supervisord.sock
848
startsecs = 0
849 850 851
# This file logs errors from listeners. Supervisord has its own logfile.
# Processes should handle their logs by themselves
stderr_logfile = $${directory:log}/supervisord-errors.log
852
slapos-cfg = $${slaprunner:slapos.cfg}
853 854 855 856 857 858

[supervisord-conf]
recipe = slapos.recipe.template:jinja2
template = ${template-supervisord:location}/${template-supervisord:filename}
rendered = $${directory:etc}/supervisord.conf
context =
859 860
    import multiprocessing multiprocessing
    import builtin __builtin__
861
    section supervisord supervisord
862
    key slapparameter_dict slap-configuration:configuration
863 864 865 866 867 868 869 870 871 872
    key listener_slapgrid listener-slapgrid-bin:rendered

[listener-slapgrid-bin]
recipe = slapos.recipe.template:jinja2
template = ${template-listener-slapgrid:location}/${template-listener-slapgrid:filename}
rendered = $${directory:bin}/listener_slapgrid.py
mode = 0744
context =
    section supervisord supervisord
    section slaprunner slaprunner
873
    raw python_executable ${buildout:directory}/bin/${extra-eggs:interpreter}
874 875 876 877 878

[supervisord-wrapper]
recipe = slapos.cookbook:wrapper
command-line = $${buildout:directory}/bin/supervisord -c $${supervisord-conf:rendered} --nodaemon
wrapper-path = $${directory:services}/supervisord
879
hash-existing-files = $${buildout:directory}/software_release/buildout.cfg
880

881 882 883
[logrotate-entry-supervisord]
<= logrotate-entry-base
name = supervisord
Ivan Tyagov's avatar
Ivan Tyagov committed
884
log = $${directory:log}/slapproxy.log $${directory:log}/supervisord.log $${directory:log}/supervisord-errors.log
885
post = kill -USR2 $(cat $${buildout:directory}/var/run/supervisord.pid)
886

887 888 889
[logrotate-entry-slapgrid]
<= logrotate-entry-base
name = slapgrid
Ivan Tyagov's avatar
Ivan Tyagov committed
890
log = $${runnerdirectory:home}/instance/*/.slapgrid/log/instance.log $${runnerdirectory:home}/instance/*/.slapgrid/promise/log/*.log
891

892 893 894 895 896 897
[supervisord-promise]
recipe = slapos.cookbook:check_port_listening
path = $${directory:promises}/supervisord
hostname = $${slaprunner:ipv4}
port = $${supervisord:port}

898
# XXX Monitor
899
[monitor-instance-parameter]
900
monitor-httpd-port = $${slap-parameter:monitor-httpd-port}
901 902 903
{% if slapparameter_dict.get('name', '') -%}
monitor-title = {{ slapparameter_dict['name'] }}
{% endif -%}
904
cors-domains = {{ slapparameter_dict.get('monitor-cors-domains', 'monitor.app.officejs.com') }}
905 906 907
{% if slapparameter_dict.get('monitor-username', '') -%}
username = {{ slapparameter_dict['monitor-username'] }}
{% endif -%}
908
password = $${runner-htpasswd:password}
909
{% if slapparameter_dict.get('monitor-url-list', '') -%}
910
monitor-url-list = {{ slapparameter_dict['monitor-url-list'] }}
911 912
{% endif -%}
instance-configuration =
913
  httpdcors cors-domain $${slaprunner-httpd-cors:location} $${httpd-graceful-wrapper:output}
914
configuration-file-path = $${buildout:directory}/knowledge0.cfg
915

916 917 918 919
[monitor-conf-parameters]
private-path-list +=
  $${logrotate-directory:logrotate-backup}

920 921 922
[monitor-check-webrunner-internal-instance]
recipe = slapos.recipe.template:jinja2
template = ${monitor-check-webrunner-internal-instance:location}/${monitor-check-webrunner-internal-instance:filename}
923
rendered = $${monitor-directory:bin}/$${:filename}
924 925 926
filename = monitor-check-webrunner-internal-instance
mode = 0744

927 928 929
## Slapuser slapos command script
[template-slapuser-script]
recipe = slapos.recipe.template:jinja2
930
template = ${template-slapuser-script:location}/${template-slapuser-script:filename}
931 932 933 934 935
rendered = $${buildout:bin-directory}/slapos
mode = 0744
context =
  raw config_location $${slapos-cfg:rendered}
  raw slapos_python_file_location ${buildout:bin-directory}/slapos