-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdeploy.yml
1072 lines (987 loc) · 46.9 KB
/
deploy.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
---
# Ansible playbook that deploys NAU.
#
#
# Open edX instance with 3 layers:
# - Load balancer servers
# - Persistence servers (mongo_servers, cache_servers and mysql_servers)
# - Application servers (app_servers & complementary_servers)
#
# NAU also has other services like:
# - richie for marketing site
# - static proxy service
# - fam servers that print course certificate to PDF
#
# Examples:
# To deploy the application servers and deploy 2 servers at once run:
# ansible-playbook -i nau-data/envs/<env>/hosts.ini deploy.yml --limit app_servers -e serial_number=2
#
# To deploy the application servers and migrate the database changes
# ansible-playbook -i nau-data/envs/<env>/hosts.ini deploy.yml --limit app_servers -e "migrate_db=yes"
#
# To deploy the application servers with a specific themes version
# ansible-playbook -i nau-data/envs/<env>/hosts.ini deploy.yml --limit app_servers -e "THEMES_VERSION=master"
#
# To deploy the complementary servers and its services run:
# ansible-playbook -i nau-data/envs/<env>/hosts.ini deploy.yml --limit complementary_servers
#
# To deploy the load balancers run:
# ansible-playbook -i nau-data/envs/<env>/hosts.ini deploy.yml --limit balancer_servers
#
# To deploy IdP proxy servers run:
# ansible-playbook -i nau-data/envs/<env>/hosts.ini deploy.yml --limit idpproxy_servers
#
# To mark a server for maintenance, like load balancer or mysql server, append to the shell command arguments:
# ansible-playbook -i nau-data/envs/<env>/hosts.ini deploy.yml --tags keepalived --limit slave_persistence_servers -e keepalived_priority=1
# To mark a server back to normal state, run the same command without the --limit.
#
# To deploy the docker registry mirror
# ansible-playbook -i nau-data/envs/<env>/hosts.ini deploy.yml --limit registry_mirror_server -e registrymirror_deploy=true
#
# To deploy Mongo DB
# ansible-playbook -i nau-data/envs/<env>/hosts.ini deploy.yml --limit mongo_docker_servers -e mongo_deploy=true
#
# To deploy Redis cache
# ansible-playbook -i nau-data/envs/<env>/hosts.ini deploy.yml --limit redis_docker_servers -e redis_deploy=true
#
# To deploy ElasticSearch cluster
# ansible-playbook -i nau-data/envs/<env>/hosts.ini deploy.yml --limit elasticsearch_docker_servers -e elasticsearch_deploy=true
#
# To deploy Richie MySQL
# ansible-playbook -i nau-data/envs/<env>/hosts.ini deploy.yml --limit richie_mysql_docker_servers -e richie_mysql_deploy=true
#
# To deploy Richie Application
# ansible-playbook -i nau-data/envs/<env>/hosts.ini deploy.yml --limit richie_docker_servers -e richie_docker_deploy=true
#
# To deploy Course Certificate
# ansible-playbook -i nau-data/envs/<env>/hosts.ini deploy.yml --limit coursecertificate_docker_servers -e coursecertificate_docker_deploy=true
#
# To deploy StaticProxy
# ansible-playbook -i nau-data/envs/<env>/hosts.ini deploy.yml --limit staticproxy_docker_servers -e staticproxy_docker_deploy=true
#
# To deploy Observability
# ansible-playbook -i nau-data/envs/<env>/hosts.ini deploy.yml --limit observability_docker_servers -e observability_docker_deploy=true
#
# To deploy Openedx MySQL Database
# ansible-playbook -i nau-data/envs/<env>/hosts.ini deploy.yml --limit openedx_mysql_docker_servers -e openedx_mysql_deploy=true
#
# To deploy Openedx Application and build nginx
# ansible-playbook -i nau-data/envs/<env>/hosts.ini deploy.yml --limit openedx_docker_servers -e openedx_docker_deploy=true -e openedx_nginx_build=true
#
# To update OpenedX app site configuration
# ansible-playbook -i nau-data/envs/<env>/hosts.ini deploy.yml --limit openedx_docker_servers -e openedx_app_site_configuration_deploy=true --tags openedx_app_site_configuration
#
# To deploy Financial Manager MySQL database
# ansible-playbook -i nau-data/envs/<env>/hosts.ini deploy.yml --limit financial_manager_mysql_docker_servers -e financial_manager_mysql_deploy=true
#
# To deploy Financial Manager application
# ansible-playbook -i nau-data/envs/<env>/hosts.ini deploy.yml --limit financial_manager_docker_servers -e financial_manager_deploy=true
#
# To deploy Percona XtraDB databases
# ansible-playbook -i nau-data/envs/<env>/hosts.ini deploy.yml --limit xtradb_servers -e xtradb_deploy=true
#
# To deploy ClickHouse databases
# ansible-playbook -i nau-data/envs/<env>/hosts.ini deploy.yml --limit clickhouse_servers -e clickhouse_deploy=true
#
# - name: Bootstrap instances of 16.04
# hosts: all,!idpproxy_servers,!support_server,!build_server
# gather_facts: no
# become: true
# tasks:
# - import_role:
# name: python_minimal
# when: ansible_python_interpreter is not defined
- name: Infrastructure configuration
hosts: all
become: True
gather_facts: True
tasks:
- import_role:
name: users
when: ansible_distribution == 'Ubuntu'
- import_role:
name: ssh_authorized_keys
- name: On Ubuntu 20.04 or later, you need to install the acl package to becoming non privileged user.
# Fix of this error:
# Failed to set permissions on the temporary files Ansible needs to create when becoming an unprivileged user
# (rc: 1, err: chown: changing ownership of Operation not permitted
# https://github.com/georchestra/ansible/issues/55
package:
name: acl
# need this package so pakiti is installed correctly on NAU
tags: pakiti
when: ansible_distribution == 'Ubuntu' and (ansible_distribution_major_version|int) >= 20
- import_role:
name: ansible_pakiti_client
# - name: Install pip
# import_role:
# name: geerlingguy.pip
# when: ansible_distribution == 'Ubuntu' and (ansible_distribution_major_version|int) >= 20
- name: Configure sysconfig custom values
sysctl:
name: "{{ sysconfig_config.name }}"
value: "{{ sysconfig_config.value }}"
state: "{{ sysconfig_config.state | default(omit) }}"
reload: "{{ sysconfig_config.reload | default(omit) }}"
sysctl_set: "{{ sysconfig_config.sysctl_set | default(omit) }}"
loop: "{{ sysconfig_configuration | default({}) }}"
loop_control:
loop_var: sysconfig_config
label: "{{ sysconfig_config.name }}"
tags: sysctl
- name: Bootstrap cnc with Ubuntu 20.04
hosts: command_and_control_2004
become: True
gather_facts: True
tasks:
# to run openedx-lms-db-export.yml playbook that runs a script on the a docker container
- name: Install docker
import_role:
name: geerlingguy.docker
when: ansible_distribution == 'Ubuntu' and (ansible_distribution_major_version|int) >= 20
- name: Configure hosts file
hosts: all,!support_server,!command_and_control,!build_server
become: True
gather_facts: True
# vars defined on 02_hosts.yml
roles:
- bertvv.hosts
tags: hosts
- name: Configure load balancer docker
# Deploy before on backup balancer, so if there is an error during the ansible deployment the primary continue to serve
hosts: balancer_servers
serial: "{{ serial_number | default(1) }}"
become: True
gather_facts: True
roles:
- role: keepalived
vars:
keepalived_priority_override: 1 # Lower priority so the VIPs can swap to other machine.
when: balancer_keepalived_vrrp_instances is defined
- role: geerlingguy.docker
- role: ansible-firewall
- role: ansible-docker-deploy
- role: haproxy-netsnmp-perl
- role: snmpd
- role: nau_check_urls
- role: keepalived
vars:
keepalived_priority_override: ""
when: balancer_keepalived_vrrp_instances is defined
tags: load-balancer
- name: Configure mongo server instance
hosts: mongo_servers
become: True
gather_facts: True
roles:
- role: swapfile
- role: data_dirs
- role: mongo_3_2
- role: oraclejdk
- role: es_kopf
- name: Configure the complementary server group
hosts: complementary_servers
serial: "{{ serial_number | default(1) }}"
become: True
gather_facts: True
roles:
- role: rolling_deploy
vars:
rolling_deploy_starting: true
when: ( groups['complementary_servers'] | length ) > 1
- role: remove_edx_apt_ppa_repo
- role: swapfile
- role: nginx
nginx_sites:
- insights
- edx_notes_api
- nau_nginx_status
- role: nginx_default_static_site
when: use_nginx_default_site
- role: discovery
when: COMMON_COMPLEMENTARY_APPLICATION_ROLES is defined and 'discovery' in COMMON_COMPLEMENTARY_APPLICATION_ROLES
- role: ecommerce
when: COMMON_COMPLEMENTARY_APPLICATION_ROLES is defined and 'ecommerce' in COMMON_COMPLEMENTARY_APPLICATION_ROLES
- role: ecomworker
when: COMMON_COMPLEMENTARY_APPLICATION_ROLES is defined and 'ecommerce' in COMMON_COMPLEMENTARY_APPLICATION_ROLES
- role: edx_notes_api
when: COMMON_COMPLEMENTARY_APPLICATION_ROLES is defined and 'edx_notes_api' in COMMON_COMPLEMENTARY_APPLICATION_ROLES
- role: analytics_api
when: COMMON_COMPLEMENTARY_APPLICATION_ROLES is defined and 'analytics_api' in COMMON_COMPLEMENTARY_APPLICATION_ROLES
- role: insights
when: COMMON_COMPLEMENTARY_APPLICATION_ROLES is defined and 'insights' in COMMON_COMPLEMENTARY_APPLICATION_ROLES
- role: mfe_deployer
when: COMMON_COMPLEMENTARY_APPLICATION_ROLES is defined and 'mfe' in COMMON_COMPLEMENTARY_APPLICATION_ROLES
- role: web_server_monitoring
- role: snmpd
- role: nau_check_urls
- role: rolling_deploy
vars:
rolling_deploy_starting: false
when: ( groups['complementary_servers'] | length ) > 1
- name: Configure pipeline servers
hosts: pipeline_servers
become: True
gather_facts: True
vars:
ANALYTICS_API_SERVICE_CONFIG: "When defined, we create the analytics-api users at the db"
roles:
- role: remove_edx_apt_ppa_repo
- role: swapfile
- role: edxlocal
# Sometimes we need to comment the next line to run the configuration,
# because the ensure everything is up and running is broken.
- analytics_pipeline
- analytics_pipeline_configuration
# specific variables are configured on nau-data/envs/<env>/group_vars/idpproxy_servers.yml
- name: Configure Shibboleth IdP
hosts:
- idpproxy_servers
become: True
gather_facts: True
tags:
- idp
roles:
- role: server_files
vars:
server_files: "{{ server_files_before }}"
- shibboleth-3-4-4-centos7-lite/roles/check-system
# - shibboleth-3-4-4-centos7-lite/roles/system
- shibboleth-3-4-4-centos7-lite/roles/httpd
- shibboleth-3-4-4-centos7-lite/roles/tomcat
- shibboleth-3-4-4-centos7-lite/roles/postgresql
- shibboleth-3-4-4-centos7-lite/roles/shibboleth
- shibboleth-3-4-4-centos7-lite/roles/shibboleth_files
- role: shibboleth-3-4-4-centos7-lite/roles/cc-cmd
when: install_cc_cmd is not defined or install_cc_cmd
- shibboleth-3-4-4-centos7-lite/roles/performance
- role: server_files
vars:
server_files: "{{ server_files_after }}"
- name: Configure support server
hosts: support_server
become: True
gather_facts: True
roles:
- role: geerlingguy.docker
- role: openark_orchestrator
- name: Configure build server
hosts: build_server
tasks:
- name: Install docker
import_role:
name: geerlingguy.docker
- name: Install Java to run a Jenkins node
import_role:
name: geerlingguy.java
- name: Install pip to build python based software
import_role:
name: geerlingguy.pip
- name: Install virtualenv pip package to build python based software
pip:
name: virtualenv
- name: Install python3.8-venv package to build python based software
package:
name: python3.8-venv
- name: Allow ubuntu user to run docker builds
user:
name: ubuntu
groups: docker
append: yes
- name: Install docker_image ansible module dependencies
pip:
name: docker-py
- name: Configure docker registry mirror
hosts: registry_mirror_server
become: True
gather_facts: True
vars:
_registry_mirror_deploy : "{{ registrymirror_deploy | default(false) | bool }}"
tasks:
- name: Deploy registry mirror
import_role:
name: registry_mirror_deploy
when: _registry_mirror_deploy
- name: Deploy Mongo servers
hosts: mongo_docker_servers
serial: "{{ serial_number | default(1) }}" # deploy in sequence
become: True
gather_facts: True
tasks:
- name: Install or upgrade docker daemon
import_role:
name: geerlingguy.docker
when: mongo_deploy | default(false) | bool
- import_role:
name: snmpd
when: mongo_deploy | default(false) | bool
- import_role:
name: snmpd_docker
when: mongo_deploy | default(false) | bool
- name: Deploy mongo
import_role:
name: mongo_docker_deploy
vars:
# mongo_docker_instance_name
mongo_docker_initdb_root_username: "{{ MONGO_ADMIN_USER | default('admin') if (mongo_docker_init | default(false) | bool) else None }}"
mongo_docker_initdb_root_password: "{{ MONGO_ADMIN_PASSWORD if (mongo_docker_init | default(false) | bool) else None }}"
mongo_docker_replSet: "{{ MONGO_REPL_SET }}"
mongo_docker_keyFile_value: "{{ MONGO_CLUSTER_KEY | default('') }}"
mongo_docker_command_bind_ip_additional_list:
- "{{ ansible_additional_ipv4 | default('') }}"
when: mongo_deploy | default(false) | bool
- name: Set Mongo Feature compatibility
hosts: mongo_docker_servers
serial: "{{ serial_number | default(1) }}" # deploy in sequence
become: True
gather_facts: True
tasks:
- name: Get Primary MongoDB Node
shell: |
make --no-print-directory --directory {{ mongo_docker_deploy_base_folder }} mongo-primary-node
register: get_primary_mongodb_node_output
when: mongo_feature_compatibility_version | default(False)
- name: Set Mongo Feature compatibility
shell: |
docker exec {{ mongo_docker_container_name }} {{ mongo_shell_command }} --username {{ mongo_docker_admin_username }} --password {{ mongo_docker_admin_password }} --eval "db.adminCommand( { setFeatureCompatibilityVersion: '{{ mongo_feature_compatibility_version }}'{% if mongo_feature_compatibility_confirm | default(False) %}, confirm: true{% endif %} } )"
delegate_to: "{{ get_primary_mongodb_node_output.stdout }}"
run_once: true
when: mongo_feature_compatibility_version | default(False)
- name: Get Mongo Feature compatibility
shell: |
docker exec {{ mongo_docker_container_name }} {{ mongo_shell_command }} --username {{ mongo_docker_admin_username }} --password {{ mongo_docker_admin_password }} --eval "JSON.stringify(db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } ))" | tail -n1 | jq -r '.featureCompatibilityVersion.version'
register: get_mongo_feature_compatibility_version_output
delegate_to: "{{ get_primary_mongodb_node_output.stdout }}"
run_once: true
when: mongo_feature_compatibility_version | default(False)
- name: Check Mongo Feature compatibility
fail:
msg: Incorrect Mongo feature compatibility version, current '{{ get_mongo_feature_compatibility_version_output.stdout }}' expected '{{ mongo_feature_compatibility_version }}'
delegate_to: "{{ get_primary_mongodb_node_output.stdout }}"
run_once: true
when: mongo_feature_compatibility_version | default(False) and get_mongo_feature_compatibility_version_output.stdout != mongo_feature_compatibility_version
- import_tasks: tasks/healthcheck.yml
when: mongo_feature_compatibility_version | default(False)
- name: Deploy Elasticsearch servers
hosts: elasticsearch_docker_servers
serial: "{{ serial_number | default(1) }}" # deploy in sequence
become: True
gather_facts: True
tasks:
- name: Install or upgrade docker daemon
import_role:
name: geerlingguy.docker
when: elasticsearch_deploy | default(false) | bool
- import_role:
name: snmpd
when: elasticsearch_deploy | default(false) | bool
- import_role:
name: snmpd_docker
when: elasticsearch_deploy | default(false) | bool
- name: Deploy elasticsearch
import_role:
name: elasticsearch_docker_deploy
vars:
elasticsearch_network_hosts_additional_list:
- "{{ ansible_additional_ipv4 | default('') }}"
when: elasticsearch_deploy | default(false) | bool
- name: Deploy cache redis docker servers
hosts: redis_docker_servers
serial: "{{ serial_number | default(1) }}" # deploy in sequence
become: True
gather_facts: True
tasks:
- name: Lower keepalived priority to force VIP swap
import_role:
name: keepalived
vars:
keepalived_priority_override: 1 # Lower priority so the VIPs can swap to other machine.
tags: keepalived
when: ( redis_deploy | default(false) | bool ) and redis_keepalived_vrrp_instances is defined and ( groups['redis_docker_servers'] | length ) > 1
- name: Install or upgrade docker daemon
import_role:
name: geerlingguy.docker
when: redis_deploy | default(false) | bool
- import_role:
name: snmpd
tags: snmpd
when: redis_deploy | default(false) | bool
- import_role:
name: snmpd_docker
tags: snmpd
when: redis_deploy | default(false) | bool
- name: Deploy cache redis
import_role:
name: redis_docker_deploy
when: redis_deploy | default(false) | bool
- name: Restore keepalived priority
import_role:
name: keepalived
vars:
keepalived_priority_override: ""
tags: keepalived
when: ( redis_deploy | default(false) | bool ) and redis_keepalived_vrrp_instances is defined and ( groups['redis_docker_servers'] | length ) > 1
- name: Deploy richie mysql docker servers
hosts: richie_mysql_docker_servers
serial: "{{ serial_number | default(1) }}" # deploy in sequence
become: True
gather_facts: True
tasks:
- name: Lower keepalived priority to force VIP swap
import_role:
name: keepalived
vars:
keepalived_priority_override: 1 # Lower priority so the VIPs can swap to other machine.
tags: keepalived
when: ( richie_mysql_deploy | default(false) | bool ) and richie_mysql_keepalived_vrrp_instances is defined and ( groups['richie_mysql_docker_servers'] | length ) > 1
- name: Install or upgrade docker daemon
import_role:
name: geerlingguy.docker
when: richie_mysql_deploy | default(false) | bool
- import_role:
name: snmpd
tags: snmpd
when: richie_mysql_deploy | default(false) | bool
- import_role:
name: snmpd_docker
tags: snmpd
when: richie_mysql_deploy | default(false) | bool
- name: Deploy richie mysql
import_role:
name: mysql_docker_deploy
vars:
# Richie shared variables to all environments
richie_nau_MYSQL_DATABASE: richie_nau
richie_nau_MYSQL_USER: richie_nau
richie_mysql_replication_user: richie_replication
# To fix Richie MySQL authentication
# use legacy authentication plugin to fix:
# django.db.utils.OperationalError: (2059, "Authentication plugin 'caching_sha2_password'
# cannot be loaded: /usr/lib/x86_64-linux-gnu/mariadb18/plugin/caching_sha2_password.so:
# cannot open shared object file: No such file or directory
mysql_docker_command_extra: --default-authentication-plugin=mysql_native_password
# Base configuration for the MySQL instance
mysql_docker_image: docker.io/mysql:8.0.29
mysql_docker_replication: true
mysql_docker_hostname: "{{ richie_mysql_docker_hostname }}"
mysql_docker_port: "{{ richie_mysql_docker_port }}"
mysql_docker_instance_name: richie_mysql
mysql_docker_primary: "{{ richie_mysql_docker_primary }}"
mysql_root_password: "{{ richie_MYSQL_ROOT_PASSWORD }}"
mysql_server_id: "{{ groups.richie_mysql_docker_servers.index(inventory_hostname) +1 }}"
mysql_health_check_user: "{{ richie_mysql_health_check_user }}"
mysql_health_check_pass: "{{ richie_mysql_health_check_pass | default('') }}"
# Advanced configuration that assumes that the first server is the primary replica.
mysql_replication_login_password: "{{ richie_MYSQL_ROOT_PASSWORD }}"
mysql_replication_master_server_ip: "{{ hostvars[groups.richie_mysql_docker_servers[0]].ansible_host }}"
mysql_replication_master_port: "{{ hostvars[groups.richie_mysql_docker_servers[0]].richie_mysql_docker_port }}"
mysql_replication_user: "{{ richie_mysql_replication_user }}"
mysql_replication_password: "{{ richie_mysql_replication_password }}"
mysql_replication_init_databases: [ "{{ richie_nau_MYSQL_DATABASE }}" ]
mysql_replication_additional_databases:
- "{{ richie_nau_MYSQL_DATABASE | default(None) }}"
mysql_replication_additional_users:
# one per site
- {
db: "{{ richie_nau_MYSQL_DATABASE | default(None) }}",
user: "{{ richie_nau_MYSQL_USER | default(None) }}",
pass: "{{ richie_nau_app_richie_MYSQL_PASSWORD | default(None) }}",
host: "%"
}
- {
db: "*",
user: "{{ openark_orchestrator_client_user | default(None) }}",
pass: "{{ openark_orchestrator_client_password | default(None) }}",
host: "{{ openark_orchestrator_client_mysql_host }}",
# ndbinfo.processes:SELECT
priv: "*.*:SUPER,PROCESS,REPLICATION SLAVE,REPLICATION CLIENT,RELOAD/meta.*:SELECT/performance_schema.replication_group_members:SELECT"
}
- {
db: "*",
user: "{{ richie_mysql_health_check_user }}",
host: "{{ richie_mysql_health_check_host | default('%') }}",
}
when: richie_mysql_deploy | default(false) | bool
- name: Restore keepalived priority
import_role:
name: keepalived
vars:
keepalived_priority_override: ""
tags: keepalived
when: ( richie_mysql_deploy | default(false) | bool ) and richie_mysql_keepalived_vrrp_instances is defined and ( groups['richie_mysql_docker_servers'] | length ) > 1
- name: Deploy richie app servers
hosts: richie_docker_servers
serial: "{{ serial_number | default(1) }}" # deploy in sequence
become: True
gather_facts: True
tasks:
- name: Start rolling deploy - block load balancer connections
import_role:
name: rolling_deploy
vars:
rolling_deploy_docker: true
rolling_deploy_starting: true
when: ( groups['richie_docker_servers'] | length ) > 1 and ( richie_docker_deploy | default(false) | bool )
- name: Install or upgrade docker daemon
import_role:
name: geerlingguy.docker
when: richie_docker_deploy | default(false) | bool
- import_role:
name: snmpd
when: richie_docker_deploy | default(false) | bool
- import_role:
name: snmpd_docker
when: richie_docker_deploy | default(false) | bool
- name: Deploy richie as docker compose file
import_role:
name: richie_docker_deploy
vars:
richie_docker_deploy_run: "{{ richie_docker_deploy | default(false) }}"
elasticsearch_cluster_hosts_url_tmp: "{% for elastic_host in groups['elasticsearch_docker_servers'] %}http://{{ hostvars[elastic_host].ansible_host }}:{{ hostvars[elastic_host].elasticsearch_http_port }}{{ ',' if not loop.last else '' }}{% endfor %}"
richie_docker_deploy_elasticsearch_cluster_hosts_url: "{{ elasticsearch_cluster_hosts_url_tmp.split(',') | list }}"
# Temporary use elasticsearch VIP at least for the new NAU Richie release
richie_docker_deploy_redis_host: "{{ hostvars[groups['redis_docker_servers'][0]].redis_virtual_ipv4 }}"
richie_docker_deploy_redis_port: "{{ hostvars[groups['redis_docker_servers'][0]].redis_docker_port }}"
richie_docker_deploy_redis_db: "2"
richie_docker_deploy_mysql_host: "{{ hostvars[groups['richie_mysql_docker_servers'][0]].richie_mysql_virtual_ipv4 }}"
richie_docker_deploy_mysql_port: "{{ hostvars[groups['richie_mysql_docker_servers'][0]].richie_mysql_docker_port }}"
# Run database migrations and elasticsearch re-index only on the 1st server
richie_app_job_deploy: "{{ groups['richie_docker_servers'][0] == inventory_hostname }}"
- name: End rolling deploy - open load balancer connections
import_role:
name: rolling_deploy
vars:
rolling_deploy_docker: true
rolling_deploy_starting: false
when: ( groups['richie_docker_servers'] | length ) > 1 and ( richie_docker_deploy | default(false) | bool )
- name: Deploy coursecertificate docker servers
hosts: coursecertificate_docker_servers
serial: "{{ serial_number | default(1) }}" # deploy in sequence
become: True
gather_facts: True
tasks:
- name: Start rolling deploy - block load balancer connections
import_role:
name: rolling_deploy
vars:
rolling_deploy_docker: true
rolling_deploy_starting: true
when: ( groups['coursecertificate_docker_servers'] | length ) > 1 and ( coursecertificate_docker_deploy | default(false) | bool )
- name: Install or upgrade docker daemon
import_role:
name: geerlingguy.docker
when: coursecertificate_docker_deploy | default(false) | bool
- import_role:
name: snmpd
tags: snmpd
when: coursecertificate_docker_deploy | default(false) | bool
- import_role:
name: snmpd_docker
tags: snmpd
when: coursecertificate_docker_deploy | default(false) | bool
- name: Deploy coursecertificate as docker compose file
import_role:
name: coursecertificate_docker_deploy
vars:
coursecertificate_docker_deploy_run: "{{ coursecertificate_docker_deploy | default(false) }}"
- name: End rolling deploy - open load balancer connections
import_role:
name: rolling_deploy
vars:
rolling_deploy_docker: true
rolling_deploy_starting: false
when: ( groups['coursecertificate_docker_servers'] | length ) > 1 and ( coursecertificate_docker_deploy | default(false) | bool )
- name: Deploy staticproxy docker servers
hosts: staticproxy_docker_servers
serial: "{{ serial_number | default(1) }}" # deploy in sequence
become: True
gather_facts: True
tasks:
- name: Start rolling deploy - block load balancer connections
import_role:
name: rolling_deploy
vars:
rolling_deploy_docker: true
rolling_deploy_starting: true
when: ( groups['staticproxy_docker_servers'] | length ) > 1 and ( staticproxy_docker_deploy | default(false) | bool )
- name: Install or upgrade docker daemon
import_role:
name: geerlingguy.docker
when: staticproxy_docker_deploy | default(false) | bool
- import_role:
name: snmpd
tags: snmpd
when: staticproxy_docker_deploy | default(false) | bool
- import_role:
name: snmpd_docker
tags: snmpd
when: staticproxy_docker_deploy | default(false) | bool
- name: Deploy staticproxy as docker compose file
import_role:
name: staticproxy_docker_deploy
vars:
staticproxy_docker_deploy_run: "{{ staticproxy_docker_deploy | default(false) }}"
- name: End rolling deploy - open load balancer connections
import_role:
name: rolling_deploy
vars:
rolling_deploy_docker: true
rolling_deploy_starting: false
when: ( groups['staticproxy_docker_servers'] | length ) > 1 and ( staticproxy_docker_deploy | default(false) | bool )
- name: Deploy openedx mysql docker servers
hosts: openedx_mysql_docker_servers
serial: "{{ serial_number | default(1) }}" # deploy in sequence
become: True
gather_facts: True
tasks:
- name: Lower keepalived priority to force VIP swap
import_role:
name: keepalived
vars:
keepalived_priority_override: 1 # Lower priority so the VIPs can swap to other machine.
tags: keepalived
when: ( openedx_mysql_deploy | default(false) | bool ) and openedx_mysql_read_replica_keepalived_vrrp_instances is defined and ( groups['openedx_mysql_docker_servers'] | length ) > 1
- name: Install or upgrade docker daemon
import_role:
name: geerlingguy.docker
when: openedx_mysql_deploy | default(false) | bool
- import_role:
name: snmpd
tags: snmpd
when: openedx_mysql_deploy | default(false) | bool
- import_role:
name: snmpd_docker
tags: snmpd
when: openedx_mysql_deploy | default(false) | bool
- name: Deploy openedx mysql
import_role:
name: mysql_docker_deploy
when: openedx_mysql_deploy | default(false) | bool
vars:
mysql_docker_image: docker.io/mysql:5.7.44
mysql_major_release_number: 5
mysql_docker_configurations_dict_default:
character_set_server: utf8
collation_server: utf8_general_ci
# The number of days for automatic binary log file removal.
# The default is 0, which means "no automatic removal."
expire_logs_days: 30
# If a write to the binary log causes the current log file size to exceed the value of this variable,
# the server rotates the binary logs (closes the current file and opens the next one).
# The minimum value is 4096 bytes. The maximum and default value is 1GB.
max_binlog_size: 100M
# The maximum permitted number of simultaneous client connections.
# Default value is 151.
max_connections: 500
# Whether to use compression of the source/replica protocol if both source and replica support it.
slave_compressed_protocol: "ON"
# The size in bytes of the buffer pool, the memory area where InnoDB caches table and index data.
# Defaults to 128MB
innodb_buffer_pool_size: "{{ openedx_mysql_innodb_buffer_pool_size | default('128MB') }}"
# innodb_flush_log_at_trx_commit: 2
# In future when on local attached SSDs
# innodb_io_capacity: 1000
mysql_docker_configurations_dict_replica:
# Older DB had: --slave-skip-errors=1032,1062,1451,1452
slave_skip_errors: 1062,1032
mysql_docker_configurations_dict: "{{ mysql_docker_configurations_dict_default | combine(mysql_docker_configurations_dict_replica, recursive=True) if not openedx_mysql_docker_primary else mysql_docker_configurations_dict_default }}"
# The `--max-allowed-packet=1G` is to allow the mysqldump execute a backup. Trying to put it on the mysqldump command directly.
# The extra command have been removed: `--innodb-buffer-pool-size=4G --innodb-log-file-size=1G --innodb-log-buffer-size=256M`
# mysql_docker_command_extra: {{ '--slave-skip-errors=1062,1032' if not openedx_mysql_docker_primary else '' }}
# mysql_replication_login_user: "{{ COMMON_MYSQL_ADMIN_USER }}"
# Base configuration for the MySQL instance
mysql_docker_replication: true
mysql_docker_hostname: "{{ openedx_mysql_docker_hostname }}"
mysql_docker_port: "{{ openedx_mysql_docker_port }}"
mysql_docker_instance_name: openedx_mysql
mysql_docker_primary: "{{ openedx_mysql_docker_primary }}"
mysql_root_password: "{{ EDXAPP_MYSQL_PASSWORD_ADMIN }}"
mysql_server_id: "{{ groups.openedx_mysql_docker_servers.index(inventory_hostname) +1 }}"
mysql_health_check_user: "{{ openedx_mysql_health_check_user | default('health_check_user') }}"
mysql_health_check_pass: "{{ openedx_mysql_health_check_pass | default('') }}"
# Advanced configuration that assumes that the first server is the primary replica.
mysql_replication_login_password: "{{ EDXAPP_MYSQL_PASSWORD_ADMIN }}"
mysql_replication_master_server_ip: "{{ hostvars[groups.openedx_mysql_docker_servers[0]].ansible_host }}"
mysql_replication_master_port: "{{ hostvars[groups.openedx_mysql_docker_servers[0]].openedx_mysql_docker_port }}"
mysql_replication_user: "{{ EDXAPP_MYSQL_REPLICATION_USER }}"
mysql_replication_password: "{{ EDXAPP_MYSQL_REPLICATION_PASSWORD }}"
mysql_replication_init_databases: [ edxapp ]
mysql_replication_additional_databases: "{{ edxlocal_databases }}" # Used by docker_mysql_replication role
mysql_replication_additional_users: "{{ edxlocal_database_users }}" # Used by docker_mysql_replication role
- name: Restore keepalived priority
import_role:
name: keepalived
vars:
keepalived_priority_override: ""
tags: keepalived
when: ( openedx_mysql_deploy | default(false) | bool ) and openedx_mysql_read_replica_keepalived_vrrp_instances is defined and ( groups['openedx_mysql_docker_servers'] | length ) > 1
- name: Deploy openedx application docker servers
hosts: openedx_docker_servers
serial: "{{ serial_number | default(1) }}" # deploy in sequence
become: True
gather_facts: True
tasks:
- name: Start rolling deploy - block load balancer connections
import_role:
name: rolling_deploy
vars:
rolling_deploy_docker: true
rolling_deploy_starting: true
when: ( groups['openedx_docker_servers'] | length ) > 1 and ( openedx_docker_deploy | default(false) | bool )
- name: Install or upgrade docker daemon
import_role:
name: geerlingguy.docker
when: openedx_docker_deploy | default(false) | bool
- import_role:
name: snmpd
tags: snmpd
when: openedx_docker_deploy | default(false) | bool
- import_role:
name: snmpd_docker
tags: snmpd
when: openedx_docker_deploy | default(false) | bool
- name: Deploy openedx as docker compose file
import_role:
name: openedx_docker_deploy
vars:
openedx_docker_deploy_run: "{{ openedx_docker_deploy | default(false) }}"
elasticsearch_cluster_hosts_url_tmp: "{% for elastic_host in groups['elasticsearch_docker_servers'] %}http://{{ hostvars[elastic_host].ansible_host }}:{{ hostvars[elastic_host].elasticsearch_http_port }}{{ ',' if not loop.last else '' }}{% endfor %}"
openedx_docker_deploy_elasticsearch_cluster_hosts_url: "{{ elasticsearch_cluster_hosts_url_tmp.split(',') | list }}"
openedx_docker_deploy_cache_redis_host: "{{ hostvars[groups['redis_docker_servers'][0]].redis_virtual_ipv4 }}" # use VIP
openedx_docker_deploy_cache_redis_port: "{{ hostvars[groups['redis_docker_servers'][0]].redis_docker_port }}"
openedx_docker_deploy_celery_redis_host: "{{ hostvars[groups['redis_docker_servers'][0]].ansible_host }}" # don't use VIP, use host IP
openedx_docker_deploy_celery_redis_port: "{{ hostvars[groups['redis_docker_servers'][0]].redis_docker_port }}"
openedx_docker_deploy_ecommerce_broker_host: "{{ hostvars[groups['redis_docker_servers'][0]].ansible_host }}" # don't use VIP, use host IP
openedx_docker_deploy_ecommerce_broker_port: "{{ hostvars[groups['redis_docker_servers'][0]].redis_docker_port }}"
openedx_docker_deploy_mysql_default_host: "{{ hostvars[groups['openedx_mysql_docker_servers'][0]].ansible_host }}"
openedx_docker_deploy_mysql_default_port: "{{ hostvars[groups['openedx_mysql_docker_servers'][0]].openedx_mysql_docker_port }}"
openedx_docker_deploy_mysql_read_replica_host: "{{ hostvars[groups['openedx_mysql_docker_servers'][1]].openedx_mysql_read_replica_virtual_ipv4 | default( hostvars[groups['openedx_mysql_docker_servers'][1]].ansible_host ) }}"
openedx_docker_deploy_mysql_read_replica_port: "{{ hostvars[groups['openedx_mysql_docker_servers'][1]].openedx_mysql_docker_port }}"
# s3 to copy ACME issued certificates
openedx_nginx_s3_certificates_folder: "/acme_certificates"
openedx_docker_deploy_s3_host: "{{ AWS_S3_DBS_BACKUP_HOST }}"
openedx_docker_deploy_s3_bucket: "{{ AWS_S3_DBS_BACKUP_BUCKET_NAME }}"
openedx_docker_deploy_s3_access_key_id: "{{ EDXAPP_BACKUPS_AWS_ACCESS_KEY_ID }}"
openedx_docker_deploy_s3_secret_access_key: "{{ EDXAPP_BACKUPS_AWS_SECRET_ACCESS_KEY }}"
# server node where to build the nginx web server image with all static assets inside
openedx_build_web_server_node: "{{ hostvars[groups['build_server'][0]].ansible_host }}"
- name: End rolling deploy - open load balancer connections
import_role:
name: rolling_deploy
vars:
rolling_deploy_docker: true
rolling_deploy_starting: false
when: ( groups['openedx_docker_servers'] | length ) > 1 and ( openedx_docker_deploy | default(false) | bool )
- name: Update openedx site configurations
import_role:
name: openedx_app_site_configuration
when: ( openedx_app_site_configuration_deploy | default(false) | bool )
run_once: yes
tags:
- openedx_app_site_configuration
- create_or_update_site_configuration
- name: Deploy financial manager mysql docker servers
hosts: financial_manager_mysql_docker_servers
serial: "{{ serial_number | default(1) }}" # deploy in sequence
become: True
gather_facts: True
tasks:
- name: Install or upgrade docker daemon
import_role:
name: geerlingguy.docker
when: financial_manager_mysql_deploy | default(false) | bool
- import_role:
name: snmpd
tags: snmpd
when: financial_manager_mysql_deploy | default(false) | bool
- import_role:
name: snmpd_docker
tags: snmpd
when: financial_manager_mysql_deploy | default(false) | bool
- name: Deploy financial manager mysql
import_role:
name: mysql_docker_deploy
vars:
# To fix Financial Manager MySQL authentication
# use legacy authentication plugin to fix:
# django.db.utils.OperationalError: (2059, "Authentication plugin 'caching_sha2_password'
# cannot be loaded: /usr/lib/x86_64-linux-gnu/mariadb18/plugin/caching_sha2_password.so:
# cannot open shared object file: No such file or directory
mysql_docker_command_extra: --default-authentication-plugin=mysql_native_password
# Base configuration for the MySQL instance
mysql_docker_image: docker.io/mysql:8.0.29
mysql_major_release_number: 8
mysql_docker_hostname: "{{ financial_manager_mysql_docker_hostname | default('nau_financial_manager_mysql') }}"
mysql_docker_port: "{{ financial_manager_mysql_docker_port | default(3306) }}"
mysql_docker_instance_name: financial_manager_mysql
mysql_docker_primary: True
mysql_root_password: "{{ financial_manager_mysql_root_password }}"
mysql_server_id: "{{ groups.financial_manager_mysql_docker_servers.index(inventory_hostname) +1 }}"
mysql_health_check_user: "{{ financial_manager_mysql_health_check_user | default('health_check_user') }}"
mysql_health_check_pass: "{{ financial_manager_mysql_health_check_pass | default('') }}"
# Advanced configuration that assumes that the first server is the primary replica.
mysql_replication_login_password: "{{ financial_manager_mysql_root_password }}"
# mysql_replication_master_server_ip: "{{ hostvars[groups.financial_manager_mysql_docker_servers[0]].ansible_host }}"
# mysql_replication_master_port: "{{ hostvars[groups.financial_manager_mysql_docker_servers[0]].financial_manager_mysql_docker_port }}"
# mysql_replication_user: "{{ financial_manager_mysql_replication_user }}"
# mysql_replication_password: "{{ financial_manager_mysql_replication_password }}"
mysql_replication_init_databases: [ "{{ financial_manager_mysql_database }}" ]
mysql_replication_additional_databases:
- "{{ financial_manager_mysql_database | default(None) }}"
mysql_replication_additional_users:
# one per site
- {
db: "{{ financial_manager_mysql_database | default(None) }}",
user: "{{ financial_manager_mysql_user | default(None) }}",
pass: "{{ financial_manager_mysql_password | default(None) }}",
host: "%"
}
- {
db: "*",
user: "{{ financial_manager_mysql_health_check_user | default('health_check_user') }}",
host: "{{ financial_manager_mysql_health_check_host | default('%') }}",
}
when: financial_manager_mysql_deploy | default(false) | bool
- name: Deploy financial manager servers
hosts: financial_manager_docker_servers
serial: "{{ serial_number | default(1) }}" # deploy in sequence
become: True
gather_facts: True
tasks:
- name: Start rolling deploy - block load balancer connections
import_role:
name: rolling_deploy
vars:
rolling_deploy_docker: true
rolling_deploy_starting: true
when: ( groups['financial_manager_docker_servers'] | length ) > 1 and ( financial_manager_docker_servers | default(false) | bool )
- name: Install or upgrade docker daemon
import_role:
name: geerlingguy.docker
when: financial_manager_deploy | default(false) | bool
- import_role:
name: snmpd
tags: snmpd
when: financial_manager_deploy | default(false) | bool
- import_role:
name: snmpd_docker
tags: snmpd
when: financial_manager_deploy | default(false) | bool
- name: Deploy financial manager app
import_role:
name: financial_manager_docker_deploy
when: financial_manager_deploy | default(false) | bool
vars:
# MySQL DB
financial_manager_mysql_docker_hostname: "{{ hostvars[groups['financial_manager_mysql_docker_servers'][0]].ansible_host }}"
financial_manager_mysql_docker_port: "{{ hostvars[groups['financial_manager_mysql_docker_servers'][0]].financial_manager_mysql_docker_port }}"
financial_manager_mysql_database: "{{ hostvars[groups['financial_manager_mysql_docker_servers'][0]].financial_manager_mysql_database }}"
financial_manager_mysql_user: "{{ hostvars[groups['financial_manager_mysql_docker_servers'][0]].financial_manager_mysql_user }}"
financial_manager_mysql_password: "{{ hostvars[groups['financial_manager_mysql_docker_servers'][0]].financial_manager_mysql_password }}"
financial_manager_mysql_root_password: "{{ hostvars[groups['financial_manager_mysql_docker_servers'][0]].financial_manager_mysql_root_password }}"
# Django Cache
financial_manager_caches_default_redis_host: "{{ hostvars[groups['redis_docker_servers'][0]].redis_virtual_ipv4 }}"
financial_manager_caches_default_redis_port: "{{ hostvars[groups['redis_docker_servers'][0]].redis_docker_port }}"
financial_manager_caches_default_redis_db: "8"
# Celery broker
financial_manager_celery_broker_redis_host: "{{ hostvars[groups['redis_docker_servers'][0]].ansible_host }}"
financial_manager_celery_broker_redis_port: "{{ hostvars[groups['redis_docker_servers'][0]].redis_docker_port }}"
financial_manager_celery_broker_redis_db: "9"
- name: End rolling deploy - open load balancer connections
import_role:
name: rolling_deploy
vars:
rolling_deploy_docker: true
rolling_deploy_starting: false
when: ( groups['financial_manager_docker_servers'] | length ) > 1 and ( financial_manager_docker_servers | default(false) | bool )
- name: Deploy to XtraDB database
hosts: xtradb_servers
serial: "{{ serial_number | default(1) }}" # deploy in sequence
become: True
gather_facts: True
tasks:
- name: Install or upgrade docker daemon
import_role:
name: geerlingguy.docker
when: xtradb_deploy | default(false) | bool
- name: Install snmpd
import_role:
name: snmpd
tags: snmpd
when: xtradb_deploy | default(false) | bool
- name: Install snmpd docker bridge
import_role:
name: snmpd_docker
tags: snmpd
when: xtradb_deploy | default(false) | bool
- name: Deploy Percona XtraDB
import_role:
name: xtradb_docker_deploy
vars: