-
Notifications
You must be signed in to change notification settings - Fork 18
/
provision-infra-web.yml
1555 lines (1491 loc) · 53.4 KB
/
provision-infra-web.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
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
---
- name: 'INITIAL SETUP'
hosts: web.infra.netsoc.co
become: yes
roles:
- ansible-requirements
- utf8-locale
- docker
tasks:
- name: 'Make /netsoc only readable by root'
file:
path: '/netsoc'
owner: root
group: root
mode: '1770'
tags:
- initial
# We don't do this on the web host because ansible needs a python driver installed on a system that uses these
- name: 'WIKI (DATABASES) - Create databases for services'
hosts: databases.infra.netsoc.co
become: yes
tasks:
- name: WIKI - Ensure database
postgresql_db:
name: '{{ wikijs.postgres.db }}'
state: present
login_host: '{{ databases.infra.postgres }}'
login_password: '{{ postgres.infra.postgres_password }}'
- name: WIKI - Ensure user
postgresql_user:
name: '{{ wikijs.postgres.username }}'
password: '{{ wikijs.postgres.password }}'
login_host: '{{ databases.infra.postgres }}'
login_password: '{{ postgres.infra.postgres_password }}'
no_log: true
- name: WIKI - Ensure user has access to database
postgresql_privs:
db: '{{ wikijs.postgres.db }}'
role: '{{ wikijs.postgres.username }}'
objs: ALL_IN_SCHEMA
privs: SELECT,INSERT,UPDATE,DELETE
login_host: '{{ databases.infra.postgres }}'
login_password: '{{ postgres.infra.postgres_password }}'
vars_files:
- 'vars/network.yml'
- 'vars/secrets_mapping.yml'
- 'vars/secrets.yml'
tags:
- provision
- wiki
- name: 'TRAEFIK'
hosts: web.infra.netsoc.co
become: yes
tasks:
- name: TRAEFIK - Ensure directories exist
file:
path: '/netsoc/{{ item }}'
owner: root
group: root
mode: '0755'
state: directory
with_items:
- traefik
- traefik/file_config
- name: TRAEFIK - Ensure Docker network
become: yes
docker_network:
name: traefik
attachable: yes
- name: TRAEFIK & NETSOC CLOUD - Load Netsoc Cloud config
set_fact:
netsoc_cloud_config: "{{ lookup('file', './vars/netsoc_cloud_api_config.yml') | from_yaml }}"
- name: TRAEFIK & NETSOC CLOUD - Generate entrypoints for web + Netsoc Cloud
set_fact:
text_traefik_entrypoints: |
web:
address: ':80'
web-secure:
address: ':443'
metrics:
address: ':8082'
{% for i in range(netsoc_cloud_config.proxmox.network.port_forward.range[0],netsoc_cloud_config.proxmox.network.port_forward.range[1]+1) %}
netsoc-cloud-{{i}}-tcp:
address: ':{{i}}/tcp'
netsoc-cloud-{{i}}-udp:
address: ':{{i}}/udp'
{% endfor %}
- name: TRAEFIK - Remember static config
set_fact:
traefik_static_config:
log:
level: INFO
format: 'json'
accessLog:
format: 'json'
entrypoints: '{{ text_traefik_entrypoints | from_yaml }}'
metrics:
prometheus:
entrypoint: metrics
serversTransport:
insecureSkipVerify: true
certificatesResolvers:
letsencrypt-tls:
acme:
email: [email protected]
storage: /traefik/acme.json
tlsChallenge: {}
letsencrypt-dns:
acme:
email: [email protected]
storage: /traefik/acme-cf.json
dnsChallenge:
provider: cloudflare
delayBeforeCheck: 10
resolvers:
- '1.1.1.1:53'
- '1.0.0.1:53'
providers:
file:
directory: /traefik/file_config/
watch: true
docker:
exposedByDefault: false
http: # cloud http config
endpoint:
- 'https://api.netsoc.cloud/v1/proxmox/traefik-config?key={{ netsoc_cloud_config.proxmox.network.traefik.config_key }}'
pollInterval: 20s
pollTimeout: 10s
api:
dashboard: true
insecure: true
- name: TRAEFIK - Remember file config
set_fact:
traefik_file_config:
http:
routers:
leela-fallback:
entrypoints:
- web-secure
rule: PathPrefix(`/`) # matches everything
service: leela-https
priority: 1 # last possible match
tls:
certResolver: letsencrypt-tls
# leela-fallback-evan:
# entrypoints:
# - web-secure
# rule: Host(`iamevan.me`)
# service: leela-https
# tls:
# certResolver: letsencrypt-tls
# leela-fallback-evan2:
# entrypoints:
# - web-secure
# rule: Host(`www.iamevan.me`)
# service: leela-https
# tls:
# certResolver: letsencrypt-tls
leela-fallback-https:
entrypoints:
- web-secure
rule: >-
Host(`cardinaldesign.io`,
`colm.cf`,
`colm.design`,
`ghostking.rip`,
`ghostkingisdead.com`,
`hau.su`,
`hausurecords.com`,
`kaizokucon.ie`,
`l.hausurecords.com`,
`olwen.ie`,
`reeling.party`,
`ultimateeastcoastusatrip.ie`,
`www.cardinaldesign.io`,
`www.colm.design`,
`www.ghostking.rip`,
`www.ghostkingisdead.com`,
`www.hausurecords.com`,
`www.olwen.ie`,
`www.reeling.party`,
`www.ultimateeastcoastusatrip.ie`)
service: leela-https
tls:
certResolver: letsencrypt-tls
leela-fallback-http:
entrypoints:
- web-secure
rule: >-
Host(
`vune.ie`,
`www.vune.ie`,
`dsn.ie`,
`refund.noahsc.xyz`,
`www.silentmovies.media`,
`silentmovies.media`,
`ultimateeastcoastusatrip.ie`)
service: leela-http
tls:
certResolver: letsencrypt-tls
leela-fallback-user-sites:
entrypoints:
- web-secure
rule: HostRegexp(`{subdomain:[a-zA-Z0-9-]+}.netsoc.co`, `www.{subdomain:[a-zA-Z0-9-]+}.netsoc.co`)
service: leela-http
priority: 2
tls:
certResolver: letsencrypt-dns
domains:
- main: 'netsoc.co'
sans:
- '*.netsoc.co'
# student-media:
# entrypoints:
# - web-secure
# rule: Host(`motley.ie`,`www.motley.ie`,`www.uccexpress.ie`,`uccexpress.ie`)
# service: studentmedia-https
# tls:
# certResolver: letsencrypt-tls
control:
entrypoints:
- web-secure
rule: Host(`proxmox.netsoc.co`)
service: control-https
tls:
certResolver: letsencrypt-tls
ipa:
entrypoints:
- web-secure
rule: Host(`ipa.netsoc.co`)
middlewares:
- ipa-rewrite
service: ipa
tls:
certResolver: letsencrypt-dns
keycloak:
entrypoints:
- web-secure
rule: Host(`keycloak.netsoc.co`)
service: keycloak
tls:
certResolver: letsencrypt-dns
discord-router:
entrypoints:
- web-secure
rule: Host(`discord.netsoc.co`)
middlewares:
- discord-redirect
service: unused
tls:
certResolver: letsencrypt-dns
constitution-router:
entrypoints:
- web-secure
rule: Host(`constitution.netsoc.co`)
middlewares:
- constitution-redirect
service: unused
tls:
certResolver: letsencrypt-dns
esports-router:
entrypoints:
- web-secure
rule: Host(`esports.netsoc.co`)
middlewares:
- esports-redirect
service: unused
tls:
certResolver: letsencrypt-dns
prometheus:
entrypoints:
- web-secure
rule: Host(`prometheus.netsoc.co`)
middlewares:
- prometheus-auth
service: prometheus
tls:
certResolver: letsencrypt-dns
mentorships-router:
entrypoints:
- web-secure
rule: Host(`mentorships.netsoc.co`)
middlewares:
- mentorships-redirect
service: unused
tls:
certResolver: letsencrypt-dns
minecraft-router:
entrypoints:
- web-secure
rule: Host(`minecraft.netsoc.co`)
middlewares:
- minecraft-redirect
service: unused
tls:
certResolver: letsencrypt-dns
tutorial-router:
entrypoints:
- web-secure
rule: Host(`tutorial.netsoc.co`)
middlewares:
- tutorial-redirect
service: unused
tls:
certResolver: letsencrypt-dns
hlm-router:
entrypoints:
- web-secure
rule: Host(`hlm.netsoc.co`)
middlewares:
- hlm-redirect
service: unused
tls:
certResolver: letsencrypt-dns
middlewares:
discord-redirect:
redirectRegex:
regex: ^(.*)
replacement: 'https://discord.gg/zHkxHYjdqH'
constitution-redirect:
redirectRegex:
regex: ^(.*)
replacement: 'https://wiki.netsoc.co/en/about/constitution'
permanent: true
minecraft-redirect:
redirectRegex:
regex: ^(.*)
replacement: 'https://wiki.netsoc.co/en/services/minecraft'
permanent: true
esports-redirect:
redirectRegex:
regex: ^(.*)
replacement: 'https://discordapp.com/invite/pDUv6Uj'
mentorships-redirect:
redirectRegex:
regex: ^(.*)
replacement: 'https://wiki.netsoc.co/en/technology/mentorships'
ipa-rewrite:
headers:
customRequestHeaders:
Host: ipa.infra.netsoc.co
Referer: https://ipa.infra.netsoc.co/ipa/
hlm-redirect:
redirectRegex:
regex: ^(.*)
replacement: 'https://hlm.netsoc.cloud'
prometheus-auth:
basicAuth:
users:
- "{{ prometheus.username }}:{{ prometheus.password | password_hash('bcrypt') }}"
tutorial-redirect:
redirectRegex:
regex: ^(.*)
replacement: 'https://wiki.netsoc.co/en/services/tutorial'
permanent: true
services:
ipa:
loadBalancer:
servers:
- url: 'https://{{ databases.infra.ipa }}'
keycloak:
loadBalancer:
servers:
- url: 'https://{{ databases.infra.keycloak }}:8443'
prometheus:
loadBalancer:
servers:
- url: 'http://{{ databases.infra.prometheus }}:9090'
unused:
loadBalancer:
servers:
- url: 'https://google.com'
leela-https:
loadBalancer:
servers:
- url: 'https://10.0.30.135'
studentmedia-https:
loadBalancer:
servers:
- url: 'https://netsoc2.ucc.ie'
control-https:
loadBalancer:
servers:
- url: 'https://10.0.30.20:8006'
leela-http:
loadBalancer:
servers:
- url: 'http://10.0.30.135'
- name: TRAEFIK - Write static config
copy:
content: '{{ traefik_static_config | from_yaml }}'
dest: /netsoc/traefik/config.yml
- name: TRAEFIK - Write file config
copy:
content: '{{ traefik_file_config | from_yaml }}'
dest: /netsoc/traefik/file_config/config.yml
- name: TRAEFIK - Write Cloudflare DNS token
copy:
content: '{{ cloudflare.api.dns_api_token }}'
dest: /netsoc/traefik/cloudflare_dns_api_token.txt
- name: TRAEFIK - Remember Compose definition
set_fact:
traefik_definition:
version: '3.8'
networks:
traefik:
external: true
services:
server:
restart: always
image: traefik:v2.3.2
command: traefik --configFile=/traefik/config.yml --log.format=json
volumes:
- '/var/run/docker.sock:/var/run/docker.sock'
- '/netsoc/traefik:/traefik/:shared'
environment:
CLOUDFLARE_DNS_API_TOKEN_FILE: '/traefik/cloudflare_dns_api_token.txt'
network_mode: 'host'
labels:
# global redirect to https
traefik.enable: 'true'
traefik.docker.network: 'traefik'
traefik.http.routers.https-redirect.entrypoints: 'web'
traefik.http.routers.https-redirect.rule: 'HostRegexp(`{any:.*}`)'
traefik.http.routers.https-redirect.middlewares: 'https-redirect'
traefik.http.middlewares.https-redirect.redirectscheme.scheme: 'https'
traefik.http.middlewares.https-redirect.redirectscheme.port: '443'
traefik.http.middlewares.https-redirect.redirectscheme.permanent: 'true'
# passworded dashboard
traefik.http.routers.dashboard.entrypoints: 'web-secure'
traefik.http.routers.dashboard.rule: 'Host(`traefik.netsoc.co`)'
traefik.http.routers.dashboard.tls.certResolver: 'letsencrypt-dns'
traefik.http.routers.dashboard.service: 'dashboard-service'
traefik.http.services.dashboard-service.loadbalancer.server.port: '8080'
traefik.http.middlewares.dashboard-auth.basicauth.users: "{{ traefik.username }}:{{ traefik.password | password_hash('bcrypt') | replace('$', '$$') }}"
traefik.http.routers.dashboard.middlewares: 'dashboard-auth@docker'
logging:
options:
max-size: '500M'
max-file: '5'
- name: TRAEFIK - Setup compose
docker_compose:
project_name: traefik
pull: yes
recreate: always
restarted: yes
remove_orphans: yes
state: present
definition: '{{ traefik_definition }}'
vars_files:
- 'vars/network.yml'
- 'vars/secrets_mapping.yml'
- 'vars/secrets.yml'
tags:
- provision
- traefik
- netsoc-cloud
- name: 'STATIC WEBSITES'
hosts: web.infra.netsoc.co
become: yes
tasks:
- name: STATIC WEBSITES - Remember Compose definition
set_fact:
static_websites_definition:
version: '3.8'
networks:
traefik:
external: true
services:
netsoc.co:
image: ghcr.io/uccnetsoc/netsoc.co:latest
networks:
traefik:
labels:
traefik.enable: 'true'
traefik.http.routers.website.rule: 'Host(`netsoc.co`, `www.netsoc.co`)'
traefik.http.routers.website.entrypoints: 'web-secure'
traefik.http.routers.website.tls.certResolver: 'letsencrypt-dns'
traefik.http.services.website-service.loadbalancer.server.port: '80'
traefik.http.routers.website.service: 'website-service'
traefik.http.middlewares.rk-redirect.redirectregex.regex: '^(http|https)://netsoc.co/(r(?:[^k].*)|[^r].*)?$$'
traefik.http.middlewares.rk-redirect.redirectregex.replacement: 'https://netsoc.co/rk/$${2}'
traefik.http.middlewares.rk-redirect.redirectregex.permanent: 'true'
traefik.http.middlewares.rk-strip.stripprefix.prefixes: '/rk'
traefik.http.middlewares.www-redirect.redirectregex.regex: '^(http|https)://www.netsoc.co/(.*)'
traefik.http.middlewares.www-redirect.redirectregex.replacement: '^(http|https)://netsoc.co/$${2}'
traefik.http.middlewares.www-redirect.redirectregex.permanent: 'true'
traefik.http.routers.website.middlewares: 'rk-redirect@docker,rk-strip@docker,www-redirect@docker'
traefik.docker.network: 'traefik'
restart: always
blog:
image: ghost:5.8.3-alpine
networks:
traefik:
environment:
url: 'https://blog.netsoc.co/'
mail__transport: SMTP
mail__from: '[email protected]'
mail__options__service: Mailgun
mail__options__host: "{{ blog.smtp.hostname }}"
mail__options__port: "{{ blog.smtp.port }}"
mail__options__secureConnection: 'false'
mail__options__auth__user: "{{ blog.smtp.username }}"
mail__options__auth__pass: "{{ blog.smtp.password }}"
labels:
traefik.enable: 'true'
traefik.http.routers.blog.rule: 'Host(`blog.netsoc.co`)'
traefik.http.routers.blog.entrypoints: 'web-secure'
traefik.http.routers.blog.tls.certResolver: 'letsencrypt-dns'
traefik.http.services.blog-service.loadbalancer.server.port: '2368'
traefik.http.routers.blog.service: 'blog-service'
traefik.docker.network: 'traefik'
volumes:
- /netsoc/blog:/var/lib/ghost/content
restart: always
robots-disallow:
image: wikiwi/robots-disallow
networks:
traefik:
labels:
traefik.enable: 'true'
traefik.http.routers.proxmox.rule: 'Host(`proxmox.netsoc.co`) && Path(`/robots.txt`)'
traefik.http.routers.proxmox.entrypoints: 'web-secure'
traefik.http.routers.proxmox.tls.certResolver: 'letsencrypt-dns'
traefik.http.services.proxmox-service.loadbalancer.server.port: '8080'
traefik.http.routers.proxmox.service: 'proxmox-service'
traefik.docker.network: 'traefik'
- name: STATIC WEBSITES - Setup compose
docker_compose:
project_name: static_websites
remove_orphans: yes
pull: yes
state: present
definition: '{{ static_websites_definition }}'
vars_files:
- 'vars/network.yml'
- 'vars/secrets_mapping.yml'
- 'vars/secrets.yml'
tags:
- provision
- static-websites
- name: 'WIKI'
hosts: web.infra.netsoc.co
become: yes
tasks:
- name: WIKI - Remember Compose definition
set_fact:
wiki_definition:
version: '3.8'
networks:
traefik:
external: true
services:
instance:
image: requarks/wiki:2.5
environment:
# like this for future use
DB_TYPE: 'postgres'
DB_HOST: "{{ interfaces.infra.databases.net0.addresses[0] | ipaddr('address') }}"
DB_PORT: '{{ wikijs.postgres.port | default(5432) }}'
DB_USER: '{{ wikijs.postgres.username }}'
DB_PASS: '{{ wikijs.postgres.password }}'
DB_NAME: '{{ wikijs.postgres.db }}'
networks:
traefik:
labels:
traefik.enable: 'true'
traefik.http.routers.wiki.rule: 'Host(`wiki.netsoc.co`)'
traefik.http.routers.wiki.entrypoints: 'web-secure'
traefik.http.routers.wiki.tls.certResolver: 'letsencrypt-dns'
traefik.http.services.wiki.loadbalancer.server.port: '3000'
traefik.http.routers.wiki.service: 'wiki'
traefik.docker.network: 'traefik'
restart: always
- name: WIKI - Setup compose
docker_compose:
project_name: wiki
recreate: smart
restarted: yes
remove_orphans: yes
state: present
definition: '{{ wiki_definition }}'
vars_files:
- 'vars/network.yml'
- 'vars/secrets_mapping.yml'
- 'vars/secrets.yml'
tags:
- provision
- wiki
- name: 'DISCORD BOT (DATABASES) - Create databases for services'
hosts: databases.infra.netsoc.co
become: yes
tasks:
- name: DISCORD BOT - Ensure MySQL Database
run_once: true
postgresql_db:
name: '{{ netsocbot.sql_database }}'
login_host: '{{ databases.infra.postgres }}'
login_password: '{{ postgres.infra.postgres_password }}'
state: present
- name: DISCORD BOT - Ensure Bot MySQL User
run_once: true
postgresql_user:
name: '{{ netsocbot.sql_user }}'
password: '{{ netsocbot.sql_password }}'
login_host: '{{ databases.infra.postgres }}'
login_password: '{{ postgres.infra.postgres_password }}'
state: present
no_log: true
vars_files:
- 'vars/network.yml'
- 'vars/secrets_mapping.yml'
- 'vars/secrets.yml'
tags:
- provision
- discord-bot
- name: 'PLAUSIBLE - Databases'
hosts: databases.infra.netsoc.co
become: yes
tasks:
- name: PLAUSIBLE - Ensure database
postgresql_db:
name: '{{ plausible.postgres.db }}'
state: present
login_host: '{{ databases.infra.postgres }}'
login_password: '{{ postgres.infra.postgres_password }}'
- name: PLAUSIBLE - Ensure user
postgresql_user:
name: '{{ plausible.postgres.user }}'
password: '{{ plausible.postgres.pass }}'
login_host: '{{ databases.infra.postgres }}'
login_password: '{{ postgres.infra.postgres_password }}'
no_log: true
- name: PLAUSIBLE - Ensure user has access to database
postgresql_privs:
db: '{{ plausible.postgres.db }}'
role: '{{ plausible.postgres.user }}'
objs: ALL_IN_SCHEMA
privs: SELECT,INSERT,UPDATE,DELETE
login_host: '{{ databases.infra.postgres }}'
login_password: '{{ postgres.infra.postgres_password }}'
- name: PLAUSIBLE - Ensure user has CREATE access
postgresql_privs:
db: '{{ plausible.postgres.db }}'
role: '{{ plausible.postgres.user }}'
privs: CREATE
type: database
login_host: '{{ databases.infra.postgres }}'
login_password: '{{ postgres.infra.postgres_password }}'
vars_files:
- 'vars/network.yml'
- 'vars/secrets_mapping.yml'
- 'vars/secrets.yml'
tags:
- provision
- plausible
- name: 'PLAUSIBLE'
hosts: web.infra.netsoc.co
become: yes
tasks:
- name: PLAUSIBLE - Ensure directories exist
file:
path: '/netsoc/{{ item }}'
owner: root
group: root
mode: '0755'
state: directory
with_items:
- plausible
- name: PLAUSIBLE - Ensure Plausible config file
copy:
dest: /netsoc/plausible/clickhouse-config.xml
mode: 0777
content: |
<yandex>
<logger>
<level>warning</level>
<console>true</console>
</logger>
<!-- Stop all the unnecessary logging -->
<query_thread_log remove="remove"/>
<query_log remove="remove"/>
<text_log remove="remove"/>
<trace_log remove="remove"/>
<metric_log remove="remove"/>
<asynchronous_metric_log remove="remove"/>
</yandex>
- name: PLAUSIBLE - Ensure Plausible User config file
copy:
dest: /netsoc/plausible/clickhouse-user-config.xml
mode: 0777
content: |
<yandex>
<profiles>
<default>
<log_queries>0</log_queries>
<log_query_threads>0</log_query_threads>
</default>
</profiles>
</yandex>
- name: PLAUSIBLE - Remember Compose definition
set_fact:
plausible_definition:
version: '3.8'
networks:
traefik:
external: true
services:
instance:
image: plausible/analytics
restart: always
command: sh -c "sleep 10 && /entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh db init-admin && /entrypoint.sh run"
environment:
ADMIN_USER_NAME: root
ADMIN_USER_EMAIL: [email protected]
ADMIN_USER_PWD: '{{ plausible.password }}'
DATABASE_URL: 'postgress://{{ plausible.postgres.user }}:{{ plausible.postgres.pass }}@{{ databases.infra.postgres }}/{{ plausible.postgres.db }}'
CLICKHOUSE_DATABASE_URL: 'http://plausible_plausible_events_db_1:8123/plausible_events_db'
SECRET_KEY_BASE: '{{ plausible.key_base }}'
BASE_URL: 'https://analytics.netsoc.co'
labels:
traefik.enable: 'true'
traefik.http.routers.plausible.rule: 'Host(`analytics.netsoc.co`)'
traefik.http.routers.plausible.entrypoints: 'web-secure'
traefik.http.routers.plausible.tls.certResolver: 'letsencrypt-dns'
traefik.http.services.plausible-service.loadbalancer.server.port: '8000'
traefik.http.routers.plausible.service: 'plausible-service'
traefik.docker.network: 'traefik'
depends_on:
- plausible_events_db
plausible_events_db:
image: yandex/clickhouse-server:21.3.2.5
restart: always
volumes:
- event-data:/var/lib/clickhouse
- /netsoc/plausible/clickhouse-config.xml:/etc/clickhouse-server/config.d/logging.xml:ro
- /netsoc/plausible/clickhouse-user-config.xml:/etc/clickhouse-server/users.d/logging.xml:ro
ulimits:
nofile:
soft: 262144
hard: 262144
volumes:
event-data:
driver: local
- name: PLAUSIBLE - Setup compose
docker_compose:
project_name: plausible
recreate: smart
restarted: yes
remove_orphans: yes
state: present
definition: '{{ plausible_definition }}'
vars_files:
- 'vars/network.yml'
- 'vars/secrets_mapping.yml'
- 'vars/secrets.yml'
tags:
- provision
- plausible
- name: 'DISCORD BOT'
hosts: web.infra.netsoc.co
become: yes
tasks:
- name: DISCORD BOT - Remember Compose definition
set_fact:
discord_bot_definition:
version: '3.8'
networks:
traefik:
external: true
services:
instance:
image: ghcr.io/uccnetsoc/discord-bot:latest
restart: always
networks:
traefik:
environment:
DISCORD_TOKEN: '{{ netsocbot.discord_token }}'
DISCORD_ROLES: '631196785913888768,855884858794442783'
DISCORD_PUBLIC_SERVER: '248421213628530688'
DISCORD_PUBLIC_CHANNEL: '494539080885993472'
DISCORD_PUBLIC_GENERAL: '248421213628530688'
DISCORD_PUBLIC_CORONA: '691756092379627621'
DISCORD_PUBLIC_WELCOME: 'Welcome to the UCC Netsoc Discord server %s!,Hey %s! Welcome to the Netsoc Discord Server!,Welcome %s!'
DISCORD_COMMITTEE_SERVER: '824315212768346152'
DISCORD_COMMITTEE_CHANNEL: '847973898900471859'
BOT_PREFIX: '!'
SENDGRID_TOKEN: '{{ sendgrid.apikey }}'
TWITTER_KEY: '{{ netsocbot.twitter_key }}'
TWITTER_SECRET: '{{ netsocbot.twitter_secret }}'
TWITTER_ACCESS_KEY: '{{ netsocbot.twitter_access_key }}'
TWITTER_ACCESS_SECRET: '{{ netsocbot.twitter_access_secret }}'
SQL_HOST: '{{ databases.infra.postgres }}'
SQL_PORT: 5432
SQL_USERNAME: '{{ netsocbot.sql_user }}'
SQL_PASSWORD: '{{ netsocbot.sql_password }}'
FREEIMAGE_KEY: '{{ netsocbot.freeimage_key }}'
FACEBOOK_APPID: '{{ netsocbot.fb.appid }}'
FACEBOOK_APP_SECRET: '{{ netsocbot.fb.appsecret }}'
FACEBOOK_PAGEID: '{{ netsocbot.fb.pageid }}'
FACEBOOK_PAGE_ACCESS_TOKEN: '{{ netsocbot.fb.accesstoken }}'
SCHEDULE_ENABLE: 'False'
MINECRAFT_HOST: "{{ interfaces.infra.minecraft.net0.addresses[0] | ipaddr('address') }}:1194"
SHORTEN_HOST: 'http://shortener_instance_1:8080/api'
SHORTEN_PUBLIC_HOST: 'https://netsoc.co/go'
SHORTEN_USERNAME: '{{ shortener.username }}'
SHORTEN_PASSWORD: '{{ shortener.password }}'
GOOGLE_CALENDAR_PUBLIC_ICS: 'https://calendar.google.com/calendar/ical/c_1rid5k8ahaiosmdhn8pkahf2og%40group.calendar.google.com/public/basic.ics'
GOOGLE_CALENDAR_COMMITTEE_ICS: '{{ netsocbot.google_calendar_committee_ics }}'
GOOGLE_CALENDAR_IMAGE_DEFAULT: 'https://raw.githubusercontent.com/UCCNetsoc/wiki/master/assets/logo-hires.png'
labels:
traefik.enable: 'true'
traefik.http.routers.netsocbot.rule: 'Host(`bot.netsoc.co`)'
traefik.http.routers.netsocbot.entrypoints: 'web-secure'
traefik.http.routers.netsocbot.tls.certResolver: 'letsencrypt-dns'
traefik.http.services.netsocbot-service.loadbalancer.server.port: '80'
traefik.http.routers.netsocbot.service: 'netsocbot-service'
traefik.docker.network: 'traefik'
- name: DISCORD BOT - Setup compose
docker_compose:
project_name: discord_bot
remove_orphans: yes
recreate: always
pull: yes
state: present
definition: '{{ discord_bot_definition }}'
vars_files:
- 'vars/network.yml'
- 'vars/secrets_mapping.yml'
- 'vars/secrets.yml'
tags:
- provision
- discord-bot
- name: 'whodis'
hosts: web.infra.netsoc.co
become: yes
tasks:
- name: whodis - Remember Compose definition
set_fact:
whodis_definition:
version: '3.8'
networks:
traefik:
external: true
services:
instance:
image: ghcr.io/uccnetsoc/whodis:latest
restart: always
networks:
traefik:
environment:
DISCORD_TOKEN: '{{ whodis.discord_token }}'
DISCORD_APP_ID: '{{ whodis.discord_app_id }}'
DISCORD_BOT_INVITE: '{{ whodis.discord_bot_invite }}'
DISCORD_GUILD_MEMBERS_WELCOME: '{"248421213628530688": "Some channels are hidden by default so head over to <#769360801332461569> to get access to them."}'
API_URL: 'https://whodis.netsoc.co'
API_PORT: '8080'
API_SECRET: '{{ whodis.api_secret }}'
OAUTH_GOOGLE_ID: '{{ whodis.oauth_google_id }}'
OAUTH_GOOGLE_SECRET: '{{ whodis.oauth_google_secret }}'
labels:
traefik.enable: 'true'
traefik.http.routers.whodis.rule: 'Host(`whodis.netsoc.co`)'
traefik.http.routers.whodis.entrypoints: 'web-secure'
traefik.http.routers.whodis.tls.certResolver: 'letsencrypt-dns'
traefik.http.routers.whodis.service: 'whodis-service'
traefik.http.services.whodis-service.loadbalancer.server.port: '8080'
traefik.docker.network: 'traefik'
- name: whodis - Setup compose
docker_compose:
project_name: whodis
remove_orphans: yes
recreate: always
pull: yes
state: present
definition: '{{ whodis_definition }}'
vars_files:
- 'vars/network.yml'
- 'vars/secrets_mapping.yml'
- 'vars/secrets.yml'
tags:
- provision
- whodis
- name: 'NETSOC CLOUD'
hosts: web.infra.netsoc.co
become: yes
tasks:
- name: NETSOC CLOUD - Ensure directories exist
file:
path: '/netsoc/{{ item }}'
owner: root
group: root
mode: '0755'
state: directory
with_items:
- cloud
- name: NETSOC CLOUD - Ensure config file
copy:
src: './vars/netsoc_cloud_api_config.yml'
dest: /netsoc/cloud/config.yaml
owner: root
group: root
mode: 0770
- name: NETSOC CLOUD - Remember Compose definition
set_fact:
netsoc_cloud_definition:
version: '3.8'
networks:
traefik:
external: true
services:
api:
image: ghcr.io/uccnetsoc/cloud-api:latest
entrypoint: /start.sh
restart: always
networks:
traefik:
volumes:
- '/netsoc/cloud/config.yaml:/config.yml'
environment:
WORKERS_PER_CORE: 4
labels:
traefik.enable: 'true'
traefik.http.routers.netsoc-cloud-api.entrypoints: web-secure
traefik.http.routers.netsoc-cloud-api.rule: Host(`api.netsoc.cloud`)
traefik.http.routers.netsoc-cloud-api.tls.certResolver: letsencrypt-dns
traefik.http.routers.netsoc-cloud-api.service: netsoc-cloud-api
traefik.http.services.netsoc-cloud-api.loadbalancer.server.port: '80'
traefik.docker.network: traefik
ui:
image: ghcr.io/uccnetsoc/cloud-ui:latest
restart: always
networks:
traefik:
labels:
traefik.enable: 'true'
traefik.http.routers.netsoc-cloud-ui.entrypoints: web-secure
traefik.http.routers.netsoc-cloud-ui.rule: Host(`netsoc.cloud`)
traefik.http.routers.netsoc-cloud-ui.tls.certResolver: letsencrypt-dns
traefik.http.routers.netsoc-cloud-ui.tls.domains[0].main: 'netsoc.cloud'
traefik.http.routers.netsoc-cloud-ui.tls.domains[0].sans: '*.netsoc.cloud'
traefik.http.routers.netsoc-cloud-ui.service: netsoc-cloud-ui
traefik.http.services.netsoc-cloud-ui.loadbalancer.server.port: '80'
traefik.docker.network: traefik
- name: NETSOC CLOUD - Setup compose
docker_compose:
project_name: netsoc_cloud
recreate: always
restarted: yes
pull: yes
remove_orphans: yes
state: present
definition: '{{ netsoc_cloud_definition }}'
vars_files:
- 'vars/network.yml'
- 'vars/secrets_mapping.yml'
- 'vars/secrets.yml'
tags:
- provision
- netsoc-cloud
- netsoc-cloud-api
- netsoc-cloud-ui
- name: NETSOC CLOUD - WEBSSH2
hosts: web.infra.netsoc.co
become: yes