Commit 7cd721f8 by Vik Paruchuri

Change naming to reflect discern instead of mlapi

parent 6f550707
- hosts: tag_Group_mlapi_prod
- hosts: tag_Group_discern_prod
vars_files:
- ["{{ secure_dir }}/vars/mlapi_prod_vars.yml"]
- ["{{ secure_dir }}/vars/discern_prod_vars.yml"]
- ["{{ secure_dir }}/vars/users.yml"]
- ["{{ secure_dir }}/vars/mlapi_prod_users.yml"]
- ["{{ secure_dir }}/vars/discern_prod_users.yml"]
roles:
- mlapi
- common
- discern
- hosts:
- tag_Group_mlapi_sandbox
- tag_Group_discern_sandbox
vars_files:
- ["{{ secure_dir }}/vars/mlapi_sandbox_vars.yml"]
- ["{{ secure_dir }}/vars/discern_sandbox_vars.yml"]
- ["{{ secure_dir }}/vars/users.yml"]
- ["{{ secure_dir }}/vars/mlapi_sandbox_users.yml"]
- ["{{ secure_dir }}/vars/discern_sandbox_users.yml"]
roles:
- common
- mlapi
- discern
- hosts: tag_Group_mlapi_stage
- hosts: tag_Group_discern_stage
vars_files:
- ["{{ secure_dir }}/vars/mlapi_stage_vars.yml"]
- ["{{ secure_dir }}/vars/discern_stage_vars.yml"]
- ["{{ secure_dir }}/vars/users.yml"]
- ["{{ secure_dir }}/vars/mlapi_stage_users.yml"]
- ["{{ secure_dir }}/vars/discern_stage_users.yml"]
roles:
- mlapi
- common
- discern
---
- include: create_users.yml
- name: Create application root
# In the future consider making group edx r/t adm
file: path=$app_base_dir state=directory owner=root group=adm mode=2775
tags:
- pre_install
- name: Create log directory
file: path=/mnt/logs state=directory mode=2770 group=adm owner=root
tags:
- pre_install
- name: Create aliases to the log directory
file: state=link src=/mnt/logs path=$app_base_dir/log
tags:
- pre_install
- name: Touch the edx log file into place
command: touch -a /mnt/logs/edx.log
tags:
- pre_install
- name: Update apt cache
apt: update_cache=yes
tags:
- pre_install
- include: create_venv.yml
- name: Install role-independent useful system packages
apt: pkg={{item}} install_recommends=yes state=present
with_items:
- ack-grep
- lynx-cur
- mosh
<<<<<<< HEAD
- tmux
sudo: True
=======
- most
- screen
tags:
- pre_install
>>>>>>> origin/master
---
#Stop all services
- name: stop celery
service: name=celery state=stopped
sudo: True
......@@ -11,18 +12,21 @@
service: name=discern state=stopped
sudo: True
- name: create mlapi application config env.json file
#Upload config files for django (auth and env)
- name: create discern application config env.json file
template: src=env.json.j2 dest=$app_base_dir/env.json
sudo: True
- name: create mlapi auth file auth.json
- name: create discern auth file auth.json
template: src=auth.json.j2 dest=$app_base_dir/auth.json
sudo: True
#Needed if using redis to prevent memory issues
- name: change memory commit settings -- needed for redis
command: sysctl vm.overcommit_memory=1
sudo: yes
#Needed to pull repos from github, due to hanging on host add prompt otherwise
- name: add github to the known hosts file
shell: ssh-keyscan -H github.com > ~/.ssh/known_hosts
......@@ -35,43 +39,48 @@
apt: pkg=git install_recommends=yes state=present
sudo: True
- name: create ml api directory and set permissions
file: path={{ml_api_dir}} owner={{remote_user}} group=edx mode=2775 state=directory
#Create directories for repos
- name: create discern directory and set permissions
file: path={{discern_dir}} owner={{remote_user}} group=edx mode=2775 state=directory
sudo: True
- name: create machine learning directory and set permissions
file: path={{ml_dir}} owner={{remote_user}} group=edx mode=2775 state=directory
- name: create ease directory and set permissions
file: path={{ease_dir}} owner={{remote_user}} group=edx mode=2775 state=directory
sudo: True
- name: git checkout discern repo into ml_api_dir
git: dest={{ml_api_dir}} repo={{mlapi_source_repo}} version={{ml_api_branch}}
#Grab both repos or update
- name: git checkout discern repo into discern_dir
git: dest={{discern_dir}} repo={{discern_source_repo}} version={{discern_branch}}
- name: git checkout machine-learning repo into ml_dir
git: dest={{ml_dir}} repo={{ml_source_repo}} version={{ml_branch}}
- name: git checkout ease repo into ease_dir
git: dest={{ease_dir}} repo={{ease_source_repo}} version={{ease_branch}}
#Install system packages
- name: install discern apt packages
command: xargs -a $app_base_dir/discern/apt-packages.txt apt-get install -y
command: xargs -a {{discern_dir}}/apt-packages.txt apt-get install -y
sudo: yes
- name: install machine-learning apt packages
command: xargs -a $app_base_dir/machine-learning/apt-packages.txt apt-get install -y
- name: install ease apt packages
command: xargs -a {{ease_dir}}/apt-packages.txt apt-get install -y
sudo: yes
#Numpy has to be a pre-requirement in order for scipy to build
- name : install python pre-requirements for discern
pip: requirements="{{ml_api_dir}}/pre-requirements.txt" virtualenv="{{venv_dir}}" state=present
pip: requirements="{{discern_dir}}/pre-requirements.txt" virtualenv="{{venv_dir}}" state=present
- name : install python pre-requirements for machine-learning
pip: requirements="{{ml_dir}}/pre-requirements.txt" virtualenv="{{venv_dir}}" state=present
- name : install python pre-requirements for ease
pip: requirements="{{ease_dir}}/pre-requirements.txt" virtualenv="{{venv_dir}}" state=present
- name : install python requirements for discern
pip: requirements="{{ml_api_dir}}/requirements.txt" virtualenv="{{venv_dir}}" state=present
pip: requirements="{{discern_dir}}/requirements.txt" virtualenv="{{venv_dir}}" state=present
- name : install python requirements for machine-learning
pip: requirements="{{ml_dir}}/requirements.txt" virtualenv="{{venv_dir}}" state=present
- name : install python requirements for ease
pip: requirements="{{ease_dir}}/requirements.txt" virtualenv="{{venv_dir}}" state=present
- name: install machine-learning python package
shell: command="{{venv_dir}}/bin/activate; cd {{ml_dir}}; python setup.py install"
- name: install ease python package
shell: command="{{venv_dir}}/bin/activate; cd {{ease_dir}}; python setup.py install"
#Needed for the ease package to work
- name: install nltk data using rendered shell script
shell: command="{{venv_dir}}/bin/python -m nltk.downloader -d {{nltk_data_dir}} all"
......@@ -79,18 +88,21 @@
file: path={{nltk_data_dir}} owner={{remote_user}} group=edx mode=2775 state=directory
sudo: True
#Run this instead of using the ansible module because the ansible module only support syncdb of these four, and does not
#support virtualenvs as of this comment
- name: django syncdb for discern
shell: ls; {{venv_dir}}/bin/python {{ml_api_dir}}/manage.py syncdb --noinput --settings={{ml_api_settings}} --pythonpath={{ml_api_dir}}
shell: ls; {{venv_dir}}/bin/python {{discern_dir}}/manage.py syncdb --noinput --settings={{discern_settings}} --pythonpath={{discern_dir}}
- name: django migrate for discern
shell: ls; {{venv_dir}}/bin/python {{ml_api_dir}}/manage.py migrate --noinput --settings={{ml_api_settings}} --pythonpath={{ml_api_dir}}
shell: ls; {{venv_dir}}/bin/python {{discern_dir}}/manage.py migrate --noinput --settings={{discern_settings}} --pythonpath={{discern_dir}}
- name: django collectstatic for discern
shell: ls; {{venv_dir}}/bin/python {{ml_api_dir}}/manage.py collectstatic --noinput --settings={{ml_api_settings}} --pythonpath={{ml_api_dir}}
shell: ls; {{venv_dir}}/bin/python {{discern_dir}}/manage.py collectstatic --noinput --settings={{discern_settings}} --pythonpath={{discern_dir}}
- name: django update_index for discern
shell: ls; {{venv_dir}}/bin/python {{ml_api_dir}}/manage.py update_index --settings={{ml_api_settings}} --pythonpath={{ml_api_dir}}
shell: ls; {{venv_dir}}/bin/python {{discern_dir}}/manage.py update_index --settings={{discern_settings}} --pythonpath={{discern_dir}}
#Create the templates for upstart services
- name: render celery service from template
template: src=celery.conf.j2 dest=/etc/init/celery.conf
sudo: True
......@@ -107,6 +119,7 @@
template: src=default.j2 dest=/etc/nginx/sites-available/default
sudo: True
#start the services up
- name: start celery
service: name=celery state=started
sudo: True
......
......@@ -9,9 +9,9 @@ stop on runlevel [!2345]
respawn
respawn limit 3 30
env DJANGO_SETTINGS_MODULE={{ml_api_settings}}
env DJANGO_SETTINGS_MODULE={{discern_settings}}
chdir {{ml_api_dir}}
chdir {{discern_dir}}
setuid {{remote_user}}
exec {{venv_dir}}/bin/python {{ml_api_dir}}/manage.py celeryd --loglevel=info --settings={{ml_api_settings}} --pythonpath={{ml_api_dir}} -B --autoscale=4,1
exec {{venv_dir}}/bin/python {{discern_dir}}/manage.py celeryd --loglevel=info --settings={{discern_settings}} --pythonpath={{discern_dir}} -B --autoscale=4,1
......@@ -9,7 +9,7 @@ server {
# https://docs.djangoproject.com/en/dev/howto/static-files/#serving-static-files-in-production
location /static/ { # STATIC_URL
alias {{ml_api_dir}}/staticfiles/;
alias {{discern_dir}}/staticfiles/;
expires 1m;
autoindex on;
}
......
......@@ -13,9 +13,9 @@ env PID=/var/run/gunicorn/discern.pid
env WORKERS=4
env PORT=7999
env LANG=en_US.UTF-8
env DJANGO_SETTINGS_MODULE={{ml_api_settings}}
env DJANGO_SETTINGS_MODULE={{discern_settings}}
chdir {{ml_api_dir}}
chdir {{discern_dir}}
setuid {{remote_user}}
exec {{venv_dir}}/bin/gunicorn --preload -b 127.0.0.1:$PORT -w $WORKERS --timeout=30 --pythonpath={{ml_api_dir}} discern.wsgi
\ No newline at end of file
exec {{venv_dir}}/bin/gunicorn --preload -b 127.0.0.1:$PORT -w $WORKERS --timeout=30 --pythonpath={{discern_dir}} discern.wsgi
\ No newline at end of file
discern_source_repo: git@github.com:edx/discern.git
ease_source_repo: git@github.com:edx/ease.git
ease_dir: $app_base_dir/ease
discern_dir: $app_base_dir/discern
discern_settings: discern.aws
nltk_data_dir: /usr/share/nltk_data
remote_user: ubuntu
ease_branch: master
discern_branch: dev
nginx_listen_port: 80
\ No newline at end of file
mlapi_source_repo: git@github.com:edx/discern.git
ml_source_repo: git@github.com:edx/machine-learning.git
ml_dir: $app_base_dir/machine-learning
ml_api_dir: $app_base_dir/discern
ml_api_settings: discern.aws
nltk_data_dir: /usr/share/nltk_data
remote_user: ubuntu
ml_branch: master
ml_api_branch: dev
nginx_listen_port: 80
\ 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