slaprunner : is now deployed by buildout
[slapos.git] / software / slaprunner / instance-runner.cfg
1 [buildout]
2 parts =
3   nginx_conf
4   nginx-launcher
5   cloud9
6   certificate-authority
7   ca-nginx
8   ca-node-frontend
9   test-runner
10   sshkeys-dropbear-runner
11   dropbear-server-add-authorized-key
12   sshkeys-authority
13   publish-connection-informations
14   slaprunner-promise
15   slaprunner-frontend-promise
16   cloud9-promise
17   cloud9-frontend-promise
18   dropbear-promise
19   symlinks
20   request-cloud9-frontend
21   node-frontend-promise
22   nginx-promise
23   environ
24   slapos-cfg
25   slaprunner-wrapper
26
27 eggs-directory = ${buildout:eggs-directory}
28 develop-eggs-directory = ${buildout:develop-eggs-directory}
29 offline = true
30
31
32 # Create all needed directories
33 [directory]
34 recipe = slapos.cookbook:mkdirectory
35 etc = $${buildout:directory}/etc/
36 var = $${buildout:directory}/var/
37 srv = $${buildout:directory}/srv/
38 bin = $${buildout:directory}/bin/
39 tmp = $${buildout:directory}/tmp/
40
41 sshkeys = $${:srv}/sshkeys
42 services = $${:etc}/service/
43 scripts = $${:etc}/run/
44 ssh = $${:etc}/ssh/
45 log = $${:var}/log/
46 run = $${:var}/run/
47 backup = $${:srv}/backup/
48 promises = $${:etc}/promise/
49 test = $${:etc}/test/
50 nginx-data = $${directory:srv}/nginx
51 ca-dir = $${:srv}/ssl
52
53
54 [runnerdirectory]
55 recipe = slapos.cookbook:mkdirectory
56 home = $${directory:srv}/runner/
57 test = $${directory:srv}/test/
58 project = $${:home}/project
59 software-root = $${:home}/software
60 instance-root = $${:home}/instance
61 project-test = $${:test}/project
62 software-test = $${:test}/software
63 instance-test = $${:test}/instance
64 sessions = $${buildout:directory}/.sessions
65
66 #Create password recovery code for slaprunner
67 [recovery-code]
68 recipe = slapos.cookbook:generate.password
69 storage-path = $${directory:etc}/.rcode
70 bytes = 4
71
72 # Deploy cloud9 and slaprunner
73 [cloud9]
74 recipe = slapos.cookbook:cloud9
75 ip = $${slap-network-information:local-ipv4}
76 port = 4443
77 wrapper = $${directory:services}/cloud9
78 working-directory = $${runnerdirectory:home}
79 git-binary = ${git:location}/bin/git
80 node-binary = ${nodejs:location}/bin/node
81 cloud9 = ${cloud9:executable}
82
83 [slaprunner]
84 slaprunner = ${buildout:directory}/bin/slaprunner
85 slapgrid_sr = ${buildout:directory}/bin/slapgrid-sr
86 slapgrid_cp = ${buildout:directory}/bin/slapgrid-cp
87 slapproxy = ${buildout:directory}/bin/slapproxy
88 supervisor = ${buildout:directory}/bin/slapgrid-supervisorctl
89 git-binary = ${git:location}/bin/git
90 slapos.cfg = $${directory:etc}/slapos.cfg
91 working-directory = $${runnerdirectory:home}
92 project-directory = $${runnerdirectory:project}
93 software-directory = $${runnerdirectory:software-root}
94 instance-directory = $${runnerdirectory:instance-root}
95 etc_dir = $${directory:etc}
96 log_dir =  $${directory:log}
97 run_dir = $${directory:run}
98 ssh_client = $${sshkeys-dropbear-runner:wrapper}
99 public_key = $${sshkeys-dropbear-runner:public-key}
100 private_key = $${sshkeys-dropbear-runner:private-key}
101 ipv4 = $${slap-network-information:local-ipv4}
102 ipv6 = $${slap-network-information:global-ipv6}
103 proxy_port = 50000
104 runner_port = 50005
105 partition-amount = $${slap-parameter:instance-amount}
106 cloud9-url = $${cloud9:access-url}
107 wrapper = $${directory:services}/slaprunner
108 debug = $${slap-parameter:debug}
109 access-url = https://[$${:ipv6}]:$${:runner_port} 
110
111 [test-runner]
112 <= slaprunner
113 recipe = slapos.cookbook:slaprunner.test
114 slaprunnertest = ${buildout:directory}/bin/slaprunnertest
115 slapos.cfg = $${directory:etc}/slapos-test.cfg
116 working-directory = $${runnerdirectory:test}
117 project-directory = $${runnerdirectory:project-test}
118 software-directory = $${runnerdirectory:software-test}
119 instance-directory = $${runnerdirectory:instance-test}
120 proxy_port = 8602
121 wrapper = $${directory:bin}/runTestSuite
122 etc_dir = $${directory:test}
123
124
125 # Deploy dropbear (minimalist SSH server)
126 [sshkeys-directory]
127 recipe = slapos.cookbook:mkdirectory
128 requests = $${directory:sshkeys}/requests/
129 keys = $${directory:sshkeys}/keys/
130
131 [sshkeys-authority]
132 recipe = slapos.cookbook:sshkeys_authority
133 request-directory = $${sshkeys-directory:requests}
134 keys-directory = $${sshkeys-directory:keys}
135 wrapper = $${directory:services}/sshkeys_authority
136 keygen-binary = ${dropbear:location}/bin/dropbearkey
137
138 [dropbear-runner-server]
139 recipe = slapos.cookbook:dropbear
140 host = $${slap-network-information:global-ipv6}
141 port = 22222
142 home = $${directory:ssh}
143 wrapper = $${directory:bin}/runner_sshd
144 shell = ${bash:location}/bin/bash
145 rsa-keyfile = $${directory:ssh}/server_key.rsa
146 dropbear-binary = ${dropbear:location}/sbin/dropbear
147
148 [sshkeys-dropbear-runner]
149 <= sshkeys-authority
150 recipe = slapos.cookbook:sshkeys_authority.request
151 name = dropbear
152 type = rsa
153 executable = $${dropbear-runner-server:wrapper}
154 public-key = $${dropbear-runner-server:rsa-keyfile}.pub
155 private-key = $${dropbear-runner-server:rsa-keyfile}
156 wrapper = $${directory:services}/runner_sshd
157
158 [dropbear-server-add-authorized-key]
159 <= dropbear-runner-server
160 recipe = slapos.cookbook:dropbear.add_authorized_key
161 key = $${slap-parameter:authorized-key}
162
163 #---------------------
164 #--
165 #-- Set node frontend
166
167 [node-frontend]
168 launcher = $${directory:bin}/node-frontend
169 ip = $${slap-network-information:global-ipv6}
170 port = $${cloud9:port}
171 access-url = https://[$${:ip}]:$${:port}
172
173 [node-frontend-launcher]
174 recipe = slapos.recipe.template:jinja2
175 template = ${node-frontend-template:location}/${node-frontend-template:filename}
176 rendered = $${node-frontend:launcher}
177 mode = 700
178 context =
179         key ip node-frontend:ip
180         key port node-frontend:port
181         key key ca-node-frontend:key-file
182         key certificate ca-node-frontend:cert-file
183         key backend_ip nginx-frontend:local-ip
184         key backend_port nginx-frontend:port
185         raw shell_path ${bash:location}/bin/bash
186         raw node_env ${buildout:parts-directory}:${npm-modules:location}/node_modules
187         raw node_path ${nodejs:location}/bin/node
188         raw conf_path ${simple-proxy:location}/${simple-proxy:filename}
189
190 #---------------------------
191 #--
192 #-- Set nginx frontend
193
194 [tempdirectory]
195 recipe = slapos.cookbook:mkdirectory
196 client_body_temp_path = $${directory:tmp}/client_body_temp_path
197 proxy_temp_path = $${directory:tmp}/proxy_temp_path
198 fastcgi_temp_path = $${directory:tmp}/fastcgi_temp_path
199 uwsgi_temp_path = $${directory:tmp}/uwsgi_temp_path
200 scgi_temp_path = $${directory:tmp}/scgi_temp_path
201
202 [nginx-frontend]
203 # Options
204 nb_workers = 2
205 # Network
206 local-ip = $${slap-network-information:local-ipv4}
207 port = 30001
208 global-ip = $${slap-network-information:global-ipv6}
209 global-port = $${slaprunner:runner_port}
210 # Backend
211 cloud9-ip = $${cloud9:ip}
212 cloud9-port = $${cloud9:port}
213 runner-ip = $${slaprunner:ipv4}
214 runner-port = $${slaprunner:runner_port}
215 # SSL
216 ssl-certificate = $${ca-nginx:cert-file}
217 ssl-key = $${ca-nginx:key-file}
218 # Log
219 path_pid = $${directory:run}/nginx.pid
220 path_log = $${directory:log}/nginx.log
221 path_access_log = $${directory:log}/nginx.access.log
222 path_error_log = $${directory:log}/nginx.error.log
223 path_tmp = $${buildout:directory}/tmp
224 # Config files
225 path_nginx_conf = $${directory:etc}/nginx.conf
226 # Executables
227 bin_nginx = ${nginx:location}/sbin/nginx
228 bin_launcher = $${directory:bin}/launcher
229 # Utils
230 path_shell = ${dash:location}/bin/dash
231 # Misc.
232 etc_dir = $${directory:etc}
233
234
235 [nginx_conf]
236 recipe = slapos.recipe.template:jinja2
237 template = ${template_nginx_conf:location}/${template_nginx_conf:filename}
238 rendered = $${nginx-frontend:path_nginx_conf}
239 context =
240     section param_nginx_frontend nginx-frontend
241     section param_tempdir tempdirectory
242
243 [nginx-launcher]
244 recipe = slapos.recipe.template:jinja2
245 template = ${template_launcher:location}/${template_launcher:filename}
246 rendered = $${nginx-frontend:bin_launcher}
247 mode = 700
248 context =
249     section param_nginx_frontend nginx-frontend
250
251 #--------------------
252 #--
253 #-- ssl certificates
254
255 [certificate-authority]
256 recipe = slapos.cookbook:certificate_authority
257 openssl-binary = ${openssl:location}/bin/openssl
258 ca-dir = $${directory:ca-dir}
259 requests-directory = $${cadirectory:requests}
260 wrapper = $${directory:services}/certificate_authority
261 ca-private = $${cadirectory:private}
262 ca-certs = $${cadirectory:certs}
263 ca-newcerts = $${cadirectory:newcerts}
264 ca-crl = $${cadirectory:crl}
265
266 [cadirectory]
267 recipe = slapos.cookbook:mkdirectory
268 requests = $${directory:ca-dir}/requests/
269 private = $${directory:ca-dir}/private/
270 certs = $${directory:ca-dir}/certs/
271 newcerts = $${directory:ca-dir}/newcerts/
272 crl = $${directory:ca-dir}/crl/
273
274 [ca-nginx]
275 <= certificate-authority
276 recipe = slapos.cookbook:certificate_authority.request
277 key-file = $${cadirectory:certs}/nginx_frontend.key
278 cert-file = $${cadirectory:certs}/nginx_frontend.crt
279 executable = $${nginx-launcher:rendered}
280 wrapper = $${directory:services}/nginx-frontend
281 # Put domain name
282 name = example.com
283
284 [ca-node-frontend]
285 <= certificate-authority
286 recipe = slapos.cookbook:certificate_authority.request
287 key-file = $${cadirectory:certs}/nodejs.key
288 cert-file = $${cadirectory:certs}/nodejs.crt
289 executable = $${node-frontend-launcher:rendered}
290 wrapper = $${directory:services}/node-frontend
291 # Put domain name
292 name = example.com
293
294 #--------------------
295 #--
296 #-- Request frontend
297
298 [request-frontend]
299 <= slap-connection
300 recipe = slapos.cookbook:requestoptional
301 name = SlapRunner Frontend
302 # XXX We have hardcoded SR URL here.
303 software-url = http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD:/software/apache-frontend/software.cfg
304 slave = true
305 config = url domain
306 config-url = $${node-frontend:access-url}
307 config-domain = $${slap-parameter:frontend-domain}
308 return = site_url domain
309
310 [request-cloud9-frontend]
311 <= slap-connection
312 recipe = slapos.cookbook:requestoptional
313 name = Cloud9 Frontend
314 software-url = http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD:/software/apache-frontend/software.cfg
315 slave = true
316 config = url domain
317 config-url = $${node-frontend:access-url}
318 config-domain = $${slap-parameter:cloud9-frontend-domain}
319 return = site_url domain
320
321 #--------------------------------------
322 #--
323 #-- Send informations to SlapOS Master
324
325 [publish-connection-informations]
326 recipe = slapos.cookbook:publish
327 1_info = Set your passord in slaprunner in order to access cloud9
328 backend_url = $${slaprunner:access-url}
329 url =  https://$${request-frontend:connection-domain}
330 cloud9_backend_url = $${node-frontend:access-url}
331 cloud9_url = https://$${request-cloud9-frontend:connection-domain}
332 ssh_command = ssh $${dropbear-runner-server:host} -p $${dropbear-runner-server:port}
333 password_recovery_code = $${recovery-code:passwd}
334
335 #---------------------------
336 #--
337 #-- Deploy promises scripts
338
339 [slaprunner-promise]
340 recipe = slapos.cookbook:check_port_listening
341 path = $${directory:promises}/slaprunner
342 hostname = $${slaprunner:ipv6}
343 port = $${slaprunner:runner_port}
344
345 [slaprunner-frontend-promise]
346 recipe = slapos.cookbook:check_url_available
347 path = $${directory:promises}/slaprunner_frontend
348 url = https://$${request-frontend:connection-domain}
349 dash_path = ${dash:location}/bin/dash
350 curl_path = ${curl:location}/bin/curl
351
352 [cloud9-promise]
353 recipe = slapos.cookbook:check_url_available
354 path = $${directory:promises}/cloud9
355 url = http://$${cloud9:ip}:$${cloud9:port}
356 dash_path = ${dash:location}/bin/dash
357 curl_path = ${curl:location}/bin/curl
358
359 [cloud9-frontend-promise]
360 recipe = slapos.cookbook:check_url_available
361 path = $${directory:promises}/cloud9-frontend-promise
362 url = $${publish-connection-informations:cloud9_url}
363 check-secure = 1
364 dash_path = ${dash:location}/bin/dash
365 curl_path = ${curl:location}/bin/curl
366
367 [node-frontend-promise]
368 recipe = slapos.cookbook:check_port_listening
369 path = $${directory:promises}/node-frontend
370 hostname = $${node-frontend:ip}
371 port = $${node-frontend:port}
372
373 [nginx-promise]
374 recipe = slapos.cookbook:check_port_listening
375 path = $${directory:promises}/nginx
376 hostname = $${nginx-frontend:local-ip}
377 port = $${nginx-frontend:port}
378
379 [dropbear-promise]
380 recipe = slapos.cookbook:check_port_listening
381 path = $${directory:promises}/dropbear
382 hostname = $${dropbear-runner-server:host}
383 port = $${dropbear-runner-server:port}
384
385 [symlinks]
386 recipe = cns.recipe.symlink
387 symlink_target = $${directory:bin}
388 symlink_base = ${buildout:directory}/bin
389
390 [slap-parameter]
391 # Default value if no ssh key is specified
392 authorized-key =
393 # Default value of instances number in slaprunner
394 instance-amount = 10
395 debug = false
396 cloud9-frontend-domain =
397 frontend-domain =
398
399 [slapos-cfg]
400 recipe = slapos.recipe.template:jinja2
401 template = ${slapos-cfg-template:location}/${slapos-cfg-template:filename}
402 rendered = $${slaprunner:slapos.cfg}
403 mode = 700
404 supd-temp-var = $${directory:etc}/supervisord.conf
405 prox-db-var = $${slaprunner:working-directory}/proxy.db
406 context =
407   key software_root runnerdirectory:software-root
408   key instance_root runnerdirectory:instance-root
409   key ipv4 slaprunner:ipv4
410   key proxy_port slaprunner:proxy_port
411   key partition_amount slaprunner:partition-amount
412   key slapgrid_sr slaprunner:slapgrid_sr 
413   key slapgrid_cp slaprunner:slapgrid_cp
414   key slapproxy slaprunner:slapproxy 
415   key supervisor slaprunner:supervisor
416   key supervisord_config slapos-cfg:supd-temp-var
417   key runner_workdir slaprunner:working-directory
418   key runner_port slaprunner:runner_port
419   key ipv6 slaprunner:ipv6
420   key etc_dir slaprunner:etc_dir
421   key proxy_host slaprunner:ipv4
422   key proxy_database slapos-cfg:prox-db-var
423   key ssh_client slaprunner:ssh_client
424   key public_key slaprunner:public_key
425   key private_key slaprunner:private_key
426   key git slaprunner:git-binary
427   key cloud9_url slaprunner:cloud9-url
428   key run_dir slaprunner:run_dir
429   key log_dir slaprunner:log_dir
430
431 [environ]
432 recipe = collective.recipe.environment
433
434 [slaprunner-wrapper]
435 recipe = slapos.cookbook:wrapper
436 command-line = $${slaprunner:slaprunner} $${slaprunner:slapos.cfg} --log_file $${:log-file}
437 log-file = $${slaprunner:log_dir}/slaprunner.log
438 wrapper-path = $${slaprunner:wrapper}
439 environment = PATH=$${slaprunner:git-binary}:$${environ:PATH}
440   GIT_SSH=$${slaprunner:ssh_client}