Commit 54784bea by e0d

adding analytics experiments role

parent baa9d2ce
#!/bin/sh
exec /usr/bin/ssh -o StrictHostKeyChecking=no -i /etc/git-identity "$@"
---
#
# 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
#
#
#
# Handlers for role analytics-experiments
#
# Overview:
#
#
- name: analytics-experiments | stop the analytics service
service: name=analytics state=stopped
- name: analytics-experiments | restart the analytics service
service: name=analytics state=started
#
# TODO: Needed while this repo is private
#
- name: analytics-experiments | upload ssh script
copy:
src=git_ssh.sh dest=/tmp/git_ssh.sh
force=yes owner=root group=adm mode=750
tags:
- analytics-experiments
- deploy
- install
- update
#
# TODO: Needed while this repo is private
#
- name: analytics-experiments | install read-only ssh key required for checkout
copy:
src={{ ax_git_identity_path }} dest=/etc/git-identity
force=yes owner=ubuntu group=adm mode=60
tags:
- analytics-experiments
- deploy
- install
- update
- name: analytics-experiments | checkout code
git:
dest={{ ax_code_dir }} repo={{ ax_source_repo }}
version={{ ax_version }}
environment:
GIT_SSH: /tmp/git_ssh.sh
notify: analytics-experiments | restart the analytics service
tags:
- analytics-experiments
- deploy
- install
- update
#
# TODO: Needed while this repo is private
#
- name: analytics-experiments | update src permissions
file:
path={{ ax_code_dir }} state=directory owner={{ ax_user }}
group={{ ax_web_user }} mode=2750 recurse=yes
tags:
- analytics-experiments
- deploy
- install
- update
#
# TODO: Needed while this repo is private
#
- name: analytics-experiments | remove read-only ssh key for the content repo
file: path=/etc/git-identity state=absent
tags:
- analytics-experiments
- deploy
- install
- update
#
# TODO: Needed while this repo is private
#
- name: analytics-experiments | remove ssh script
file: path=/tmp/git_ssh.sh state=absent
tags:
- analytics-experiments
- deploy
- install
- update
- name: analytics-experiments | install application requirements
pip:
requirements={{ ax_requirements_file }}
virtualenv={{ ax_venv_dir }} state=present
sudo: true
sudo_user: "{{ ax_user }}"
tags:
- analytics-experiments
- deploy
- install
- update
#- name: analytics-experiments | syncdb
# shell: >
# cd {{ ax_code_dir }} && {{ ax_venv_dir }}/bin/python manage.py syncdb
# sudo: true
# sudo_user: "{{ ax_user }}"
# notify:
# - analytics-experiments | restart analytics-experiments
# tags:
# - analytics-experiments
# - deploy
# - install
# - update
---
#
# 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 analytics-experiments
#
# Overview:
#
#
# Dependencies:
#
#
# Example play:
#
#
- name: analytics-experiments | install system packages
apt: pkg={{','.join(ax_debian_pkgs)}} state=present
tags:
- analytics-experiments
- install
- update
- name: analytics-experiments | create analytics-experiments user {{ ax_user }}
user:
name={{ ax_user }} state=present shell=/bin/bash
home={{ ax_home }} createhome=yes
tags:
- analytics-experiments
- install
- update
- name: analytics-experiments | setup the analytics-experiments env
template:
src=opt/wwc/analytics-experiments/{{ ax_env }}.j2
dest={{ ax_home }}/{{ ax_env }}
owner="{{ ax_user }}" group="{{ ax_user }}"
tags:
- analytics-experiments
- install
- update
- name: analytics-experiments | drop a bash_profile
copy: >
src=../../common/files/bash_profile
dest={{ ax_home }}/.bash_profile
owner={{ ax_user }}
group={{ ax_user }}
- name: analytics-experiments | ensure .bashrc exists
shell: touch {{ ax_home }}/.bashrc
sudo: true
sudo_user: "{{ ax_user }}"
tags:
- analytics-experiments
- install
- update
- name: analytics-experiments | add source of analytics-experiments_env to .bashrc
lineinfile:
dest={{ ax_home }}/.bashrc
regexp='. {{ ax_home }}/analytics-experiments_env'
line='. {{ ax_home }}/analytics_experiments_env'
tags:
- analytics-experiments
- install
- update
- name: analytics-experiments | add source venv to .bashrc
lineinfile:
dest={{ ax_home }}/.bashrc
regexp='. {{ ax_venv_dir }}/bin/activate'
line='. {{ ax_venv_dir }}/bin/activate'
tags:
- analytics-experiments
- install
- update
- name: analytics-experiments | install global python requirements
pip: name={{ item }}
with_items: ax_pip_pkgs
tags:
- analytics-experiments
- install
- update
- name: analtyics-experiments | install service
template:
src=etc/init/analytics.conf.j2 dest=/etc/init/analytics.conf
owner=root group=root
- include: deploy.yml
\ No newline at end of file
# gunicorn
description "Analytics server under gunicorn"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
respawn limit 3 30
env SERVICE_VARIANT={{ ax_service_variant }}
env PID=/var/tmp/analytics.pid
env WORKERS={{ ax_workers }}
env PORT={{ ax_server_port }}
env LANG={{ ax_env_lang }}
env DJANGO_SETTINGS_MODULE={{ ax_django_settings }}
chdir {{ ax_code_dir }}
setuid {{ ax_web_user }}
exec {{ ax_venv_dir }}/bin/gunicorn -b 0.0.0.0:$PORT -w $WORKERS --pythonpath={{ ax_code_dir }}/anserv anserv.wsgi
# gunicorn
description "Analytics server under gunicorn"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
respawn limit 3 30
env SERVICE_VARIANT={{ ax_service_variant }}
env PID=/var/tmp/analytics.pid
env WORKERS={{ ax_workers }}
env PORT={{ ax_server_port }}
env LANG={{ ax_env_lang }}
env DJANGO_SETTINGS_MODULE={{ ax_django_settings }}
chdir {{ ax_code_dir }}
setuid {{ ax_web_user }}
exec {{ ax_venv_dir }}/bin/gunicorn -b 0.0.0.0:$PORT -w $WORKERS --pythonpath={{ ax_code_dir }}/anserv anserv.wsgi
# {{ ansible_managed }}
{% for name,value in ax_env_vars.items() %}
{% if value %}
export {{ name }}="{{ value }}"
{% endif %}
{% endfor %}
\ No newline at end of file
---
#
# 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
#
#
# Vars for role analytics-experiments
# vars are namespace with the module name.
#
ax_role_name: "analytics-experiments"
ax_user: "analytics-experiments"
ax_home: "/opt/wwc/analytics-experiments"
ax_venv_dir: "{{ ax_home }}/virtualenvs/analytics-experiments"
ax_source_repo: "git@github.com:MITx/analytics-experiments.git"
ax_code_dir: "{{ ax_home }}/src"
ax_version: "e0d/requirements-update"
ax_git_identity_path: "{{ secure_dir }}/files/git-identity"
ax_requirements_file: "{{ ax_code_dir }}/requirements.txt"
ax_log_level: "INFO"
ax_rsyslog_enabled: "yes"
ax_web_user: "www-data"
ax_env: "analytics-experiments_env"
ax_service_variant: 'analytics'
ax_workers: '4'
ax_server_port: '9000'
ax_env_lang: 'en_US.UTF-8'
ax_django_settings: 'anserv.settings'
ax_env_vars:
ANALYTICS_EXPERIMENTS_LOG_LEVEL: "{{ ax_log_level }}"
#
# OS packages
#
ax_debian_pkgs:
- mongodb-clients
- zip
ax_redhat_pkgs: []
ax_pip_pkgs:
- git+https://github.com/s3tools/s3cmd.git#egg=s3cmd
\ No newline at end of file
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