Commit c4bea4aa by Clinton Blackburn Committed by Clinton Blackburn

Added support for provisioning the ecommerce service in sandboxes

ECOM-2185
parent 2878a9e6
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
- role: nginx - role: nginx
nginx_sites: nginx_sites:
- ecommerce - ecommerce
nginx_default_sites:
- ecommerce
- aws - aws
- ecommerce - ecommerce
- role: datadog - role: datadog
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
- xserver - xserver
- certs - certs
- analytics_api - analytics_api
- ecommerce
nginx_default_sites: nginx_default_sites:
- lms - lms
- role: edxlocal - role: edxlocal
...@@ -35,6 +36,8 @@ ...@@ -35,6 +36,8 @@
- certs - certs
- edx_ansible - edx_ansible
- analytics_api - analytics_api
- ecommerce
- oauth_client_setup
- role: datadog - role: datadog
when: COMMON_ENABLE_DATADOG when: COMMON_ENABLE_DATADOG
- role: splunkforwarder - role: splunkforwarder
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
- insights - insights
- edx_notes_api - edx_notes_api
- demo - demo
- oauth_client_setup
- { role: 'rabbitmq', rabbitmq_ip: '127.0.0.1' } - { role: 'rabbitmq', rabbitmq_ip: '127.0.0.1' }
- oraclejdk - oraclejdk
- elasticsearch - elasticsearch
......
...@@ -18,6 +18,7 @@ ECOMMERCE_GIT_IDENTITY: !!null ...@@ -18,6 +18,7 @@ ECOMMERCE_GIT_IDENTITY: !!null
ECOMMERCE_NEWRELIC_APPNAME: "{{ COMMON_ENVIRONMENT }}-{{ COMMON_DEPLOYMENT }}-{{ ecommerce_service_name }}" ECOMMERCE_NEWRELIC_APPNAME: "{{ COMMON_ENVIRONMENT }}-{{ COMMON_DEPLOYMENT }}-{{ ecommerce_service_name }}"
ECOMMERCE_PIP_EXTRA_ARGS: "-i {{ COMMON_PYPI_MIRROR_URL }}" ECOMMERCE_PIP_EXTRA_ARGS: "-i {{ COMMON_PYPI_MIRROR_URL }}"
ECOMMERCE_NGINX_PORT: "18130" ECOMMERCE_NGINX_PORT: "18130"
ECOMMERCE_SSL_NGINX_PORT: 48130
ECOMMERCE_DEFAULT_DB_NAME: 'ecommerce' ECOMMERCE_DEFAULT_DB_NAME: 'ecommerce'
...@@ -38,10 +39,10 @@ ECOMMERCE_VERSION: "master" ...@@ -38,10 +39,10 @@ ECOMMERCE_VERSION: "master"
ECOMMERCE_SECRET_KEY: 'Your secret key here' ECOMMERCE_SECRET_KEY: 'Your secret key here'
ECOMMERCE_TIME_ZONE: 'UTC' ECOMMERCE_TIME_ZONE: 'UTC'
ECOMMERCE_LANGUAGE_CODE: 'en-us' ECOMMERCE_LANGUAGE_CODE: 'en-us'
ECOMMERCE_EDX_API_KEY: 'put-your-edx-api-auth-token-here' ECOMMERCE_EDX_API_KEY: 'PUT_YOUR_API_KEY_HERE' # This should match the value set for edxapp
ECOMMERCE_ECOMMERCE_URL_ROOT: 'http://localhost:8002' ECOMMERCE_ECOMMERCE_URL_ROOT: 'http://localhost:8002'
ECOMMERCE_LMS_URL_ROOT: 'http://127.0.0.1:8000' ECOMMERCE_LMS_URL_ROOT: 'http://127.0.0.1:8000'
ECOMMERCE_JWT_SECRET_KEY: 'generated-key-that-matches-ECOMMERCE_API_SIGNING_KEY-in-edxapp' ECOMMERCE_JWT_SECRET_KEY: 'SET-ME-PLEASE' # This should match the value set for edxapp
ECOMMERCE_JWT_VERIFY_EXPIRATION: true ECOMMERCE_JWT_VERIFY_EXPIRATION: true
# Used to automatically configure OAuth2 Client # Used to automatically configure OAuth2 Client
......
...@@ -55,6 +55,7 @@ repos_to_cmd["read-only-certificate-code"]="$edx_ansible_cmd certs.yml -e 'certs ...@@ -55,6 +55,7 @@ repos_to_cmd["read-only-certificate-code"]="$edx_ansible_cmd certs.yml -e 'certs
repos_to_cmd["edx-analytics-data-api"]="$edx_ansible_cmd analyticsapi.yml -e 'ANALYTICS_API_VERSION=$2'" repos_to_cmd["edx-analytics-data-api"]="$edx_ansible_cmd analyticsapi.yml -e 'ANALYTICS_API_VERSION=$2'"
repos_to_cmd["edx-ora2"]="$edx_ansible_cmd ora2.yml -e 'ora2_version=$2'" repos_to_cmd["edx-ora2"]="$edx_ansible_cmd ora2.yml -e 'ora2_version=$2'"
repos_to_cmd["insights"]="$edx_ansible_cmd insights.yml -e 'INSIGHTS_VERSION=$2'" repos_to_cmd["insights"]="$edx_ansible_cmd insights.yml -e 'INSIGHTS_VERSION=$2'"
repos_to_cmd["ecommerce"]="$edx_ansible_cmd ecommerce.yml -e 'ECOMMERCE_VERSION=$2'"
if [[ -z $1 || -z $2 ]]; then if [[ -z $1 || -z $2 ]]; then
......
...@@ -477,7 +477,7 @@ PERFORMANCE_GRAPHITE_URL: 'SetPerformanceGraphiteHostName' ...@@ -477,7 +477,7 @@ PERFORMANCE_GRAPHITE_URL: 'SetPerformanceGraphiteHostName'
# E-Commerce Related Settings # E-Commerce Related Settings
EDXAPP_ECOMMERCE_PUBLIC_URL_ROOT: 'https://www.example.com' EDXAPP_ECOMMERCE_PUBLIC_URL_ROOT: 'https://www.example.com'
EDXAPP_ECOMMERCE_API_URL: 'https://www-internal.example.com/api' EDXAPP_ECOMMERCE_API_URL: 'https://www-internal.example.com/api/v2'
EDXAPP_ECOMMERCE_API_SIGNING_KEY: 'SET-ME-PLEASE' EDXAPP_ECOMMERCE_API_SIGNING_KEY: 'SET-ME-PLEASE'
#To use AWS S3 as your backend, you need different kwargs: #To use AWS S3 as your backend, you need different kwargs:
......
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
value: "{{ item.public_dns_name }}" value: "{{ item.public_dns_name }}"
with_items: ec2.instances with_items: ec2.instances
- name: Add DNS name studio - name: Add DNS names for services
local_action: local_action:
module: route53 module: route53
overwrite: yes overwrite: yes
...@@ -74,21 +74,11 @@ ...@@ -74,21 +74,11 @@
zone: "{{ dns_zone }}" zone: "{{ dns_zone }}"
type: CNAME type: CNAME
ttl: 300 ttl: 300
record: "studio-{{ dns_name }}.{{ dns_zone }}" record: "{{ item[1] }}-{{ dns_name }}.{{ dns_zone }}"
value: "{{ item.public_dns_name }}" value: "{{ item[0].public_dns_name }}"
with_items: ec2.instances with_nested:
- ec2.instances
- name: Add DNS name preview - ['studio', 'ecommerce', 'preview']
local_action:
module: route53
overwrite: yes
command: create
zone: "{{ dns_zone }}"
type: CNAME
ttl: 300
record: "preview-{{ dns_name }}.{{ dns_zone }}"
value: "{{ item.public_dns_name }}"
with_items: ec2.instances
- name: Add new instance to host group - name: Add new instance to host group
......
...@@ -35,9 +35,3 @@ local_dev_pkgs: ...@@ -35,9 +35,3 @@ local_dev_pkgs:
- openbox - openbox
localdev_jscover_version: "1.0.2" localdev_jscover_version: "1.0.2"
localdev_oauth2_clients:
- { name: "{{ ecommerce_service_name | default('None') }}", url_root: "{{ ECOMMERCE_ECOMMERCE_URL_ROOT }}",
id: "{{ ECOMMERCE_SOCIAL_AUTH_EDX_OIDC_KEY }}", secret: "{{ ECOMMERCE_SOCIAL_AUTH_EDX_OIDC_SECRET }}" }
- { name: "{{ INSIGHTS_OAUTH2_APP_CLIENT_NAME | default('None') }}", url_root: "{{ INSIGHTS_BASE_URL }}",
id: "{{ INSIGHTS_OAUTH2_KEY }}", secret: "{{ INSIGHTS_OAUTH2_SECRET }}" }
...@@ -76,19 +76,3 @@ ...@@ -76,19 +76,3 @@
- name: add preview.localhost to /etc/hosts - name: add preview.localhost to /etc/hosts
shell: sed -i -r 's/^127.0.0.1\s+.*$/127.0.0.1 localhost preview.localhost/' /etc/hosts shell: sed -i -r 's/^127.0.0.1\s+.*$/127.0.0.1 localhost preview.localhost/' /etc/hosts
sudo: yes sudo: yes
- name: create OAuth2 Clients
shell: >
{{ COMMON_BIN_DIR }}/python.edxapp {{ COMMON_BIN_DIR }}/manage.edxapp lms --settings=aws
create_oauth2_client
{{ item.url_root }}
"{{ item.url_root }}/complete/edx-oidc/"
confidential
--client_name {{ item.name }}
--client_id {{ item.id }}
--client_secret {{ item.secret }}
--trusted
sudo_user: "{{ edxapp_user }}"
environment: "{{ edxapp_environment }}"
with_items: localdev_oauth2_clients
when: item.name != 'None'
...@@ -70,6 +70,7 @@ NGINX_EDXAPP_ERROR_PAGES: ...@@ -70,6 +70,7 @@ NGINX_EDXAPP_ERROR_PAGES:
"504": "{{ nginx_default_error_page }}" "504": "{{ nginx_default_error_page }}"
CMS_HOSTNAME: '~^((stage|prod)-)?studio.*' CMS_HOSTNAME: '~^((stage|prod)-)?studio.*'
ECOMMERCE_HOSTNAME: '~^((stage|prod)-)?ecommerce.*'
nginx_template_dir: "edx/app/nginx/sites-available" nginx_template_dir: "edx/app/nginx/sites-available"
......
# #
# {{ ansible_managed }} # {{ ansible_managed }}
# #
{% if "ecommerce" in nginx_default_sites %}
{% set default_site = "default" %}
{% else %}
{% set default_site = "" %}
{% endif %}
upstream ecommerce_app_server { upstream ecommerce_app_server {
{% for host in nginx_ecommerce_gunicorn_hosts %} {% for host in nginx_ecommerce_gunicorn_hosts %}
server {{ host }}:{{ ecommerce_gunicorn_port }} fail_timeout=0; server {{ host }}:{{ ecommerce_gunicorn_port }} fail_timeout=0;
{% endfor %} {% endfor %}
} }
server { server {
listen {{ ECOMMERCE_NGINX_PORT }} default_server; server_name {{ ECOMMERCE_HOSTNAME }};
{% if NGINX_ENABLE_SSL %}
listen {{ ECOMMERCE_NGINX_PORT }} {{ default_site }};
listen {{ ECOMMERCE_SSL_NGINX_PORT }} ssl;
ssl_certificate /etc/ssl/certs/{{ NGINX_SSL_CERTIFICATE|basename }};
ssl_certificate_key /etc/ssl/private/{{ NGINX_SSL_KEY|basename }};
# request the browser to use SSL for all connections
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
{% else %}
listen {{ ECOMMERCE_NGINX_PORT }} {{ default_site }};
{% endif %}
location ~ ^/static/(?P<file>.*) { location ~ ^/static/(?P<file>.*) {
root {{ COMMON_DATA_DIR }}/{{ ecommerce_service_name }}; root {{ COMMON_DATA_DIR }}/{{ ecommerce_service_name }};
......
---
#
# edX Configuration
#
# github: https://github.com/edx/configuration
# wiki: https://github.com/edx/configuration/wiki
# code style: https://github.com/edx/configuration/wiki/Ansible-Coding-Conventions
# license: https://github.com/edx/configuration/blob/master/LICENSE.TXT
#
##
# Defaults for role oauth_client_setup
#
#
# vars are namespaced with the module name.
#
oauth_client_setup_role_name: oauth_client_setup
oauth_client_setup_oauth2_clients:
- { name: "{{ ecommerce_service_name | default('None') }}", url_root: "{{ ECOMMERCE_ECOMMERCE_URL_ROOT }}",
id: "{{ ECOMMERCE_SOCIAL_AUTH_EDX_OIDC_KEY }}", secret: "{{ ECOMMERCE_SOCIAL_AUTH_EDX_OIDC_SECRET }}" }
- { name: "{{ INSIGHTS_OAUTH2_APP_CLIENT_NAME | default('None') }}", url_root: "{{ INSIGHTS_BASE_URL }}",
id: "{{ INSIGHTS_OAUTH2_KEY }}", secret: "{{ INSIGHTS_OAUTH2_SECRET }}" }
#
# OS packages
#
oauth_client_setup_debian_pkgs: []
oauth_client_setup_redhat_pkgs: []
---
#
# edX Configuration
#
# github: https://github.com/edx/configuration
# wiki: https://github.com/edx/configuration/wiki
# code style: https://github.com/edx/configuration/wiki/Ansible-Coding-Conventions
# license: https://github.com/edx/configuration/blob/master/LICENSE.TXT
#
#
#
# Tasks for role oauth_client_setup
#
# Overview:
#
#
# Dependencies:
#
#
# Example play:
#
#
- name: create OAuth2 Clients
shell: >
{{ COMMON_BIN_DIR }}/python.edxapp {{ COMMON_BIN_DIR }}/manage.edxapp lms --settings=aws
create_oauth2_client
{{ item.url_root }}
"{{ item.url_root }}/complete/edx-oidc/"
confidential
--client_name {{ item.name }}
--client_id {{ item.id }}
--client_secret {{ item.secret }}
--trusted
sudo_user: "{{ edxapp_user }}"
environment: "{{ edxapp_environment }}"
with_items: oauth_client_setup_oauth2_clients
when: item.name != 'None'
...@@ -32,3 +32,4 @@ ...@@ -32,3 +32,4 @@
- browsermob-proxy - browsermob-proxy
- local_dev - local_dev
- demo - demo
- oauth_client_setup
...@@ -147,6 +147,8 @@ EDXAPP_STATIC_URL_BASE: $static_url_base ...@@ -147,6 +147,8 @@ EDXAPP_STATIC_URL_BASE: $static_url_base
EDXAPP_LMS_NGINX_PORT: 80 EDXAPP_LMS_NGINX_PORT: 80
EDXAPP_LMS_PREVIEW_NGINX_PORT: 80 EDXAPP_LMS_PREVIEW_NGINX_PORT: 80
EDXAPP_CMS_NGINX_PORT: 80 EDXAPP_CMS_NGINX_PORT: 80
ECOMMERCE_NGINX_PORT: 80
ECOMMERCE_SSL_NGINX_PORT: 443
NGINX_SET_X_FORWARDED_HEADERS: True NGINX_SET_X_FORWARDED_HEADERS: True
EDX_ANSIBLE_DUMP_VARS: true EDX_ANSIBLE_DUMP_VARS: true
migrate_db: "yes" migrate_db: "yes"
...@@ -209,6 +211,11 @@ EDXAPP_NEWRELIC_WORKERS_APPNAME: sandbox-${dns_name}-edxapp-workers ...@@ -209,6 +211,11 @@ EDXAPP_NEWRELIC_WORKERS_APPNAME: sandbox-${dns_name}-edxapp-workers
XQUEUE_NEWRELIC_APPNAME: sandbox-${dns_name}-xqueue XQUEUE_NEWRELIC_APPNAME: sandbox-${dns_name}-xqueue
FORUM_NEW_RELIC_APP_NAME: sandbox-${dns_name}-forums FORUM_NEW_RELIC_APP_NAME: sandbox-${dns_name}-forums
SANDBOX_USERNAME: $github_username SANDBOX_USERNAME: $github_username
ECOMMERCE_SOCIAL_AUTH_REDIRECT_IS_HTTPS: true
EDXAPP_ECOMMERCE_PUBLIC_URL_ROOT: "https://ecommerce-${deploy_host}"
EDXAPP_ECOMMERCE_API_URL: "https://ecommerce-${deploy_host}/api/v2"
ECOMMERCE_ECOMMERCE_URL_ROOT: "https://ecommerce-${deploy_host}"
ECOMMERCE_LMS_URL_ROOT: "https://${deploy_host}"
EOF EOF
fi fi
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment