Commit 8bb35254 by Max Rothman

Integrate service role

parent 265e222e
...@@ -11,8 +11,6 @@ ...@@ -11,8 +11,6 @@
# Defaults for role insights # Defaults for role insights
# #
INSIGHTS_GIT_IDENTITY: !!null
INSIGHTS_MEMCACHE: [ 'localhost:11211' ] INSIGHTS_MEMCACHE: [ 'localhost:11211' ]
INSIGHTS_FEEDBACK_EMAIL: 'dashboard@example.com' INSIGHTS_FEEDBACK_EMAIL: 'dashboard@example.com'
INSIGHTS_MKTG_BASE: 'http://example.com' INSIGHTS_MKTG_BASE: 'http://example.com'
...@@ -59,7 +57,7 @@ INSIGHTS_DATABASES: ...@@ -59,7 +57,7 @@ INSIGHTS_DATABASES:
# #
# This block of config is dropped into /edx/etc/insights.yml # This block of config is dropped into /edx/etc/insights.yml
# and is read in by analytics_dashboard/settings/production.py # and is read in by analytics_dashboard/settings/production.py
INSIGHTS_CONFIG: INSIGHTS_SERVICE_CONFIG:
SUPPORT_URL: '{{ INSIGHTS_SUPPORT_URL }}' SUPPORT_URL: '{{ INSIGHTS_SUPPORT_URL }}'
DOCUMENTATION_LOAD_ERROR_URL: '{{ INSIGHTS_DOC_BASE }}/Reference.html#error-conditions' DOCUMENTATION_LOAD_ERROR_URL: '{{ INSIGHTS_DOC_BASE }}/Reference.html#error-conditions'
SEGMENT_IO_KEY: '{{ INSIGHTS_SEGMENT_IO_KEY }}' SEGMENT_IO_KEY: '{{ INSIGHTS_SEGMENT_IO_KEY }}'
...@@ -103,13 +101,24 @@ INSIGHTS_CONFIG: ...@@ -103,13 +101,24 @@ INSIGHTS_CONFIG:
connect_timeout: 10 connect_timeout: 10
DATABASES: "{{ INSIGHTS_DATABASES }}" DATABASES: "{{ INSIGHTS_DATABASES }}"
INSIGHTS_VERSION: "master"
INSIGHTS_NEWRELIC_APPNAME: "{{ COMMON_ENVIRONMENT }}-{{ COMMON_DEPLOYMENT }}-analytics-api" INSIGHTS_NEWRELIC_APPNAME: "{{ COMMON_ENVIRONMENT }}-{{ COMMON_DEPLOYMENT }}-analytics-api"
INSIGHTS_PIP_EXTRA_ARGS: "-i {{ COMMON_PYPI_MIRROR_URL }}" INSIGHTS_PIP_EXTRA_ARGS: "-i {{ COMMON_PYPI_MIRROR_URL }}"
INSIGHTS_NGINX_PORT: "18110" INSIGHTS_NGINX_PORT: "18110"
INSIGHTS_GUNICORN_WORKERS: "2" INSIGHTS_GUNICORN_WORKERS: "2"
INSIGHTS_GUNICORN_EXTRA: "" INSIGHTS_GUNICORN_EXTRA: ""
INSIGHTS_VERSION: "master"
INSIGHTS_GIT_IDENTITY: !!null
INSIGHTS_REPOS:
- PROTOCOL: "{{ COMMON_GIT_PROTOCOL }}"
DOMAIN: "{{ COMMON_GIT_MIRROR }}"
PATH: "{{ COMMON_GIT_PATH }}"
REPO: edx-analytics-dashboard.git
VERSION: "{{ INSIGHTS_VERSION }}"
DESTINATION: "{{ insights_code_dir }}"
SSH_KEY: "{{ INSIGHTS_GIT_IDENTITY }}
# #
# vars are namespace with the module name. # vars are namespace with the module name.
# #
...@@ -117,14 +126,10 @@ insights_environment: ...@@ -117,14 +126,10 @@ insights_environment:
DJANGO_SETTINGS_MODULE: "analytics_dashboard.settings.production" DJANGO_SETTINGS_MODULE: "analytics_dashboard.settings.production"
ANALYTICS_DASHBOARD_CFG: "{{ COMMON_CFG_DIR }}/{{ insights_service_name }}.yaml" ANALYTICS_DASHBOARD_CFG: "{{ COMMON_CFG_DIR }}/{{ insights_service_name }}.yaml"
insights_role_name: "insights" insights_service_name: insights
insights_service_name: "{{ insights_role_name }}" insights_user: "{{ insights_service_name }}"
insights_user: "{{ insights_role_name }}"
insights_app_dir: "{{ COMMON_APP_DIR }}/{{ insights_service_name }}" insights_app_dir: "{{ COMMON_APP_DIR }}/{{ insights_service_name }}"
insights_home: "{{ COMMON_APP_DIR }}/{{ insights_service_name }}" insights_home: "{{ COMMON_APP_DIR }}/{{ insights_service_name }}"
insights_venv_base: "{{ insights_home }}/venvs"
insights_venv_dir: "{{ insights_venv_base }}/{{ insights_service_name }}"
insights_venv_bin: "{{ insights_venv_dir }}/bin"
insights_code_dir: "{{ insights_app_dir }}/edx-analytics-dashboard" insights_code_dir: "{{ insights_app_dir }}/edx-analytics-dashboard"
insights_python_path: "{{ insights_code_dir }}/analytics_dashboard" insights_python_path: "{{ insights_code_dir }}/analytics_dashboard"
insights_conf_dir: "{{ insights_home }}" insights_conf_dir: "{{ insights_home }}"
...@@ -141,9 +146,6 @@ insights_gunicorn_timeout: "300" ...@@ -141,9 +146,6 @@ insights_gunicorn_timeout: "300"
insights_wsgi: "analytics_dashboard.wsgi:application" insights_wsgi: "analytics_dashboard.wsgi:application"
insights_django_settings: "analytics_dashboard.settings.production" insights_django_settings: "analytics_dashboard.settings.production"
insights_source_repo: "git@{{ COMMON_GIT_MIRROR }}:/edx/edx-analytics-dashboard"
insights_git_ssh_opts: "-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i {{ insights_git_identity_file }}"
insights_git_identity_file: "{{ insights_home }}/git-identity"
insights_manage: "{{ insights_code_dir }}/analytics_dashboard/manage.py" insights_manage: "{{ insights_code_dir }}/analytics_dashboard/manage.py"
insights_requirements_base: "{{ insights_code_dir }}/requirements" insights_requirements_base: "{{ insights_code_dir }}/requirements"
......
...@@ -12,6 +12,9 @@ ...@@ -12,6 +12,9 @@
# #
dependencies: dependencies:
- role: edx_service - role: edx_service
edx_role_name: "{{ insights_role_name }}"
edx_service_name: "{{ insights_service_name }}" edx_service_name: "{{ insights_service_name }}"
edx_service_config: "{{ INSIGHTS_SERVICE_CONFIG }}"
edx_service_repos: "{{ INSIGHTS_REPOS }}"
edx_service_user: "{{ insights_user }}"
edx_service_home: "{{ insights_home }}"
- supervisor - supervisor
...@@ -21,11 +21,6 @@ ...@@ -21,11 +21,6 @@
# #
# #
- name: install read-only ssh key
copy: >
content="{{ INSIGHTS_GIT_IDENTITY }}" dest={{ insights_git_identity_file }}
owner={{ insights_user }} group={{ insights_user }} mode=0600
- name: setup the insights env file - name: setup the insights env file
template: > template: >
src="edx/app/insights/insights_env.j2" src="edx/app/insights/insights_env.j2"
...@@ -34,35 +29,18 @@ ...@@ -34,35 +29,18 @@
group={{ insights_user }} group={{ insights_user }}
mode=0644 mode=0644
- name: checkout code
git: >
dest={{ insights_code_dir }} repo={{ insights_source_repo }} version={{ INSIGHTS_VERSION }}
accept_hostkey=yes
ssh_opts="{{ insights_git_ssh_opts }}"
register: insights_code_checkout
notify: restart insights
sudo_user: "{{ insights_user }}"
- name: write out app config file
template: >
src=edx/app/insights/insights.yaml.j2
dest={{ COMMON_CFG_DIR }}/{{ insights_service_name }}.yaml
mode=0644 owner={{ insights_user }} group={{ insights_user }}
notify: restart insights
- name: install application requirements - name: install application requirements
pip: > pip: >
requirements="{{ insights_requirements_base }}/{{ item }}" requirements="{{ insights_requirements_base }}/{{ item }}"
virtualenv="{{ insights_venv_dir }}" state=present virtualenv="{{ insights_home }}/venvs/{{ insights_service_name }}"
extra_args="--exists-action w" state=present extra_args="--exists-action w"
sudo_user: "{{ insights_user }}" sudo_user: "{{ insights_user }}"
notify: restart insights
with_items: insights_requirements with_items: insights_requirements
- name: create nodeenv - name: create nodeenv
shell: > shell: >
creates={{ insights_nodeenv_dir }} creates={{ insights_nodeenv_dir }}
{{ insights_venv_bin }}/nodeenv {{ insights_nodeenv_dir }} {{ insights_home }}/venvs/{{ insights_service_name }}/bin/nodeenv {{ insights_nodeenv_dir }}
sudo_user: "{{ insights_user }}" sudo_user: "{{ insights_user }}"
- name: install node dependencies - name: install node dependencies
...@@ -80,7 +58,7 @@ ...@@ -80,7 +58,7 @@
chdir={{ insights_code_dir }} chdir={{ insights_code_dir }}
DB_MIGRATION_USER={{ COMMON_MYSQL_MIGRATE_USER }} DB_MIGRATION_USER={{ COMMON_MYSQL_MIGRATE_USER }}
DB_MIGRATION_PASS={{ COMMON_MYSQL_MIGRATE_PASS }} DB_MIGRATION_PASS={{ COMMON_MYSQL_MIGRATE_PASS }}
{{ insights_venv_bin }}/python {{ insights_manage }} migrate --noinput {{ insights_home }}/venvs/{{ insights_service_name }}/bin/python {{ insights_manage }} migrate --noinput
sudo_user: "{{ insights_user }}" sudo_user: "{{ insights_user }}"
environment: "{{ insights_environment }}" environment: "{{ insights_environment }}"
when: migrate_db is defined and migrate_db|lower == "yes" when: migrate_db is defined and migrate_db|lower == "yes"
...@@ -94,7 +72,7 @@ ...@@ -94,7 +72,7 @@
- name: run collectstatic - name: run collectstatic
shell: > shell: >
chdir={{ insights_code_dir }} chdir={{ insights_code_dir }}
{{ insights_venv_bin }}/python {{ insights_manage }} {{ item }} {{ insights_home }}/venvs/{{ insights_service_name }}/bin/python {{ insights_manage }} {{ item }}
sudo_user: "{{ insights_user }}" sudo_user: "{{ insights_user }}"
environment: "{{ insights_environment }}" environment: "{{ insights_environment }}"
with_items: with_items:
...@@ -104,7 +82,7 @@ ...@@ -104,7 +82,7 @@
- name: compile translations - name: compile translations
shell: > shell: >
chdir={{ insights_code_dir }}/analytics_dashboard chdir={{ insights_code_dir }}/analytics_dashboard
. {{ insights_venv_bin }}/activate && i18n_tool generate -v . {{ insights_home }}/venvs/{{ insights_service_name }}/bin/activate && i18n_tool generate -v
sudo_user: "{{ insights_user }}" sudo_user: "{{ insights_user }}"
- name: write out the supervisior wrapper - name: write out the supervisior wrapper
...@@ -112,14 +90,12 @@ ...@@ -112,14 +90,12 @@
src=edx/app/insights/insights.sh.j2 src=edx/app/insights/insights.sh.j2
dest={{ insights_app_dir }}/{{ insights_service_name }}.sh dest={{ insights_app_dir }}/{{ insights_service_name }}.sh
mode=0650 owner={{ supervisor_user }} group={{ common_web_user }} mode=0650 owner={{ supervisor_user }} group={{ common_web_user }}
notify: restart insights
- name: write supervisord config - name: write supervisord config
template: > template: >
src=edx/app/supervisor/conf.d.available/insights.conf.j2 src=edx/app/supervisor/conf.d.available/insights.conf.j2
dest="{{ supervisor_available_dir }}/{{ insights_service_name }}.conf" dest="{{ supervisor_available_dir }}/{{ insights_service_name }}.conf"
owner={{ supervisor_user }} group={{ common_web_user }} mode=0644 owner={{ supervisor_user }} group={{ common_web_user }} mode=0644
notify: restart insights
- name: enable supervisor script - name: enable supervisor script
file: > file: >
...@@ -127,7 +103,6 @@ ...@@ -127,7 +103,6 @@
dest={{ supervisor_cfg_dir }}/{{ insights_service_name }}.conf dest={{ supervisor_cfg_dir }}/{{ insights_service_name }}.conf
state=link state=link
force=yes force=yes
notify: restart insights
when: not disable_edx_services when: not disable_edx_services
- name: update supervisor configuration - name: update supervisor configuration
...@@ -136,8 +111,8 @@ ...@@ -136,8 +111,8 @@
- name: create symlinks from the venv bin dir - name: create symlinks from the venv bin dir
file: > file: >
src="{{ insights_venv_bin }}/{{ item }}" src="{{ insights_home }}/venvs/{{ insights_service_name }}/bin/{{ item }}"
dest="{{ COMMON_BIN_DIR }}/{{ item.split('.')[0] }}.{{ insights_role_name }}" dest="{{ COMMON_BIN_DIR }}/{{ item.split('.')[0] }}.{{ insights_service_name }}"
state=link state=link
with_items: with_items:
- python - python
...@@ -147,11 +122,5 @@ ...@@ -147,11 +122,5 @@
- name: create manage.py symlink - name: create manage.py symlink
file: > file: >
src="{{ insights_manage }}" src="{{ insights_manage }}"
dest="{{ COMMON_BIN_DIR }}/manage.{{ insights_role_name }}" dest="{{ COMMON_BIN_DIR }}/manage.{{ insights_service_name }}"
state=link state=link
\ No newline at end of file
- name: remove read-only ssh key for the content repo
file: path={{ insights_git_identity_file }} state=absent
- include: tag_ec2.yml tags=deploy
when: COMMON_TAG_EC2_INSTANCE
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
# {{ ansible_managed }} # {{ ansible_managed }}
{% set insights_venv_bin = insights_home + '/venvs' + insights_service_name + '/bin' }
{% if COMMON_ENABLE_NEWRELIC_APP %} {% if COMMON_ENABLE_NEWRELIC_APP %}
{% set executable = insights_venv_bin + '/newrelic-admin run-program ' + insights_venv_bin + '/gunicorn' %} {% set executable = insights_venv_bin + '/newrelic-admin run-program ' + insights_venv_bin + '/gunicorn' %}
{% else %} {% else %}
......
---
# {{ ansible_managed }}
{{ INSIGHTS_CONFIG | to_nice_yaml }}
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