This repository has been archived by the owner on Jun 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
platform.yml
592 lines (503 loc) · 20.4 KB
/
platform.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
---
- name: Installing platform
hosts: rockstat
become: yes
tasks:
- debug:
msg:
email: "{{_email}}"
realname: "{{_fullname}}"
domain: "{{_domain}}"
admin_password: "{{_admin_password}}"
enable_support: "{{_enable_support}}"
ssl_wildcard: "{{_ssl_wildcard}}"
tags: ['never']
#### ##### ##### ##### ##### Check is python 3 ##### ##### ##### ##### #####
- name: Checking python version is 3
assert:
that:
- "ansible_python_interpreter == '/usr/bin/python3'"
msg: "Required python 3. Details: https://docs.ansible.com/ansible/latest/reference_appendices/python_3_support.html"
tags: ["always"]
- name: Build and set permissions for required dirs
block:
- name: Creating directories
command: "mkdir -p {{ block_dirs }}"
args:
warn: False
- name: Setting permissions
command: "chown {{_uid}}:{{_gid}} {{ block_dirs }}"
args:
warn: False
vars:
block_dirs: "{{ create_dirs|flatten|join(' ') }}"
tags: ["never", "full", "platform", "dirs"]
##### ##### ##### ##### ##### Server configuration ##### ##### ##### ##### #####
- block:
- name: BaseServer role execution
include_role:
name: dr.server
vars:
drs_setup_user: yes
drs_user: '{{support_user}}'
drs_home_dir: "{{home_dir}}"
drs_pub_key_file: '{{support_key_file}}'
drs_disable_ipv6: "{{disable_ipv6}}"
drs_extra_hosts: "{{etc_hosts}}"
drs_uid: "{{_gid}}"
drs_gid: "{{_uid}}"
r_authorized_key_remove: "{{ not _enable_support }}"
when: 'setup_server == True'
tags: ['never', 'os', 'network', 'system', 'full']
##### ##### ##### ##### ##### Check DNS configuration ##### ##### ##### ##### #####
# Should be after server configuration role that ensure dns utils is installed
- block:
- include_tasks: tasks/check_dns.yml
vars:
check_domains: "{{_domains + [_domain]}}"
tags: ['never', 'ssl', 'full']
##### ##### ##### ##### ##### Docker server ##### ##### ##### ##### #####
- block:
- name: Docker role execution
include_role:
name: dr.docker
vars:
drd_users:
- "{{support_user}}"
drd_create_network: yes
drd_version: edge
drd_net_name: '{{docker_net_name}}'
drd_bind_ip: "{{docker_host_ip}}"
drd_interface: '{{docker_interface}}'
drd_net: '{{docker_net}}'
drd_mtu: '1400'
tags: ['never', 'system', 'docker', 'full']
##### ##### ##### ##### ##### Dashboard ##### ##### ##### ##### #####
- name: Cloning Dashboard content
git:
repo: '{{repos.dashboard}}'
version: HEAD
force: yes
accept_hostkey: yes
dest: '{{dirs.dashboard}}'
tags: ['dashboard', 'platform', 'ppart', 'band', 'static', 'full']
##### ##### ##### ##### ##### Splash screen ##### ##### ##### ##### #####
- block:
- name: Cloning Splash content
git:
repo: "{{repos.splash}}"
dest: "{{dirs.splash}}"
accept_hostkey: yes
force: yes
- template:
src: google-webmaster.j2
dest: "{{dirs.splash}}/{{_google_webmaster}}"
when: "_google_webmaster is defined and _google_webmaster != ''"
tags: ['splash', 'platform', 'ppart', 'band', 'static', 'full']
##### ##### ##### ##### ##### Exposeur (UFW, iptables) ##### ##### ##### ##### #####
- block:
- name: Exposeur role execution
include_role:
name: dr.exposeur
vars:
expo_reset_ufw: true
expo_rules: '{{firewall_rules|flatten + host_firewall_rules|default([]) + group_firewall_rules|default([])}}'
expo_expose_rules: '{{expose_rules|default([]) + host_expose_rules|default([]) + group_expose_rules|default([])}}'
tags: ['never', 'firewall', 'network', 'system', 'full']
##### ##### ##### ##### ##### Lets encrypt - acme.sh ##### ##### ##### ##### #####
- block:
- name: LetsEncrypt role execution
include_role:
name: dr.letsencrypt.wildcard.auto
vars:
_r_domain: "{{_domain}}"
_r_subdomains: "{{_subdomains}}"
_r_webroot: "{{dirs.well_known}}"
_r_force: "{{ssl_force|default(False)|bool}}"
_r_wildcard: "{{_ssl_wildcard}}"
_r_docker_networks: [ { name: "{{docker_net_name}}" } ]
_r_docker_labels: "{{ {}|combine(labels, docker_band_lbls) }}"
_r_check_addr: "{{if_inner}}:{{ports.http.0}}"
_r_bind_addr: "{{if_inner}}:{{ports.letsencrypt.0}}"
_r_cert_root: "{{dirs.certs}}"
_r_dns_provider: "{{_ssl_dns_provider|default('dns_acmedns')}}"
_r_dns_envs: "{{_ssl_dns_envs|default({})}}"
_r_debug: yes
_r_log: no
- shell: nginx -t && nginx -s reload || /bin/true
vars:
oldloc: "/etc/letsencrypt/live/{{_domain}}"
labels:
band.service.title: "SSL Renewer"
band.service.def_position: "0x6"
when: "_setup_ssl == True"
tags: ['never', 'full', 'system', 'ssl']
##### ##### ##### ##### ##### Nginx ##### ##### ##### ##### #####
- block:
- include_vars: vars/nginx.yml
- name: Nginx role execution
include_role:
name: jdauphant.nginx
vars:
nginx_official_repo: no
keep_only_specified: yes
nginx_http_params: '{{_nginx_http_params}}'
nginx_sites: "{{_nginx_sites|combine(_nginx_sites_extra|default({}))}}"
nginx_auth_basic_files:
common: "{{ common_users|flatten }}"
nginx_configs:
upgrade: '{{_nginx_proto_upgrade}}'
gzip: '{{_nginx_gzip_params}}'
proxy: '{{_nginx_proxy_params + _nginx_proxy_params_extra|default([])}}'
upstream: '{{_nginx_upstreams + _nginx_upstreams_extra|default([]) }}'
ssl: '{{_nginx_ssl_params}}'
vars:
# local_config: "{{ansible_local.config|default({})}}"
# local_general: "{{local_config.general|default({})}}"
common_users:
- "admin:{{_admin_password}}"
# - "{{local_general.users}}"
when: "setup_nginx == True"
tags: ['never', 'nginx', 'httpd', 'system', 'full']
##### ##### ##### ##### ##### Netdata ##### ##### ##### ##### #####
- block:
- name: Netdata container
docker_container:
name: netdata
hostname: netdata
image: "{{images.netdata}}"
labels: "{{docker_band_lbls}}"
ports:
- "{{if_inner}}:{{ports.netdata.0}}:{{ports.netdata.1}}"
- "{{if_inner}}:{{ports.statsd.0}}:{{ports.statsd.1}}/udp"
networks: [ { name: "{{docker_net_name}}" } ]
etc_hosts: "{{etc_hosts}}"
restart_policy: "{{_restart_policy}}"
pull: yes
env: "{{container_env}}"
restart: yes
# recreate: yes
memory: "200m"
capabilities:
- SYS_PTRACE
security_opts:
- apparmor:unconfined
volumes:
- /proc:/host/proc:ro
- /sys:/host/sys:ro
- /var/run/docker.sock:/var/run/docker.sock
- name: Netdata role execution
include_role:
name: dr.netdata
vars:
drn_action: remove
drn_allow:
dashboard_from: "*"
badges_from: "*"
conf_from: "*"
connections_from: "*"
streaming_from: "*"
drn_stream: '{{netdata_stream_config|default({})}}'
drn_backend: '{{netdata_backend_config|default({})}}'
drn_bind_to: "{{if_inner}}"
vars:
container_env:
PGID: "999"
tags: ['never', 'netdata', 'system', 'full']
##### ##### ##### ##### ##### Clickhouse ##### ##### ##### ##### #####
- block:
- name: ClickHouse role execution
include_role:
name: AlexeySetevoi.clickhouse
vars:
clickhouse_listen_host_default: ["127.0.0.1", "::1", "{{if_inner}}"]
clickhouse_networks_default: ["127.0.0.1", "::1", "{{docker_net}}"]
clickhouse_profiles_custom: "{{_clickhouse_profiles_custom}}"
clickhouse_users_custom: "{{_clickhouse_users_custom}}"
clickhouse_logger: "{{_clickhouse_logger}}"
clickhouse_dbs_custom: [ {name: '{{ch_db}}'} ]
clickhouse_path_data: "{{dirs.clickhouse}}"
clickhouse_path_tmp: "{{dirs.clickhouse_tmp}}"
tags: ['never', 'clickhouse', 'clickhouse-server', 'system', 'full']
##### ##### ##### ##### ##### Redis server ##### ##### ##### ##### #####
- name: Redis setup
block:
- name: Starting container for service Redis
docker_container:
name: redis
hostname: redis
image: "{{images.redis}}"
# labels: "{{docker_band_lbls}}"
networks: [ { name: "{{docker_net_name}}" } ]
etc_hosts: "{{etc_hosts}}"
restart_policy: "{{_restart_policy}}"
restart: yes
pull: yes
recreate: yes
memory: "300m"
ports: ["{{if_inner}}:{{ports.redis.0}}:{{ports.redis.1}}"]
volumes: ["{{dirs.redis}}:/data"]
tags: ['never', 'redis', 'system', 'docker-container', 'full']
##### ##### ##### ##### ##### Band Director ##### ##### ##### ##### #####
- block:
- name: Pulling latest Band framework base image from docker hub
docker_image:
name: "{{images.band}}"
pull: yes
force: yes
- name: Pulling BandSet services collection content from git
git:
repo: "{{repos.band_set}}"
dest: "{{dirs.band_set}}"
version: "{{branch}}"
accept_hostkey: yes
force: yes
- name: Starting container for service Director
docker_container:
name: director
hostname: director
image: "{{images.director}}"
labels: "{{docker_band_lbls}}"
ports: [ "{{if_inner}}:{{ports.director.0}}:{{ports.director.1}}" ]
networks: [ { name: "{{docker_net_name}}" } ]
etc_hosts: "{{etc_hosts}}"
env: "{{ container_env|combine({'ENCODED_ENV': container_env|to_json }) }}"
restart_policy: "{{_restart_policy}}"
pull: yes
restart: yes
recreate: yes
memory: "300m"
volumes:
- "{{dirs.band_set}}:/images/band_set"
- "{{dirs.rockme_set}}:/images/rockme_set"
- "{{dirs.user_images}}:/images/user"
- "{{dirs.director_data}}:/data" # containers configs
- "{{dirs.environments}}:/data/environments"
- "{{dirs.etc_dir}}:/srv/platform/etc"
- "/var/run/docker.sock:/var/run/docker.sock"
vars:
service: director
tags: ['band', 'platform', 'ppart', 'director', 'docker-container', 'full']
##### ##### ##### ##### ##### Front ##### ##### ##### ##### #####
- block:
- docker_container: name=frontier state=absent
- name: Starting container for service Front
docker_container:
name: front
hostname: front
image: "{{ images.front }}"
labels: "{{ docker_band_lbls }}"
ports:
- "{{if_inner}}:{{ports.front.0}}:{{ports.front.1}}"
- "{{if_inner}}:{{ports.front_ws.0}}:{{ports.front_ws.1}}"
networks: [ { name: "{{docker_net_name}}" } ]
etc_hosts: "{{etc_hosts}}"
env: "{{container_env}}"
restart_policy: "{{_restart_policy}}"
pull: yes
restart: yes
recreate: yes
memory: "300m"
volumes:
- "{{dirs.front_custom_config}}:/app/config/custom"
vars:
service: "front"
tags: ['front', 'platform', 'ppart', 'rockme', 'docker-container', 'full']
##### ##### ##### ##### ##### ClickHouse migrations ##### ##### ##### ##### #####
# - name: Including ClickHouse maintain role
# block:
# - import_tasks: tasks/ch_migrate.yml
# vars:
# operate_db: "{{ch_db}}"
# operate_host: "127.0.0.1"
# migrations_path: clickhouse_migrations
# tags: ['never', 'chmigrate']
##### ##### ##### ##### ##### Clickhouse Proxy ##### ##### ##### ##### #####
- block:
- name: Rendering CHProxy config
template:
src: 'chproxy/config.yml.j2'
dest: '{{chproxy_config}}'
- name: Starting container for service Chproxy
docker_container:
name: chproxy
hostname: chproxy
image: "{{images.chproxy}}"
labels: "{{docker_band_lbls}}"
networks: [ { name: "{{docker_net_name}}" } ]
etc_hosts: "{{etc_hosts}}"
restart_policy: "{{_restart_policy}}"
restart: yes
pull: yes
recreate: yes
memory: "200m"
ports: ["{{if_inner}}:{{ports.chproxy.0}}:{{ports.chproxy.1}}"]
volumes: ["{{chproxy_config}}:/config.yml:ro"]
vars:
chproxy_config: "{{etc_dir}}/chproxy.yml"
chproxy_defs: "{{_chproxy_defs}}"
chproxy_allowed_networks: "{{_chproxy_allowed_networks_default + _chproxy_allowed_networks|default([])}}"
chproxy_clusters: "{{_chproxy_clusters_default + _chproxy_clusters|default([])}}"
chproxy_users: "{{_chproxy_users_default + _chproxy_users|default([])}}"
tags: ['never', 'clickhouse-proxy', 'chproxy', 'platform', 'pservice', 'docker-container', 'full']
##### ##### ##### ##### ##### ClickHouse Writer ##### ##### ##### ##### #####
- block:
- name: Starting container for service ChWriter
docker_container:
name: chwriter
hostname: chwriter
image: "{{images.chwriter}}"
labels: "{{docker_band_lbls}}"
networks: [ { name: "{{docker_net_name}}" } ]
etc_hosts: "{{etc_hosts}}"
env: "{{container_env}}"
restart_policy: "{{_restart_policy}}"
pull: yes
restart: yes
recreate: yes
memory: "300m"
volumes:
- "{{dirs.chwriter_custom_config}}:/app/config/custom"
- "{{dirs.chwriter_custom_migrations}}:/app/migrations/custom"
- "{{dirs.chwriter_emergency}}:/app/emergency"
vars:
service: chwriter
tags: ['chwriter', 'platform', 'ppart', 'rockme', 'docker-container', 'full']
##### ##### ##### ##### ##### Heavyload ##### ##### ##### ##### #####
- block:
- name: Starting container for service Heavyload
docker_container:
name: heavyload
hostname: heavyload
image: "{{images.heavyload}}"
labels: "{{docker_band_lbls}}"
networks: [ { name: "{{docker_net_name}}" } ]
etc_hosts: "{{etc_hosts}}"
env: "{{container_env}}"
restart_policy: "{{_restart_policy}}"
pull: yes
restart: yes
memory: "500m"
volumes:
- "{{dirs.uploads}}:/go/src/heavyload/upload"
ports:
- "{{if_inner}}:{{ports.heavyload.0}}:{{ports.heavyload.1}}"
vars:
service: heavyload
tags: ['heavyload', 'platform', 'pservice', 'docker-container', 'full']
##### ##### ##### ##### ##### Anaconda ##### ##### ##### ##### #####
- block:
- name: Starting container for service Jupyter
docker_container:
name: anaconda
hostname: anaconda
image: "{{images.anaconda}}"
labels: "{{docker_band_lbls}}"
networks: [ { name: "{{docker_net_name}}" } ]
etc_hosts: "{{etc_hosts}}"
restart_policy: "{{_restart_policy}}"
pull: yes
recreate: yes
memory: "{{ anaconda_mem_limit|default('2g') }}"
volumes:
- "{{dirs.notebooks}}:/opt/notebooks:cached"
- "{{dirs.public}}:/opt/notebooks/public:cached"
ports: [ "{{if_inner}}:{{ports.jupyter.0}}:{{ports.jupyter.1}}" ]
env: "{{ container_env }}"
vars:
service: anaconda
cmd_parts:
when: 'setup_jupyter == True'
tags: ['never', 'anaconda', 'jupyter', 'platform', 'pservice', 'docker-container', 'full']
##### ##### ##### ##### ##### Grafana ##### ##### ##### ##### #####
- block:
- name: Creating Grafana datadir
file:
state: directory
path: "{{dirs.grafana_data}}"
owner: "{{_uid}}" # grafana container ids
group: "{{_gid}}"
- name: Starting container for service Grafana
docker_container:
name: grafana
hostname: grafana
image: "{{images.grafana}}"
labels: "{{docker_band_lbls}}"
networks: [ { name: "{{docker_net_name}}" } ]
etc_hosts: "{{etc_hosts}}"
restart_policy: "{{_restart_policy}}"
pull: yes
restart: yes
recreate: yes
memory: "300m"
ports:
- "{{if_inner}}:{{ports.grafana.0}}:{{ports.grafana.1}}"
volumes:
- '{{dirs.grafana_data}}:/var/lib/grafana'
tags: ['never', 'grafana', 'platform', 'pservice', 'docker-container', 'full']
##### ##### ##### ##### ##### Theia ##### ##### ##### ##### #####
- block:
- name: Fix workspace permissions
command: "chown -R {{_uid}}:{{_gid}} {{dirs.workspace}}"
args:
warn: False
- name: Starting container for service Theia
docker_container:
name: theia
hostname: theia
image: "{{images.theia}}"
labels: "{{docker_band_lbls}}"
ports: [ "{{if_inner}}:{{ports.theia.0}}:{{ports.theia.1}}" ]
networks: [ { name: "{{docker_net_name}}" } ]
etc_hosts: "{{etc_hosts}}"
env: "{{ container_env }}"
restart_policy: "{{_restart_policy}}"
pull: yes
restart: yes
recreate: yes
memory: "1g"
volumes:
- "{{dirs.workspace}}:{{project_dir}}:cached"
- "{{dirs.user_images}}:{{project_dir}}/images:cached"
- "{{dirs.user_libraries}}:{{project_dir}}/libraries:cached"
- "{{dirs.public}}:{{project_dir}}/public:cached"
- "{{dirs.chwriter_custom_migrations}}:{{project_dir}}/config/migrations:cached"
- "{{dirs.band_set}}:{{project_dir}}/sources_ro/band_set:ro"
- "{{dirs.band_set}}/__skeletons:{{project_dir}}/sources_ro/skeletons:ro"
- "{{dirs.chwriter_custom_config}}:{{custom_config_dir}}/chwriter:cached"
- "{{dirs.front_custom_config}}:{{custom_config_dir}}/front:cached"
- "{{dirs.environments}}:{{config_dir}}/environments:cached"
vars:
project_dir: /home/theia/project
config_dir: "{{project_dir}}/config"
custom_config_dir: "{{config_dir}}/custom"
service: theia
when: 'setup_theia == True'
tags: ['theia', 'platform', 'pservice', 'band', 'docker-container', 'full']
##### ##### ##### ##### ##### VPN Server ##### ##### ##### ##### #####
- import_tasks: tasks/setup_vpn_server.yml
tags: ['never', 'ovpn-server']
##### ##### ##### ##### ##### Custom tasks ##### ##### ##### ##### #####
- import_tasks: tasks/custom.yml
##### ##### ##### ##### ##### Fake Shop ##### ##### ##### ##### #####
- block:
- name: Starting container for service Fake-Shop
docker_container:
name: "{{service}}"
hostname: "{{service}}"
image: "{{images[service]}}"
labels: "{{docker_band_lbls}}"
env: "{{container_env}}"
restart_policy: "{{_restart_policy}}"
pull: yes
restart: yes
memory: "50m"
ports:
- "{{if_inner}}:{{ports[service].0}}:{{ports[service].1}}"
vars:
service: fakeshop
tags: ['never', 'fakeshop', 'platform', 'pservice', 'docker-container', 'full']
- docker_container: name=ebaloger state=absent
tags: ['never', 'ebaloger', 'system', 'platform', 'pservice', 'docker-container', 'full']
- docker_container: name=ebaloger state=absent
tags: ['never', 'httpdebug', 'system', 'full']