Commit 10f565d7 by John Jarvis

creating deploy.yml for the discern role

parent 62759be1
DISCERN_NGINX_PORT: 18070
DISCERN_BASIC_AUTH: False
discern_app_dir: "{{ app_dir }}/discern"
discern_code_dir: "{{ discern_app_dir }}/discern"
discern_data_dir: "{{ data_dir }}/discern"
discern_venv_dir: "{{ venvs_dir }}/discern"
discern_venv_bin: "{{ discern_venv_dir }}/bin"
discern_pre_requirements_file: "{{ discern_code_dir }}/pre-requirements.txt"
discern_post_requirements_file: "{{ discern_code_dir }}/requirements.txt"
discern_user: "discern"
discern_ease_venv_dir: "{{ discern_venv_dir }}"
discern_ease_code_dir: "{{ app_dir }}/ease"
discern_ease_source_repo: https://github.com/edx/ease.git
discern_ease_version: 'HEAD'
discern_ease_pre_requirements_file: "{{ discern_ease_code_dir }}/pre-requirements.txt"
discern_ease_post_requirements_file: "{{ discern_ease_code_dir }}/requirements.txt"
discern_nltk_data_dir: "{{ discern_data_dir}}/nltk_data"
discern_source_repo: https://github.com/edx/discern.git
ease_source_repo: https://github.com/edx/ease.git
ease_dir: $app_dir/ease
discern_dir: $app_dir/discern
discern_settings: discern.aws
nltk_data_dir: /usr/share/nltk_data
ease_branch: master
discern_branch: dev
discern_gunicorn_port: 8070
discern_gunicorn_host: 127.0.0.1
discern_user: discern
site_name: discern
discern_debian_pkgs:
- policykit-1
- python-virtualenv
- gcc
- g++
- build-essential
- python-dev
- gfortran
- libfreetype6-dev
- libpng12-dev
- libxml2-dev
- libxslt-dev
- libreadline6
- libreadline6-dev
- redis-server
- python-pip
- ipython
- nginx
- libmysqlclient-dev
- libblas3gf
- libblas-dev
- liblapack3gf
- liblapack-dev
- libatlas-base-dev
- curl
- yui-compressor
discern_ease_debian_pkgs:
- python-pip
- gcc
- g++
- gfortran
- libblas3gf
- libblas-dev
- liblapack3gf
- liblapack-dev
- libatlas-base-dev
- libxml2-dev
- libxslt1-dev
- aspell
- python
---
#Upload config files for django (auth and env)
- name: discern | create discern application config env.json file
template: src=env.json.j2 dest={{app_dir}}/env.json
sudo_user: "{{ discern_user }}"
notify:
- discern | restart celery
- discern | restart discern
- name: discern | create discern auth file auth.json
template: src=auth.json.j2 dest={{app_dir}}/auth.json
sudo_user: "{{ discern_user }}"
notify:
- discern | restart celery
- discern | restart discern
#Needed if using redis to prevent memory issues
- name: discern | change memory commit settings -- needed for redis
command: sysctl vm.overcommit_memory=1
- name: discern | set permissions on app_dir sgid for edx
file: path={{app_dir}} owner=root group=edx mode=2775 state=directory
file: path={{venv_dir}} owner=root group=edx mode=2775 state=directory
#Grab both repos or update
- name: discern | git checkout discern repo into discern_dir
git: dest={{discern_dir}} repo={{discern_source_repo}} version={{discern_branch}}
sudo_user: "{{ discern_user }}"
notify:
- discern | restart celery
- discern | restart discern
- name: discern | git checkout ease repo into ease_dir
git: dest={{ease_dir}} repo={{ease_source_repo}} version={{ease_branch}}
sudo_user: "{{ discern_user }}"
notify:
- discern | restart celery
- discern | restart discern
#Numpy has to be a pre-requirement in order for scipy to build
- name : install python pre-requirements for discern and ease
pip: requirements="{{item}}/pre-requirements.txt" virtualenv="{{ discern_venv_dir }}" state=present
sudo_user: "{{ discern_user }}"
with_items:
- "{{ discern_pre_requirements_file }}"
- "{{ discern_ease_pre_requirements_file }}"
- name : install python requirements for discern and ease
pip: requirements="{{item}}/requirements.txt" virtualenv="{{ discern_venv_dir }}" state=present
sudo_user: "{{ discern_user }}"
with_items:
- "{{ discern_post_requirements_file }}"
- "{{ discern_ease_post_requirements_file }}"
- name: discern | install ease python package
shell: command="{{discern_venv_dir}}/bin/activate; cd {{ discern_ease_code_dir }}; python setup.py install"
#Needed for the ease package to work
- name: discern | install nltk data using rendered shell script
shell: command="{{ discern_venv_dir }}/bin/python -m nltk.downloader -d {{ discern_nltk_data_dir }} all"
sudo_user: "{{ discern_user }}"
#Run this instead of using the ansible module because the ansible module only support syncdb of these three, and does not
#support virtualenvs as of this comment
- name: discern | django syncdb, migrate, and collectstatic for discern
shell: "{{ discern_venv_dir }}/bin/python {{discern_code_dir}}/manage.py {{item}} --noinput --settings={{discern_settings}} --pythonpath={{discern_code_dir}}"
sudo_user: "{{ discern_user }}"
with_items:
- syncdb
- migrate
- collectstatic
#Have this separate from the other three because it doesn't take the noinput flag
- name: discern | django update_index for discern
shell: "{{ discern_venv_dir}}/bin/python {{discern_code_dir}}/manage.py update_index --settings={{discern_settings}} --pythonpath={{discern_code_dir}}"
sudo_user: "{{ discern_user }}"
---
- name: discern | create application user
user: >
name="{{ discern_user }}"
home="{{ discern_app_dir }}"
createhome=no
shell=/bin/false
- name: discern | create discern app and data dir
file: >
path="{{ item }}"
state=directory
owner="{{ discern_user }}"
group="{{ common_web_group }}"
with_items:
- "{{ discern_app_dir }}"
- "{{ discern_data_dir }}"
- name: discern | install debian packages that discern needs
apt: pkg={{ item }} state=present
with_items: discern_debian_pkgs
- name: discern | install debian packages for ease that discern needs
apt: pkg={{ item }} state=present
with_items: discern_ease_debian_pkgs
#Create the templates for upstart services
- name: discern | render celery service from template
template: src=celery.conf.j2 dest=/etc/init/celery.conf owner=root group=edx mode=0664
......@@ -8,104 +33,10 @@
template: src=discern.conf.j2 dest=/etc/init/discern.conf owner=root group=edx mode=0664
notify: discern | restart discern
#Allows us to recover from a bad sudoers file
- name: discern | Install policykit
apt: pkg=policykit-1 install_recommends=yes state=present update_cache=yes
#Discern user is admin
- name: discern | Create discern user
user: name={{ discern_user }} append=yes groups="adm,edx" shell=/bin/bash
- name: discern | upload sudoers template to /tmp/sudoers
copy: src=sudoers-discern dest=/tmp/{{site_name}} owner=root group=root mode=0440
#Verify file and move to sudoers.d folder
- name: discern | move temp file to sudoers.d
shell: visudo -q -c -f /tmp/{{site_name}} && cp /tmp/{{site_name}} /etc/sudoers.d/{{site_name}}
#Upload config files for django (auth and env)
- name: discern | create discern application config env.json file
template: src=env.json.j2 dest={{app_dir}}/env.json owner={{discern_user}} group=edx mode=0640
notify:
- discern | restart celery
- discern | restart discern
- name: discern | create discern auth file auth.json
template: src=auth.json.j2 dest={{app_dir}}/auth.json owner={{discern_user}} group=edx mode=0640
notify:
- discern | restart celery
- discern | restart discern
#Needed if using redis to prevent memory issues
- name: discern | change memory commit settings -- needed for redis
command: sysctl vm.overcommit_memory=1
- name: discern | set permissions on app_dir sgid for edx
file: path={{app_dir}} owner=root group=edx mode=2775 state=directory
file: path={{venv_dir}} owner=root group=edx mode=2775 state=directory
- name: discern | Install git so that we can clone repos
apt: pkg=git install_recommends=yes state=present
#Create directories for repos
- name: discern | create discern and ease directories and set permissions
file: path={{item}} owner={{discern_user}} group=edx mode=2775 state=directory
with_items:
- ${discern_dir}
- ${ease_dir}
#Grab both repos or update
- name: discern | git checkout discern repo into discern_dir
git: dest={{discern_dir}} repo={{discern_source_repo}} version={{discern_branch}}
notify:
- discern | restart celery
- discern | restart discern
- name: discern | git checkout ease repo into ease_dir
git: dest={{ease_dir}} repo={{ease_source_repo}} version={{ease_branch}}
notify:
- discern | restart celery
- discern | restart discern
#Install system packages
- name: discern | install discern and ease apt packages
command: xargs -a {{item}}/apt-packages.txt apt-get install -y
with_items:
- ${discern_dir}
- ${ease_dir}
#Numpy has to be a pre-requirement in order for scipy to build
- name : install python pre-requirements for discern and ease
pip: requirements="{{item}}/pre-requirements.txt" virtualenv="{{venv_dir}}" state=present
with_items:
- ${discern_dir}
- ${ease_dir}
- name : install python requirements for discern and ease
pip: requirements="{{item}}/requirements.txt" virtualenv="{{venv_dir}}" state=present
with_items:
- ${discern_dir}
- ${ease_dir}
- name: discern | 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: discern | install nltk data using rendered shell script
shell: command="{{venv_dir}}/bin/python -m nltk.downloader -d {{nltk_data_dir}} all"
- name: discern | set permissions on nltk data directory
file: path={{nltk_data_dir}} owner={{discern_user}} group=edx mode=2775 state=directory
#Run this instead of using the ansible module because the ansible module only support syncdb of these three, and does not
#support virtualenvs as of this comment
- name: discern | django syncdb, migrate, and collectstatic for discern
shell: ${venv_dir}/bin/python {{discern_dir}}/manage.py {{item}} --noinput --settings={{discern_settings}} --pythonpath={{discern_dir}}
with_items:
- syncdb
- migrate
- collectstatic
- name: discern | copy sudoers file for discern
copy: >
src=sudoers-discern
dest=/etc/sudoers.d/{{ site_name }}
validate='visudo -cf %s'
#Have this separate from the other three because it doesn't take the noinput flag
- name: discern | django update_index for discern
shell: ${venv_dir}/bin/python {{discern_dir}}/manage.py update_index --settings={{discern_settings}} --pythonpath={{discern_dir}}
- include: deploy.yml
......@@ -7,10 +7,8 @@ ora_app_dir: "{{ app_dir }}/ora"
ora_code_dir: "{{ ora_app_dir }}/ora"
ora_data_dir: "{{ data_dir }}/ora"
ora_venv_dir: "{{ venvs_dir }}/ora"
ora_ease_venv_dir: "{{ ora_venv_dir }}"
ora_venv_bin: "{{ ora_venv_dir }}/bin"
ora_user: "ora"
ora_ease_code_dir: "{{ app_dir }}/ease"
ora_nltk_data_dir: "{{ ora_data_dir}}/nltk_data"
ora_source_repo: https://github.com/edx/edx-ora.git
......@@ -18,10 +16,12 @@ ora_version: 'HEAD'
ora_pre_requirements_file: "{{ ora_code_dir }}/pre-requirements.txt"
ora_post_requirements_file: "{{ ora_code_dir }}/requirements.txt"
ora_ease_venv_dir: "{{ ora_venv_dir }}"
ora_ease_code_dir: "{{ app_dir }}/ease"
ora_ease_source_repo: https://github.com/edx/ease.git
ora_ease_version: 'HEAD'
ora_ease_pre_requirements_file: "{{ ease_code_dir }}/pre-requirements.txt"
ora_ease_post_requirements_file: "{{ ease_code_dir }}/requirements.txt"
ora_ease_pre_requirements_file: "{{ ora_ease_code_dir }}/pre-requirements.txt"
ora_ease_post_requirements_file: "{{ ora_ease_code_dir }}/requirements.txt"
# Default nginx listen port
......
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