From 49c6db45fbb6b16dc02f91dbf4959516f41bfed6 Mon Sep 17 00:00:00 2001 From: Guruprasad Lakshmi Narayanan Date: Fri, 20 Mar 2020 23:31:31 +0530 Subject: [PATCH 1/6] Allow setting SiteConfiguration values when provisioning an instance Allow setting SiteConfiguration values for the default site or a specific site by id or domain when provisioning an instance. (cherry picked from commit e805a57a66dac62b6d96afce5c4bc4278147621f) --- CHANGELOG.md | 3 ++ playbooks/roles/edxapp/defaults/main.yml | 20 +++++++++ .../edxapp/tasks/service_variant_config.yml | 8 ++++ .../roles/edxapp/tasks/site_configuration.yml | 42 +++++++++++++++++++ .../templates/site_configuration.json.j2 | 1 + 5 files changed, 74 insertions(+) create mode 100644 playbooks/roles/edxapp/tasks/site_configuration.yml create mode 100644 playbooks/roles/edxapp/templates/site_configuration.json.j2 diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ecbf7b2fb2..42142027afe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ All notable changes to this project will be documented in this file. Add any new changes to the top(right below this line). +- Role: edxapp + - Added `EDXAPP_SITE_CONFIGURATION` to allow creating/updating the `SiteConfiguration` values during provisioning. + - Role: edxapp BREAKING_CHANGE - The sandbox environment that runs instructor written python code used to run python 2.7. We update the default to python 3.5 but provide a new variable to be able to go back to the old setting. If `edxapp_sandbox_python_version` diff --git a/playbooks/roles/edxapp/defaults/main.yml b/playbooks/roles/edxapp/defaults/main.yml index acae0128a3c..3ae515ab662 100644 --- a/playbooks/roles/edxapp/defaults/main.yml +++ b/playbooks/roles/edxapp/defaults/main.yml @@ -1741,3 +1741,23 @@ EDXAPP_LMS_LOCAL_CONFIG_FILE: "{{ UNENCRYPTED_CFG_DIR }}/lms.yml" EDXAPP_CMS_LOCAL_CONFIG_FILE: "{{ UNENCRYPTED_CFG_DIR }}/studio.yml" edxapp_staticfiles_storage_overrides: !!null + +# Accepts a list of dictionaries of the following form. +# EDXAPP_SITE_CONFIGURATION: +# - site_id: 1 +# values: +# foo: true +# bar: false +# - domain: example.com +# values: +# abc: true +# - values: +# xyz: true +# +# In each dictionary, the 'site_id' and the 'domain' keys are optional and the 'values' key +# is required. However, only one of 'site_id', 'domain' can be specified due to the behaviour +# of the 'create_or_update_site_configuration' management command. The 'values' key accepts a +# dictionary of keys and values corresponding to the SiteConfiguration paramters to be added to the +# SiteConfiguration instance. + +EDXAPP_SITE_CONFIGURATION: {} diff --git a/playbooks/roles/edxapp/tasks/service_variant_config.yml b/playbooks/roles/edxapp/tasks/service_variant_config.yml index 0b74a1fe423..9abb6bf0f9b 100644 --- a/playbooks/roles/edxapp/tasks/service_variant_config.yml +++ b/playbooks/roles/edxapp/tasks/service_variant_config.yml @@ -302,3 +302,11 @@ tags: - gather_static_assets - assets + +- name: Create or update SiteConfiguration + include: site_configuration.yml + when: celery_worker is not defined and EDXAPP_SITE_CONFIGURATION + with_items: "{{ EDXAPP_SITE_CONFIGURATION }}" + become_user: "{{ edxapp_user }}" + tags: + - create_or_update_site_configuration diff --git a/playbooks/roles/edxapp/tasks/site_configuration.yml b/playbooks/roles/edxapp/tasks/site_configuration.yml new file mode 100644 index 00000000000..a30c7de440b --- /dev/null +++ b/playbooks/roles/edxapp/tasks/site_configuration.yml @@ -0,0 +1,42 @@ +--- +- name: Create or update SiteConfiguration + block: + - name: Create the SiteConfiguration JSON file + template: + src: "site_configuration.json.j2" + dest: "/tmp/site_configuration.json" + + - name: Use the site_id if it is provided + set_fact: + site_identifier: "--site-id {{ item.site_id }}" + when: item.site_id is defined and item.domain is not defined + + - name: Use the domain name if it is provided + set_fact: + site_identifier: "{{ item.domain }}" + when: item.domain is defined and item.site_id is not defined + + - name: Fail if both site_id and domain are provided + fail: + msg: "Cannot specify the site_id and domain at the same time in {{ item }}" + when: item.domain is defined and item.site_id is defined + + - name: Get the default SITE_ID + shell: ". {{ edxapp_app_dir }}/edxapp_env && {{ edxapp_venv_bin }}/python {{ edxapp_code_dir }}/manage.py lms print_setting SITE_ID 2>/dev/null" + register: default_site_id + when: item.site_id is not defined and item.domain is not defined + + - name: Use the default SITE_ID as the site identifier + set_fact: + site_identifier: "--site-id {{ default_site_id.stdout }}" + when: item.site_id is not defined and item.domain is not defined + + - name: Run create_or_update_site_configuration + shell: | + . {{ edxapp_app_dir }}/edxapp_env + {{ edxapp_venv_bin }}/python {{ edxapp_code_dir }}/manage.py lms create_or_update_site_configuration -f /tmp/site_configuration.json --enabled {{ site_identifier }} + + - name: Remove the generated SiteConfiguration JSON file + file: + path: "/tmp/site_configuration.json" + state: absent diff --git a/playbooks/roles/edxapp/templates/site_configuration.json.j2 b/playbooks/roles/edxapp/templates/site_configuration.json.j2 new file mode 100644 index 00000000000..2fae98836c8 --- /dev/null +++ b/playbooks/roles/edxapp/templates/site_configuration.json.j2 @@ -0,0 +1 @@ +{{ item['values'] | to_nice_json }} From 7910bcc75b92fc4685136986ab4b626c0534cdc4 Mon Sep 17 00:00:00 2001 From: Paulo Viadanna Date: Fri, 23 Aug 2019 15:56:12 -0300 Subject: [PATCH 2/6] Add ECOMMERCE_SECURE_PROXY_SSL_HEADER (cherry picked from commit 40c5a8993d6cc2f9ab8197bd72e83bb018a91f60) --- playbooks/roles/ecommerce/defaults/main.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/playbooks/roles/ecommerce/defaults/main.yml b/playbooks/roles/ecommerce/defaults/main.yml index 0c6f3549fc6..9465d103337 100644 --- a/playbooks/roles/ecommerce/defaults/main.yml +++ b/playbooks/roles/ecommerce/defaults/main.yml @@ -194,7 +194,10 @@ ECOMMERCE_CORS_ALLOW_CREDENTIALS: false ECOMMERCE_USERNAME_REPLACEMENT_WORKER: "OVERRIDE THIS WITH A VALID USERNAME" +ECOMMERCE_SECURE_PROXY_SSL_HEADER: !!null + ecommerce_service_config_overrides: + SECURE_PROXY_SSL_HEADER: '{{ ECOMMERCE_SECURE_PROXY_SSL_HEADER }}' LANGUAGE_COOKIE_NAME: '{{ ECOMMERCE_LANGUAGE_COOKIE_NAME }}' EDX_API_KEY: '{{ ECOMMERCE_EDX_API_KEY }}' OSCAR_FROM_EMAIL: '{{ ECOMMERCE_OSCAR_FROM_EMAIL }}' From e9c4e0e8bf6a85be670495eadecc63f848114a1e Mon Sep 17 00:00:00 2001 From: Jillian Vogel Date: Wed, 26 Feb 2020 10:56:40 +1030 Subject: [PATCH 3/6] Makes the ecommerce OSCAR_DEFAULT_CURRENCY configurable. (cherry picked from commit 436092e2ab1a4dd8db3e5e077dfb6d8dd7151d71) (cherry picked from commit e7b91fbe321d8c7bf34ee95c27cdc529359fd7eb) --- playbooks/roles/ecommerce/defaults/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/playbooks/roles/ecommerce/defaults/main.yml b/playbooks/roles/ecommerce/defaults/main.yml index 9465d103337..7da59dc30d3 100644 --- a/playbooks/roles/ecommerce/defaults/main.yml +++ b/playbooks/roles/ecommerce/defaults/main.yml @@ -83,6 +83,7 @@ ECOMMERCE_SOCIAL_AUTH_REDIRECT_IS_HTTPS: false # Settings for affiliate cookie tracking ECOMMERCE_AFFILIATE_COOKIE_NAME: '{{ EDXAPP_AFFILIATE_COOKIE_NAME | default("dev_affiliate_id") }}' +ECOMMERCE_OSCAR_DEFAULT_CURRENCY: 'USD' ECOMMERCE_OSCAR_FROM_EMAIL: 'oscar@example.com' # NOTE: The contents of the certificates should be set in private configuration @@ -200,6 +201,7 @@ ecommerce_service_config_overrides: SECURE_PROXY_SSL_HEADER: '{{ ECOMMERCE_SECURE_PROXY_SSL_HEADER }}' LANGUAGE_COOKIE_NAME: '{{ ECOMMERCE_LANGUAGE_COOKIE_NAME }}' EDX_API_KEY: '{{ ECOMMERCE_EDX_API_KEY }}' + OSCAR_DEFAULT_CURRENCY: '{{ ECOMMERCE_OSCAR_DEFAULT_CURRENCY }}' OSCAR_FROM_EMAIL: '{{ ECOMMERCE_OSCAR_FROM_EMAIL }}' ENTERPRISE_SERVICE_URL: '{{ ECOMMERCE_ENTERPRISE_URL }}/enterprise/' From a30667fc025084c2bd294738921be22ff5df68b9 Mon Sep 17 00:00:00 2001 From: Agrendalath Date: Sun, 31 May 2020 17:47:16 +0200 Subject: [PATCH 4/6] [BB-2447] Add `NGINX_ALLOW_PRIVATE_IP_ACCESS` variable Setting this variable to `True` disables handling the IP disclosure within private subnetworks. (cherry picked from commit 8a797720dd6d312222e4aa35fecdb45c6e358d90) --- .../nginx/sites-available/concerns/handle-ip-disclosure.j2 | 5 +++++ .../handle-tls-terminated-elsewhere-ip-disclosure.j2 | 5 +++++ .../nginx/sites-available/concerns/handle-ip-disclosure.j2 | 5 +++++ .../handle-tls-terminated-elsewhere-ip-disclosure.j2 | 5 +++++ playbooks/roles/nginx/defaults/main.yml | 2 ++ .../edx/app/nginx/sites-available/handle-ip-disclosure.j2 | 5 +++++ .../handle-tls-terminated-elsewhere-ip-disclosure.j2 | 5 +++++ 7 files changed, 32 insertions(+) diff --git a/playbooks/roles/edx_django_service/templates/edx/app/nginx/sites-available/concerns/handle-ip-disclosure.j2 b/playbooks/roles/edx_django_service/templates/edx/app/nginx/sites-available/concerns/handle-ip-disclosure.j2 index bde470df881..f7267de637d 100644 --- a/playbooks/roles/edx_django_service/templates/edx/app/nginx/sites-available/concerns/handle-ip-disclosure.j2 +++ b/playbooks/roles/edx_django_service/templates/edx/app/nginx/sites-available/concerns/handle-ip-disclosure.j2 @@ -2,6 +2,11 @@ # there is a TLS redirect to same box, and a TLS redirect to externally terminated TLS # version of this in nginx and in edx_django_service role. +{% if NGINX_ALLOW_PRIVATE_IP_ACCESS %} +# This regexp matches only public IP addresses. +if ($host ~ "(\d+)(? Date: Mon, 15 Jun 2020 17:22:10 +0530 Subject: [PATCH 5/6] Override additional partials and the discussion bootstrap styles to fix issues (cherry picked from commit af69623be7a0f4deebd2e0667f205ebe24aa0f0d) --- .../lms/static/sass/discussion/lms-discussion-bootstrap.scss | 2 ++ .../lms/static/sass/partials/lms/theme/_variables-v1.scss | 2 ++ .../lms/static/sass/partials/lms/theme/_variables.scss | 2 ++ playbooks/roles/simple_theme/tasks/deploy.yml | 1 - 4 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 playbooks/roles/simple_theme/files/default_skeleton/lms/static/sass/discussion/lms-discussion-bootstrap.scss create mode 100644 playbooks/roles/simple_theme/files/default_skeleton/lms/static/sass/partials/lms/theme/_variables-v1.scss create mode 100644 playbooks/roles/simple_theme/files/default_skeleton/lms/static/sass/partials/lms/theme/_variables.scss diff --git a/playbooks/roles/simple_theme/files/default_skeleton/lms/static/sass/discussion/lms-discussion-bootstrap.scss b/playbooks/roles/simple_theme/files/default_skeleton/lms/static/sass/discussion/lms-discussion-bootstrap.scss new file mode 100644 index 00000000000..d4668edb4af --- /dev/null +++ b/playbooks/roles/simple_theme/files/default_skeleton/lms/static/sass/discussion/lms-discussion-bootstrap.scss @@ -0,0 +1,2 @@ +@import 'lms/static/sass/discussion/lms-discussion-bootstrap'; +@import '../lms-overrides'; diff --git a/playbooks/roles/simple_theme/files/default_skeleton/lms/static/sass/partials/lms/theme/_variables-v1.scss b/playbooks/roles/simple_theme/files/default_skeleton/lms/static/sass/partials/lms/theme/_variables-v1.scss new file mode 100644 index 00000000000..5bdd4d5aaf3 --- /dev/null +++ b/playbooks/roles/simple_theme/files/default_skeleton/lms/static/sass/partials/lms/theme/_variables-v1.scss @@ -0,0 +1,2 @@ +@import '../common-variables'; +@import 'lms/static/sass/partials/lms/theme/variables-v1'; diff --git a/playbooks/roles/simple_theme/files/default_skeleton/lms/static/sass/partials/lms/theme/_variables.scss b/playbooks/roles/simple_theme/files/default_skeleton/lms/static/sass/partials/lms/theme/_variables.scss new file mode 100644 index 00000000000..e40724fd7c1 --- /dev/null +++ b/playbooks/roles/simple_theme/files/default_skeleton/lms/static/sass/partials/lms/theme/_variables.scss @@ -0,0 +1,2 @@ +@import '../common-variables'; +@import 'lms/static/sass/partials/lms/theme/variables'; diff --git a/playbooks/roles/simple_theme/tasks/deploy.yml b/playbooks/roles/simple_theme/tasks/deploy.yml index 85cfb4ec4b8..ac601a0bdab 100644 --- a/playbooks/roles/simple_theme/tasks/deploy.yml +++ b/playbooks/roles/simple_theme/tasks/deploy.yml @@ -91,7 +91,6 @@ with_items: # List of files from ./templates to be processed - "lms/static/sass/common-variables.scss" - - "lms/static/sass/partials/lms/theme/_variables-v1.scss" - "lms/static/sass/_lms-overrides.scss" # Copying static files is done in two steps: create directories + copy files From 9831fdef856636289bf5eafe74240bacc7b3c16b Mon Sep 17 00:00:00 2001 From: pkulkark Date: Wed, 22 Jul 2020 15:44:31 +0530 Subject: [PATCH 6/6] Remove repeated course data dir creation step cf https://github.com/edx/configuration/pull/5884 (cherry picked from commit a027b4b6677231c5238013488888566b9cd05aff) --- playbooks/roles/edxapp/tasks/main.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/playbooks/roles/edxapp/tasks/main.yml b/playbooks/roles/edxapp/tasks/main.yml index d10fe30e412..3882a20384e 100644 --- a/playbooks/roles/edxapp/tasks/main.yml +++ b/playbooks/roles/edxapp/tasks/main.yml @@ -27,7 +27,6 @@ - { path: "{{ edxapp_theme_dir }}" } - { path: "{{ edxapp_staticfile_dir }}" } - { path: "{{ edxapp_course_static_dir }}" } - - { path: "{{ edxapp_course_data_dir }}" } # var should have more permissive permissions than the rest - { path: "{{ edxapp_data_dir }}", mode: "0775" } # directory to import the courses from github