Commit 93e13f69 by John Jarvis

updating ora role for refactor

parent f7ea2bb7
......@@ -3,14 +3,30 @@
ORA_NGINX_PORT: 18060
ORA_BASIC_AUTH: False
ora_code_dir: "{{ app_dir }}/edx-ora"
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"
ease_venv_dir: "{{ ora_venv_dir }}"
ora_venv_bin: "{{ ora_venv_dir }}/bin"
ora_user: "ora"
ease_code_dir: "{{ app_dir }}/ease"
nltk_data_dir: "{{ ora_data_dir}}/nltk_data"
ora_source_repo: https://github.com/edx/edx-ora.git
ora_version: 'HEAD'
ora_pre_requirements_file: "{{ ora_code_dir }}/pre-requirements.txt"
ora_post_requirements_file: "{{ ora_code_dir }}/requirements.txt"
ease_source_repo: https://github.com/edx/ease.git
ease_version: 'HEAD'
ease_pre_requirements_file: "{{ ease_code_dir }}/pre-requirements.txt"
ease_post_requirements_file: "{{ ease_code_dir }}/requirements.txt"
# Default nginx listen port
# These should be overrided if you want
# to serve all content on port 80
ora_user: "edx-ora"
ora_user_home: "/opt/edx-ora"
ora_venv_dir: "{{ ora_user_home }}/virtualenvs/{{ ora_user }}"
ease_venv_dir: "{{ ora_venv_dir }}"
ora_gunicorn_workers: 4
ora_gunicorn_port: 8060
ora_gunicorn_host: 127.0.0.1
......@@ -67,18 +83,6 @@ ora_auth_config:
'AWS_ACCESS_KEY_ID' : ''
'AWS_SECRET_ACCESS_KEY' : ''
ora_source_repo: https://github.com/edx/edx-ora.git
ora_version: 'HEAD'
ora_pre_requirements_file: "{{ ora_code_dir }}/pre-requirements.txt"
ora_post_requirements_file: "{{ ora_code_dir }}/requirements.txt"
ease_code_dir: "{{ app_dir }}/ease"
ease_source_repo: https://github.com/edx/ease.git
ease_version: 'HEAD'
ease_pre_requirements_file: "{{ ease_code_dir }}/pre-requirements.txt"
ease_post_requirements_file: "{{ ease_code_dir }}/requirements.txt"
nltk_data_dir: /usr/share/nltk_data
ora_debian_pkgs:
- python-software-properties
- pkg-config
......
- include: ease.yml
- name: ora | See if edx-ora.conf is installed
shell: "[ -f /etc/init/edx-ora.conf ] && echo 'Found' || echo ''"
register: edx_ora_installed
tags:
- ora
- deploy
- name: ora | See if edx-ora-celery.conf is installed
shell: "[ -f /etc/init/edx-ora-celery.conf ] && echo 'Found' || echo ''"
register: edx_ora_celery_installed
tags:
- ora
- deploy
# Stop ora service.
......@@ -18,7 +19,6 @@
when: edx_ora_installed.stdout == 'Found'
notify: ora | restart edx-ora
tags:
- ora
- deploy
- name: ora | stop edx-ora-celery service
......@@ -26,76 +26,62 @@
when: edx_ora_celery_installed.stdout == 'Found'
notify: ora | restart edx-ora-celery
tags:
- ora
- deploy
- name: ora | create ora application config
template: src=ora.env.json.j2 dest={{ora_code_dir}}/../ora.env.json mode=0640 owner={{ ora_user }} group=adm
template: src=ora.env.json.j2 dest={{ora_app_dir}}/ora.env.json
sudo_user: "{{ ora_user }}"
tags:
- ora
- deploy
- name: ora | create ora auth file
template: src=ora.auth.json.j2 dest={{ora_code_dir}}/../ora.auth.json mode=0640 owner={{ ora_user }} group=adm
template: src=ora.auth.json.j2 dest={{ora_app_dir}}/ora.auth.json
sudo_user: "{{ ora_user }}"
tags:
- ora
- deploy
- name: ora | create ora upstart script
template: src=edx-ora.conf.j2 dest=/etc/init/edx-ora.conf mode=0640 owner=root group=adm
template: src=edx-ora.conf.j2 dest=/etc/init/edx-ora.conf
tags:
- ora
- deploy
- name: ora | create ora-celery upstart script
template: src=edx-ora-celery.conf.j2 dest=/etc/init/edx-ora-celery.conf mode=0640 owner=root group=adm
template: src=edx-ora-celery.conf.j2 dest=/etc/init/edx-ora-celery.conf
tags:
- ora
- deploy
# Do A Checkout
- name: ora | git checkout ora repo into $app_dir
git: dest={{ora_code_dir}} repo={{ora_source_repo}} version={{ora_version}}
- name: ora | git checkout ora repo into {{ ora_app_dir }}
git: dest={{ ora_code_dir }} repo={{ ora_source_repo }} version={{ ora_version }}
sudo_user: "{{ ora_user }}"
notify:
- ora | restart edx-ora
- ora | restart edx-ora-celery
tags:
- ora
- deploy
# Do Post Checkout Tasks.
- name: ora | change permissions on ora code dir
file: path={{ora_code_dir}} state=directory owner={{ ora_user }} group={{ ora_user }} mode=755 recurse=yes
notify:
- ora | restart edx-ora
- ora | restart edx-ora-celery
tags:
- ora
- deploy
# TODO: Check git.py _run_if_changed() to see if the logic there to skip running certain
# portions of the deploy needs to be incorporated here.
# Install the python pre requirements into {{ ora_venv_dir }}
- name: ora | install python pre-requirements
pip: requirements="{{ora_pre_requirements_file}}" virtualenv="{{ora_venv_dir}}" state=present
pip: requirements="{{ ora_pre_requirements_file }}" virtualenv="{{ ora_venv_dir }}" state=present
sudo_user: "{{ ora_user }}"
notify:
- ora | restart edx-ora
- ora | restart edx-ora-celery
tags:
- ora
- deploy
# Install the python post requirements into {{ ora_venv_dir }}
- name: ora | install python post-requirements
pip: requirements="{{ora_post_requirements_file}}" virtualenv="{{ora_venv_dir}}" state=present
pip: requirements="{{ ora_post_requirements_file }}" virtualenv="{{ ora_venv_dir }}" state=present
sudo_user: "{{ ora_user }}"
notify:
- ora | restart edx-ora
- ora | restart edx-ora-celery
tags:
- ora
- deploy
#Needed if using redis to prevent memory issues
......@@ -105,26 +91,23 @@
- ora | restart edx-ora
- ora | restart edx-ora-celery
tags:
- ora
- deploy
- name: ora | syncdb and migrate
shell: sudo -u {{ ora_user }} SERVICE_VARIANT=ora {{ora_venv_dir}}/bin/django-admin.py syncdb --migrate --noinput --settings=edx_ora.aws --pythonpath={{ora_code_dir}}
shell: SERVICE_VARIANT=ora {{ora_venv_dir}}/bin/django-admin.py syncdb --migrate --noinput --settings=edx_ora.aws --pythonpath={{ora_code_dir}}
when: migrate_db is defined and migrate_db|lower == "yes"
sudo_user: "{{ ora_user }}"
notify:
- ora | restart edx-ora
- ora | restart edx-ora-celery
tags:
- ora
- syncdb
- deploy
- name: ora | create users
shell: sudo -u {{ ora_user }} SERVICE_VARIANT=ora {{ora_venv_dir}}/bin/django-admin.py update_users --settings=edx_ora.aws --pythonpath={{ora_code_dir}}
shell: SERVICE_VARIANT=ora {{ora_venv_dir}}/bin/django-admin.py update_users --settings=edx_ora.aws --pythonpath={{ora_code_dir}}
sudo_user: "{{ ora_user }}"
notify:
- ora | restart edx-ora
- ora | restart edx-ora-celery
tags:
- ora
- syncdb
- deploy
......@@ -2,14 +2,12 @@
shell: "[ -f /etc/init/edx-ora.conf ] && echo 'Found' || echo ''"
register: edx_ora_installed
tags:
- ora
- deploy
- name: ora | See if edx-ora-celery.conf is installed
shell: "[ -f /etc/init/edx-ora-celery.conf ] && echo 'Found' || echo ''"
register: edx_ora_celery_installed
tags:
- ora
- deploy
# Stop ora service.
......@@ -17,61 +15,47 @@
service: name=edx-ora state=stopped
when: edx_ora_installed.stdout == 'Found'
tags:
- ora
- deploy
- name: ora | stop edx-ora-celery service
service: name=edx-ora-celery state=stopped
when: edx_ora_celery_installed.stdout == 'Found'
tags:
- ora
- deploy
# Do A Checkout
- name: ora | git checkout ease repo into its base dir
git: dest={{ease_code_dir}} repo={{ease_source_repo}} version={{ease_version}}
sudo_user: "{{ ora_user }}"
tags:
- ease
- deploy
# Do Post Checkout Tasks.
- name: ora | change permissions on ease code dir
file: path={{ease_code_dir}} state=directory owner={{ ora_user }} group={{ ora_user }} mode=755 recurse=yes
tags:
- ease
- deploy
# TODO: Check git.py _run_if_changed() to see if the logic there to skip running certain
# portions of the deploy needs to be incorporated here.
#
- name: ora | install ease system packages
apt: pkg={{item}} state=present
with_items: ease_debian_pkgs
tags:
- ease
- deploy
# Install the python pre requirements into {{ ease_venv_dir }}
- name: ora | install ease python pre-requirements
pip: requirements="{{ease_pre_requirements_file}}" virtualenv="{{ease_venv_dir}}" state=present
sudo_user: "{{ ora_user }}"
tags:
- ease
- deploy
# Install the python post requirements into {{ ease_venv_dir }}
- name: ora | install ease python post-requirements
pip: requirements="{{ease_post_requirements_file}}" virtualenv="{{ease_venv_dir}}" state=present
sudo_user: "{{ ora_user }}"
tags:
- ease
- deploy
- name: ora | install ease python package
shell: command="{{ease_venv_dir}}/bin/activate; cd {{ease_code_dir}}; python setup.py install"
sudo_user: "{{ ora_user }}"
tags:
- ease
- deploy
#Needed for the ease package to work
......@@ -79,19 +63,12 @@
shell: "[ -f {{nltk_data_dir}}/taggers/maxent_treebank_pos_tagger/english.pickle ] && echo 'Found' || echo ''"
register: nltk_data_installed
tags:
- ease
- deploy
- name: ora | install nltk data using rendered shell script
command: "{{ease_venv_dir}}/bin/python -m nltk.downloader -d {{nltk_data_dir}} all"
when: nltk_data_installed.stdout != "Found"
sudo_user: "{{ ora_user }}"
tags:
- ease
- deploy
- name: ora | set permissions on nltk data directory
file: path={{nltk_data_dir}} owner=ubuntu group=adm mode=2775 state=directory
tags:
- ease
- deploy
......@@ -2,27 +2,27 @@
# - group_vars/all
# - common/tasks/main.yml
---
- name: ora | create the ora application user
user: name={{ ora_user }}
tags:
- ora
- name: ora | Create ml_models directory
file: path={{ora_code_dir}}/../ml_models state=directory owner={{ ora_user }} group={{ ora_user }}
tags:
- ora
- name: ora | create application user
user: >
name="{{ ora_user }}"
home="{{ ora_app_dir }}"
createhome=no
shell=/bin/false
# Check out ora repo to {{ora_code_dir}}
- name: ora | install git and its recommends
apt: pkg=git state=present install_recommends=yes
tags:
- ora
- name: ora | create ora app and data dir
file: >
path="{{ item }}"
state=directory
owner="{{ ora_user }}"
group="{{ common_web_group }}"
with_items:
- "{{ ora_app_dir }}"
- "{{ ora_data_dir }}"
- "{{ ora_app_dir }}/ml_models"
- name: ora | install debian packages that ora needs
apt: pkg={{item}} state=present
with_items: ora_debian_pkgs
tags:
- ora
- include: ease.yml
- include: deploy.yml
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