Commit 14db9ed8 by John Jarvis

read config from yaml

parent 9c8baf9d
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
ENABLE_NEWRELIC: False ENABLE_NEWRELIC: False
roles: roles:
- aws - aws
- edxlocal
- analytics-api - analytics-api
- role: datadog - role: datadog
when: COMMON_ENABLE_DATADOG when: COMMON_ENABLE_DATADOG
......
...@@ -30,7 +30,7 @@ analytics_api_home: "{{ COMMON_APP_DIR }}/{{ analytics_api_service_name }}" ...@@ -30,7 +30,7 @@ analytics_api_home: "{{ COMMON_APP_DIR }}/{{ analytics_api_service_name }}"
analytics_api_venv_base: "{{ analytics_api_home }}/venvs" analytics_api_venv_base: "{{ analytics_api_home }}/venvs"
analytics_api_venv_dir: "{{ analytics_api_venv_base }}/{{ analytics_api_service_name }}" analytics_api_venv_dir: "{{ analytics_api_venv_base }}/{{ analytics_api_service_name }}"
analytics_api_venv_bin: "{{ analytics_api_venv_dir }}/bin" analytics_api_venv_bin: "{{ analytics_api_venv_dir }}/bin"
analytics_api_code_dir: "{{ analytics_api_app_dir }}/src/edx-analytics-data-api" analytics_api_code_dir: "{{ analytics_api_app_dir }}/edx-analytics-data-api"
analytics_api_conf_dir: "{{ analytics_api_home }}" analytics_api_conf_dir: "{{ analytics_api_home }}"
analytics_api_gunicorn_host: "0.0.0.0" analytics_api_gunicorn_host: "0.0.0.0"
analytics_api_gunicorn_port: "8080" analytics_api_gunicorn_port: "8080"
...@@ -63,22 +63,22 @@ ANALYTICS_API_CONFIG: ...@@ -63,22 +63,22 @@ ANALYTICS_API_CONFIG:
API_AUTH_TOKEN: 'put-your-api-token-here' API_AUTH_TOKEN: 'put-your-api-token-here'
# db config # db config
DATABASES: DATABASES:
# rw user
default: default:
ENGINE: 'django.db.backends.mysql' ENGINE: 'django.db.backends.mysql'
NAME: 'reports' NAME: 'analytics-api'
USER: 'pipeline' USER: 'api001'
PASSWORD: 'password' PASSWORD: 'password'
HOST: 'localhost' HOST: 'localhost'
PORT: '3306' PORT: '3306'
analytics: # read-only user
reports:
ENGINE: 'django.db.backends.mysql' ENGINE: 'django.db.backends.mysql'
NAME: 'analytics-api' NAME: 'reports'
USER: 'api' USER: 'reports001'
PASSWORD: 'password' PASSWORD: 'password'
HOST: 'localhost' HOST: 'localhost'
PORT: '3306' PORT: '3306'
# #
# OS packages # OS packages
# #
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
dest={{ analytics_api_code_dir }} repo={{ analytics_api_source_repo }} version={{ ANALYTICS_API_VERSION }} dest={{ analytics_api_code_dir }} repo={{ analytics_api_source_repo }} version={{ ANALYTICS_API_VERSION }}
accept_hostkey=yes accept_hostkey=yes
ssh_opts="{{ analytics_api_git_ssh_opts }}" ssh_opts="{{ analytics_api_git_ssh_opts }}"
sudo_user: "{{ analytics_api_user }}"
- name: install application requirements - name: install application requirements
pip: > pip: >
......
...@@ -13,6 +13,7 @@ export NEW_RELIC_APP_NAME="{{ ANALYTICS_API_NEWRELIC_APPNAME }}" ...@@ -13,6 +13,7 @@ export NEW_RELIC_APP_NAME="{{ ANALYTICS_API_NEWRELIC_APPNAME }}"
export NEW_RELIC_LICENSE_KEY="{{ NEWRELIC_LICENSE_KEY }}" export NEW_RELIC_LICENSE_KEY="{{ NEWRELIC_LICENSE_KEY }}"
{% endif -%} {% endif -%}
export DJANGO_SETTINGS_MODULE="analyticsdataserver.settings.production"
export ANALYTICS_API_CFG="{{ COMMON_CFG_DIR }}/{{ analytics_api_service_name }}.yaml" export ANALYTICS_API_CFG="{{ COMMON_CFG_DIR }}/{{ analytics_api_service_name }}.yaml"
{{ executable }} -b {{ analytics_api_gunicorn_host }}:{{ analytics_api_gunicorn_port }} -w {{ analytics_api_gunicorn_workers }} --timeout={{ analytics_api_gunicorn_timeout }} analyticsdataserver.wsgi:application {{ executable }} --pythonpath={{ analytics_api_code_dir }} -b {{ analytics_api_gunicorn_host }}:{{ analytics_api_gunicorn_port }} -w {{ analytics_api_gunicorn_workers }} --timeout={{ analytics_api_gunicorn_timeout }} analyticsdataserver.wsgi:application
...@@ -43,7 +43,6 @@ ...@@ -43,7 +43,6 @@
with_items: with_items:
- "{{ COMMON_APP_DIR }}/{{ edx_service_name }}" - "{{ COMMON_APP_DIR }}/{{ edx_service_name }}"
- "{{ COMMON_APP_DIR }}/{{ edx_service_name }}/venvs" - "{{ COMMON_APP_DIR }}/{{ edx_service_name }}/venvs"
- "{{ COMMON_APP_DIR }}/{{ edx_service_name }}/data"
- name: create edx_service log dir - name: create edx_service log dir
file: > file: >
......
...@@ -18,12 +18,14 @@ ...@@ -18,12 +18,14 @@
name={{ EDXAPP_MYSQL_USER_MIGRATE }} name={{ EDXAPP_MYSQL_USER_MIGRATE }}
password={{ EDXAPP_MYSQL_PASSWORD_MIGRATE}} password={{ EDXAPP_MYSQL_PASSWORD_MIGRATE}}
priv='{{EDXAPP_MYSQL_DB_NAME}}.*:ALL' priv='{{EDXAPP_MYSQL_DB_NAME}}.*:ALL'
when: EDXAPP_MYSQL_USER_MIGRATE is defined
- name: setup the edxapp db user - name: setup the edxapp db user
mysql_user: > mysql_user: >
name={{ EDXAPP_MYSQL_USER }} name={{ EDXAPP_MYSQL_USER }}
password={{ EDXAPP_MYSQL_PASSWORD }} password={{ EDXAPP_MYSQL_PASSWORD }}
priv='{{EDXAPP_MYSQL_DB_NAME}}.*:ALL' priv='{{EDXAPP_MYSQL_DB_NAME}}.*:ALL'
when: EDXAPP_MYSQL_USER is defined
- name: create a database for edxapp - name: create a database for edxapp
mysql_db: > mysql_db: >
...@@ -51,6 +53,7 @@ ...@@ -51,6 +53,7 @@
name={{ ORA_MYSQL_USER }} name={{ ORA_MYSQL_USER }}
password={{ ORA_MYSQL_PASSWORD }} password={{ ORA_MYSQL_PASSWORD }}
priv='{{ORA_MYSQL_DB_NAME}}.*:ALL' priv='{{ORA_MYSQL_DB_NAME}}.*:ALL'
when: ORA_MYSQL_USER is defined
- name: create a database for ora - name: create a database for ora
mysql_db: > mysql_db: >
...@@ -84,18 +87,18 @@ ...@@ -84,18 +87,18 @@
- 'analytics-api' - 'analytics-api'
when: analytics_api_role_name is defined when: analytics_api_role_name is defined
- name: create database users analytics api - name: create api user for the analytics api
mysql_user: > mysql_user: >
name=reports name=api001
password=password password=password
priv='reports.*:ALL' priv='analytics-api.*:ALL'
when: analytics_api_role_name is defined when: analytics_api_role_name is defined
- name: create database users analytics api - name: create read-only reports user for the analytics-api
mysql_user: > mysql_user: >
name=api name=reports001
password=password password=password
priv='analytics-api.*:ALL' priv='reports.*:SELECT'
when: analytics_api_role_name is defined when: analytics_api_role_name is defined
- name: install memcached - name: install memcached
......
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