-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathopenedx_lms_db_export.yml
60 lines (54 loc) · 2.97 KB
/
openedx_lms_db_export.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
# Ansible playbook to update intermediate analytics database and to export open edx database to a spreadsheet/google sheets with information of the Open edX LMS/Studio.
#
# It runs a git clone on the localhost machine, run a docker build, generates a configuration file and then runs the built docker image.
#
# Example:
# ansible-playbook -i nau-data/envs/production/hosts.ini openedx_lms_db_export.yml -e "extra_params: -t"
#
# Example exports only the organization table to google sheets:
# ansible-playbook -i nau-data/envs/production/hosts.ini openedx_lms_db_export.yml -e export=google_sheets -e export_sheets=organizations
#
# Example exports everything to xlsx file:
# ansible-playbook -i nau-data/envs/production/hosts.ini openedx_lms_db_export.yml -e export=google_sheets
---
- name: Exports information to excel from Open EDX LMS/Studio databases
hosts: "staticproxy_docker_servers:&{{ target | default('staticproxy_docker_servers') }}[-1]"
become: True
gather_facts: True
vars:
_nau_db_exporter_version: "{{ nau_db_exporter_version | default('master') }}"
nau_db_exporter_extra_params: "{{ extra_params | default('') }}"
nau_db_exporter_base_directory: /tmp/nau-database-exporter-{{ _nau_db_exporter_version }}
export_sheets: organizations,course_runs,course_run_by_date,enrollments_year_of_birth,enrollments_gender,enrollments_level_of_education,enrollments_country,enrollments_employment_situation,registered_users_by_day,distinct_users_by_day,distinct_users_by_month,final_summary
export_sheets_as_list: "{{ (export_sheets.split(',') | list) }}"
export: xlsx
tasks:
- name: Create folder
file:
path: "{{ nau_db_exporter_base_directory }}"
state: directory
- name: Generates a configuration file
template:
src: "{{ COMMON_PATH_CUSTOM_FILES }}/nau-database-exporter/config.ini.j2"
dest: "{{ nau_db_exporter_base_directory }}/config.ini"
- name: Pull docker image
shell: docker pull nauedu/nau-database-exporter:{{ _nau_db_exporter_version }}
- name: Runs the python that exports data
shell: |
docker run -t --rm \
--name nau-database-exporter-{{ _nau_db_exporter_version }} \
--mount type=bind,source={{ nau_db_exporter_base_directory }}/config.ini,target=/usr/src/app/config.ini \
-v {{ nau_db_exporter_base_directory }}/output:/usr/src/app/output \
nauedu/nau-database-exporter:{{ _nau_db_exporter_version }} \
timeout 1h python export.py --config config.ini --export {{ export | default('xlsx') }} {{ nau_db_exporter_extra_params }}
args:
chdir: "{{ nau_db_exporter_base_directory }}"
register: export_data_output
- name: Print stdout of export output
debug:
msg: "{{ export_data_output.stdout_lines }}"
when: export_data_output.stdout_lines is defined
- name: Print stderr of export output
debug:
msg: "{{ export_data_output.stderr_lines }}"
when: export_data_output.stderr_lines is defined