Commit 6e38a951 by Clinton Blackburn

Merge pull request #2313 from edx/clintonb/programs-base

Added configuration for programs service
parents 0cd877b0 7c49b8f8
......@@ -9,7 +9,8 @@
# and a key being provided via NEWRELIC_LICENSE_KEY
{{ role_name|upper }}_NEWRELIC_APPNAME: "{{ '{{ COMMON_ENVIRONMENT }}' }}-{{ '{{ COMMON_DEPLOYMENT }}' }}-{{ '{{' }} {{ role_name }}_service_name }}"
{{ role_name|upper }}_PIP_EXTRA_ARGS: "-i {{ '{{ COMMON_PYPI_MIRROR_URL }}' }}"
{{ role_name|upper }}_NGINX_PORT: XXX # TODO Change this!!!
{{ role_name|upper }}_NGINX_PORT: XXX # TODO Change this!!!
{{ role_name|upper }}_SSL_NGINX_PORT: XXX # TODO Change this!!!
{{ role_name|upper }}_DEFAULT_DB_NAME: '{{ role_name }}'
......@@ -27,6 +28,7 @@
{{ role_name|upper }}_VERSION: "master"
{{ role_name|upper }}_DJANGO_SETTINGS_MODULE: "{{ role_name }}.settings.production"
{{ role_name|upper }}_URL_ROOT: 'http://localhost:####' # TODO Set port number!
{{ role_name|upper }}_LMS_URL_ROOT: 'http://127.0.0.1:8000'
{{ role_name|upper }}_SECRET_KEY: 'Your secret key here'
......
......@@ -86,7 +86,7 @@
- name: create symlinks from the repo dir
file:
src: "{{ '{{' }} {{ role_name }}_code_dir }}/{{ item }}"
src: "{{ '{{' }} {{ role_name }}_code_dir }}/{{ '{{' }} item }}"
dest: "{{ '{{' }} COMMON_BIN_DIR }}/{{ '{{' }} item.split('.')[0] }}.{{ role_name }}"
state: link
with_items:
......
......@@ -15,5 +15,4 @@ export NEW_RELIC_LICENSE_KEY="{{ '{{' }} NEWRELIC_LICENSE_KEY }}"
{{ '{%' }} endif -%}
source {{ '{{' }} {{ role_name }}_home }}/{{ role_name }}_env
# TODO fix application
{{ '{{' }} executable }} -c {{ '{{' }} {{ role_name }}_home }}/{{ role_name }}_gunicorn.py {{ '{{' }} {{ role_name|upper }}_GUNICORN_EXTRA }} {{ role_name }}.wsgi:application
......@@ -15,5 +15,4 @@ export NEW_RELIC_LICENSE_KEY="{{ NEWRELIC_LICENSE_KEY }}"
{% endif -%}
source {{ ecommerce_home }}/ecommerce_env
# TODO fix application
{{ executable }} -c {{ ecommerce_home }}/ecommerce_gunicorn.py {{ ECOMMERCE_GUNICORN_EXTRA }} ecommerce.wsgi:application
......@@ -6,3 +6,44 @@ edxlocal_debian_pkgs:
- python-mysqldb
- postfix
- libjpeg-dev
edxlocal_databases:
- "{{ ECOMMERCE_DEFAULT_DB_NAME | default(None) }}"
- "{{ INSIGHTS_DEFAULT_DB_NAME | default(None) }}"
- "{{ ORA_MYSQL_DB_NAME | default(None) }}"
- "{{ XQUEUE_MYSQL_DB_NAME | default(None) }}"
- "{{ EDXAPP_MYSQL_DB_NAME | default(None) }}"
- "{{ EDX_NOTES_API_MYSQL_DB_NAME | default(None) }}"
- "{{ PROGRAMS_DEFAULT_DB_NAME | default(None) }}"
edxlocal_database_users:
- {
db: "{{ ECOMMERCE_DEFAULT_DB_NAME | default(None) }}",
user: "{{ ECOMMERCE_DATABASES.default.USER | default(None) }}",
pass: "{{ ECOMMERCE_DATABASES.default.PASSWORD | default(None) }}"
}
- {
db: "{{ INSIGHTS_DEFAULT_DB_NAME | default(None) }}",
user: "{{ INSIGHTS_DATABASES.default.USER | default(None) }}",
pass: "{{ INSIGHTS_DATABASES.default.PASSWORD | default(None) }}"
}
- {
db: "{{ ORA_MYSQL_DB_NAME | default(None) }}",
user: "{{ ORA_MYSQL_USER | default(None) }}",
pass: "{{ ORA_MYSQL_PASSWORD | default(None) }}"
}
- {
db: "{{ XQUEUE_MYSQL_DB_NAME | default(None) }}",
user: "{{ XQUEUE_MYSQL_USER | default(None) }}",
pass: "{{ XQUEUE_MYSQL_PASSWORD | default(None) }}"
}
- {
db: "{{ EDXAPP_MYSQL_DB_NAME | default(None) }}",
user: "{{ EDXAPP_MYSQL_USER | default(None) }}",
pass: "{{ EDXAPP_MYSQL_PASSWORD | default(None) }}"
}
- {
db: "{{ PROGRAMS_DEFAULT_DB_NAME | default(None) }}",
user: "{{ PROGRAMS_DATABASES.default.USER | default(None) }}",
pass: "{{ PROGRAMS_DATABASES.default.PASSWORD | default(None) }}"
}
......@@ -43,47 +43,30 @@
- name: install packages needed for single server
apt: pkg={{','.join(edxlocal_debian_pkgs)}} install_recommends=yes state=present
- name: setup the edxapp db user
mysql_user: >
name={{ EDXAPP_MYSQL_USER }}
password={{ EDXAPP_MYSQL_PASSWORD }}
priv='{{ EDXAPP_MYSQL_DB_NAME }}.*:ALL'
when: EDXAPP_MYSQL_USER is defined
- name: create a database for edxapp
mysql_db: >
db=edxapp
state=present
encoding=utf8
when: EDXAPP_MYSQL_USER is defined
- name: setup the xqueue db user
mysql_user: >
name={{ XQUEUE_MYSQL_USER }}
password={{ XQUEUE_MYSQL_PASSWORD }}
priv='{{ XQUEUE_MYSQL_DB_NAME }}.*:ALL'
when: XQUEUE_MYSQL_USER is defined
- name: create a database for xqueue
mysql_db: >
db=xqueue
state=present
encoding=utf8
when: XQUEUE_MYSQL_USER is defined
- name: setup the ora db user
mysql_user: >
name={{ ORA_MYSQL_USER }}
password={{ ORA_MYSQL_PASSWORD }}
priv='{{ ORA_MYSQL_DB_NAME }}.*:ALL'
when: ORA_MYSQL_USER is defined
- name: create databases
mysql_db:
db: "{{ item }}"
state: present
encoding: utf8
when: item != None and item != ''
with_items: "{{ edxlocal_databases }}"
- name: create database users
mysql_user:
name: "{{ item.user }}"
password: "{{ item.pass }}"
priv: "{{ item.db }}.*:ALL"
when: item.db != None and item.db != ''
with_items: "{{ edxlocal_database_users }}"
- name: create a database for ora
mysql_db: >
db=ora
state=present
encoding=utf8
when: ORA_MYSQL_USER is defined
- name: setup the migration db user
mysql_user:
name: "{{ COMMON_MYSQL_MIGRATE_USER }}"
password: "{{ COMMON_MYSQL_MIGRATE_PASS }}"
priv: "{{ item }}.*:ALL"
append_privs: yes
when: item != None and item != ''
with_items: "{{ edxlocal_databases }}"
- name: create databases for analytics api
mysql_db: >
......@@ -95,34 +78,6 @@
- "{{ ANALYTICS_API_SERVICE_CONFIG['DATABASES']['default']['NAME'] }}"
- "{{ ANALYTICS_API_SERVICE_CONFIG['DATABASES']['reports']['NAME'] }}"
- name: create database for insights
mysql_db: >
db={{ INSIGHTS_DATABASES.default.NAME }}
state=present
encoding=utf8
when: INSIGHTS_DATABASES is defined
- name: create database user for insights
mysql_user: >
name="{{ INSIGHTS_DATABASES.default.USER }}"
password="{{ INSIGHTS_DATABASES.default.PASSWORD }}"
priv='{{ INSIGHTS_DATABASES.default.NAME }}.*:ALL'
when: INSIGHTS_DATABASES is defined
- name: create database for ecommerce
mysql_db: >
db="{{ ECOMMERCE_DEFAULT_DB_NAME }}"
state=present
encoding=utf8
when: ECOMMERCE_DEFAULT_DB_NAME is defined
- name: setup users for ecommerce
mysql_user: >
name="{{ ECOMMERCE_DATABASES.default.USER }}"
password="{{ ECOMMERCE_DATABASES.default.PASSWORD }}"
priv='{{ ECOMMERCE_DEFAULT_DB_NAME }}.*:ALL'
when: ECOMMERCE_DEFAULT_DB_NAME is defined
- name: create api user for the analytics api
mysql_user: >
name=api001
......@@ -151,13 +106,6 @@
encoding=latin1
when: HIVE_METASTORE_DATABASE is defined
- name: setup the edxapp db user
mysql_user: >
name={{ HIVE_METASTORE_DATABASE.user }}
password={{ HIVE_METASTORE_DATABASE.password }}
priv='{{ HIVE_METASTORE_DATABASE.name }}.*:ALL'
when: HIVE_METASTORE_DATABASE is defined
- name: setup the edx-notes-api db user
mysql_user: >
name={{ EDX_NOTES_API_MYSQL_DB_USER }}
......@@ -165,29 +113,6 @@
priv='{{ EDX_NOTES_API_MYSQL_DB_NAME }}.*:SELECT,INSERT,UPDATE,DELETE'
when: EDX_NOTES_API_MYSQL_DB_USER is defined
- name: create a database for edx-notes-api
mysql_db: >
db={{ EDX_NOTES_API_MYSQL_DB_NAME }}
state=present
encoding=utf8
when: EDX_NOTES_API_MYSQL_DB_USER is defined
- name: setup the migration db user
mysql_user: >
name={{ COMMON_MYSQL_MIGRATE_USER }}
password={{ COMMON_MYSQL_MIGRATE_PASS }}
priv='{{ item }}.*:ALL'
append_privs=yes
when: item != 'None'
with_items:
- "{{ EDXAPP_MYSQL_DB_NAME|default('None') }}"
- "{{ XQUEUE_MYSQL_DB_NAME|default('None') }}"
- "{{ ORA_MYSQL_DB_NAME|default('None') }}"
- "{{ EDX_NOTES_API_MYSQL_DB_NAME|default('None') }}"
- "{{ ANALYTICS_API_DEFAULT_DB_NAME|default('None') }}"
- "{{ ANALYTICS_API_REPORTS_DB_NAME|default('None') }}"
- "{{ INSIGHTS_DATABASE_NAME|default('None') }}"
- "{{ ECOMMERCE_DEFAULT_DB_NAME|default('None') }}"
- name: setup the read-only db user
mysql_user: >
......
......@@ -6,26 +6,61 @@ localdev_xauthority: "{{ localdev_home }}/.Xauthority"
localdev_xvfb_display: ":1"
localdev_accounts:
- { user: "{{ edxapp_user|default('None') }}", home: "{{ edxapp_app_dir }}",
env: "edxapp_env", repo: "edx-platform" }
- {
user: "{{ edxapp_user|default('None') }}",
home: "{{ edxapp_app_dir }}",
env: "edxapp_env",
repo: "edx-platform"
}
- { user: "{{ forum_user|default('None') }}", home: "{{ forum_app_dir }}",
env: "forum_env", repo: "cs_comments_service" }
- {
user: "{{ forum_user|default('None') }}",
home: "{{ forum_app_dir }}",
env: "forum_env",
repo: "cs_comments_service"
}
- { user: "{{ ora_user|default('None') }}", home: "{{ ora_app_dir }}",
env: "ora_env", repo: "ora" }
- {
user: "{{ ora_user|default('None') }}",
home: "{{ ora_app_dir }}",
env: "ora_env",
repo: "ora"
}
- { user: "{{ notifier_user|default('None') }}", home: "{{ notifier_app_dir }}",
env: "notifier_env", repo: "" }
- {
user: "{{ notifier_user|default('None') }}",
home: "{{ notifier_app_dir }}",
env: "notifier_env",
repo: ""
}
- { user: "{{ ecommerce_user|default('None') }}", home: "{{ ecommerce_home }}",
env: "ecommerce_env", repo: "ecommerce" }
- {
user: "{{ ecommerce_user|default('None') }}",
home: "{{ ecommerce_home }}",
env: "ecommerce_env",
repo: "ecommerce"
}
- { user: "{{ analytics_api_user|default('None') }}", home: "{{ analytics_api_home }}",
env: "analytics_api_env", repo: "analytics_api" }
- {
user: "{{ analytics_api_user|default('None') }}",
home: "{{ analytics_api_home }}",
env: "analytics_api_env",
repo: "analytics_api"
}
- { user: "{{ insights_user|default('None') }}", home: "{{ insights_home }}",
env: "insights_env", repo: "edx_analytics_dashboard" }
- {
user: "{{ insights_user|default('None') }}",
home: "{{ insights_home }}",
env: "insights_env",
repo: "edx_analytics_dashboard"
}
- {
user: "{{ programs_user|default('None') }}",
home: "{{ programs_home }}",
env: "programs_env",
repo: "programs"
}
# Helpful system packages for local dev
local_dev_pkgs:
......
......@@ -71,6 +71,7 @@ NGINX_EDXAPP_ERROR_PAGES:
CMS_HOSTNAME: '~^((stage|prod)-)?studio.*'
ECOMMERCE_HOSTNAME: '~^((stage|prod)-)?ecommerce.*'
PROGRAMS_HOSTNAME: '~^((stage|prod)-)?programs.*'
nginx_template_dir: "edx/app/nginx/sites-available"
......@@ -96,6 +97,8 @@ nginx_edx_notes_api_gunicorn_hosts:
- 127.0.0.1
nginx_ecommerce_gunicorn_hosts:
- 127.0.0.1
nginx_programs_gunicorn_hosts:
- 127.0.0.1
nginx_cfg:
# - link - turn on
......
#
# {{ ansible_managed }}
#
{% if "programs" in nginx_default_sites %}
{% set default_site = "default" %}
{% else %}
{% set default_site = "" %}
{% endif %}
upstream programs_app_server {
{% for host in nginx_programs_gunicorn_hosts %}
server {{ host }}:{{ programs_gunicorn_port }} fail_timeout=0;
{% endfor %}
}
server {
server_name {{ PROGRAMS_HOSTNAME }};
{% if NGINX_ENABLE_SSL %}
listen {{ PROGRAMS_NGINX_PORT }} {{ default_site }};
listen {{ PROGRAMS_SSL_NGINX_PORT }} ssl;
ssl_certificate /etc/ssl/certs/{{ NGINX_SSL_CERTIFICATE|basename }};
ssl_certificate_key /etc/ssl/private/{{ NGINX_SSL_KEY|basename }};
# request the browser to use SSL for all connections
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
{% else %}
listen {{ PROGRAMS_NGINX_PORT }} {{ default_site }};
{% endif %}
location ~ ^/static/(?P<file>.*) {
root {{ COMMON_DATA_DIR }}/{{ programs_service_name }};
try_files /staticfiles/$file =404;
}
location / {
try_files $uri @proxy_to_app;
}
{% include "robots.j2" %}
location @proxy_to_app {
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
proxy_set_header X-Forwarded-Port $http_x_forwarded_port;
proxy_set_header X-Forwarded-For $http_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://programs_app_server;
}
}
......@@ -17,10 +17,24 @@
oauth_client_setup_role_name: oauth_client_setup
oauth_client_setup_oauth2_clients:
- { name: "{{ ecommerce_service_name | default('None') }}", url_root: "{{ ECOMMERCE_ECOMMERCE_URL_ROOT }}",
id: "{{ ECOMMERCE_SOCIAL_AUTH_EDX_OIDC_KEY }}", secret: "{{ ECOMMERCE_SOCIAL_AUTH_EDX_OIDC_SECRET }}" }
- { name: "{{ INSIGHTS_OAUTH2_APP_CLIENT_NAME | default('None') }}", url_root: "{{ INSIGHTS_BASE_URL }}",
id: "{{ INSIGHTS_OAUTH2_KEY }}", secret: "{{ INSIGHTS_OAUTH2_SECRET }}" }
- {
name: "{{ ecommerce_service_name | default('None') }}",
url_root: "{{ ECOMMERCE_ECOMMERCE_URL_ROOT }}",
id: "{{ ECOMMERCE_SOCIAL_AUTH_EDX_OIDC_KEY }}",
secret: "{{ ECOMMERCE_SOCIAL_AUTH_EDX_OIDC_SECRET }}"
}
- {
name: "{{ INSIGHTS_OAUTH2_APP_CLIENT_NAME | default('None') }}",
url_root: "{{ INSIGHTS_BASE_URL }}",
id: "{{ INSIGHTS_OAUTH2_KEY }}",
secret: "{{ INSIGHTS_OAUTH2_SECRET }}"
}
- {
name: "{{ PROGRAMS_OAUTH2_APP_CLIENT_NAME | default('None') }}",
url_root: "{{ PROGRAMS_URL_ROOT }}",
id: "{{ PROGRAMS_SOCIAL_AUTH_EDX_OIDC_KEY }}",
secret: "{{ PROGRAMS_SOCIAL_AUTH_EDX_OIDC_SECRET }}"
}
#
# OS packages
......
---
#
# 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
#
##
# Defaults for role programs
#
PROGRAMS_GIT_IDENTITY: !!null
# depends upon Newrelic being enabled via COMMON_ENABLE_NEWRELIC
# and a key being provided via NEWRELIC_LICENSE_KEY
PROGRAMS_NEWRELIC_APPNAME: "{{ COMMON_ENVIRONMENT }}-{{ COMMON_DEPLOYMENT }}-{{ programs_service_name }}"
PROGRAMS_PIP_EXTRA_ARGS: "-i {{ COMMON_PYPI_MIRROR_URL }}"
PROGRAMS_NGINX_PORT: 18140
PROGRAMS_SSL_NGINX_PORT: 48140
PROGRAMS_DEFAULT_DB_NAME: 'programs'
PROGRAMS_DATABASES:
# rw user
default:
ENGINE: 'django.db.backends.mysql'
NAME: '{{ PROGRAMS_DEFAULT_DB_NAME }}'
USER: 'programs001'
PASSWORD: 'password'
HOST: 'localhost'
PORT: '3306'
ATOMIC_REQUESTS: true
CONN_MAX_AGE: 60
PROGRAMS_VERSION: "master"
PROGRAMS_DJANGO_SETTINGS_MODULE: "programs.settings.production"
PROGRAMS_URL_ROOT: 'http://localhost:8004'
PROGRAMS_LMS_URL_ROOT: 'http://127.0.0.1:8000'
PROGRAMS_SECRET_KEY: 'Your secret key here'
PROGRAMS_TIME_ZONE: 'UTC'
PROGRAMS_LANGUAGE_CODE: 'en-us'
# Used to automatically configure OAuth2 Client
PROGRAMS_SOCIAL_AUTH_EDX_OIDC_KEY : 'some-secret'
PROGRAMS_SOCIAL_AUTH_EDX_OIDC_SECRET : 'some-secret'
PROGRAMS_SOCIAL_AUTH_REDIRECT_IS_HTTPS: false
PROGRAMS_PLATFORM_NAME: 'Your Platform Name Here'
PROGRAMS_SERVICE_CONFIG:
SECRET_KEY: '{{ PROGRAMS_SECRET_KEY }}'
TIME_ZONE: '{{ PROGRAMS_TIME_ZONE }}'
LANGUAGE_CODE: '{{ PROGRAMS_LANGUAGE_CODE }}'
SOCIAL_AUTH_EDX_OIDC_KEY: '{{ PROGRAMS_SOCIAL_AUTH_EDX_OIDC_KEY }}'
SOCIAL_AUTH_EDX_OIDC_SECRET: '{{ PROGRAMS_SOCIAL_AUTH_EDX_OIDC_SECRET }}'
SOCIAL_AUTH_EDX_OIDC_ID_TOKEN_DECRYPTION_KEY: '{{ PROGRAMS_SOCIAL_AUTH_EDX_OIDC_SECRET }}'
SOCIAL_AUTH_EDX_OIDC_URL_ROOT: '{{ PROGRAMS_LMS_URL_ROOT }}/oauth2'
SOCIAL_AUTH_REDIRECT_IS_HTTPS: '{{ PROGRAMS_SOCIAL_AUTH_REDIRECT_IS_HTTPS }}'
STATIC_ROOT: "{{ COMMON_DATA_DIR }}/{{ programs_service_name }}/staticfiles"
# db config
DATABASE_OPTIONS:
connect_timeout: 10
DATABASES: '{{ PROGRAMS_DATABASES }}'
PLATFORM_NAME: '{{ PROGRAMS_PLATFORM_NAME }}'
PROGRAMS_REPOS:
- PROTOCOL: "{{ COMMON_GIT_PROTOCOL }}"
DOMAIN: "{{ COMMON_GIT_MIRROR }}"
PATH: "{{ COMMON_GIT_PATH }}"
REPO: programs.git
VERSION: "{{ PROGRAMS_VERSION }}"
DESTINATION: "{{ programs_code_dir }}"
SSH_KEY: "{{ PROGRAMS_GIT_IDENTITY }}"
PROGRAMS_GUNICORN_WORKERS: "2"
PROGRAMS_GUNICORN_EXTRA: ""
PROGRAMS_GUNICORN_EXTRA_CONF: ""
PROGRAMS_GUNICORN_WORKER_CLASS: "gevent"
#
# vars are namespace with the module name.
#
programs_role_name: programs
programs_venv_dir: "{{ programs_home }}/venvs/{{ programs_service_name }}"
programs_environment:
DJANGO_SETTINGS_MODULE: "{{ PROGRAMS_DJANGO_SETTINGS_MODULE }}"
PROGRAMS_CFG: "{{ COMMON_CFG_DIR }}/{{ programs_service_name }}.yml"
PATH: "{{ programs_venv_dir }}/bin:${PATH}"
programs_service_name: "programs"
programs_user: "{{ programs_service_name }}"
programs_home: "{{ COMMON_APP_DIR }}/{{ programs_service_name }}"
programs_code_dir: "{{ programs_home }}/{{ programs_service_name }}"
programs_gunicorn_host: "127.0.0.1"
programs_gunicorn_port: 8140
programs_gunicorn_timeout: 300
programs_log_dir: "{{ COMMON_LOG_DIR }}/{{ programs_service_name }}"
programs_requirements_base: "{{ programs_code_dir }}/requirements"
programs_requirements:
- production.txt
#
# OS packages
#
programs_debian_pkgs:
- libmysqlclient-dev
- libssl-dev
programs_redhat_pkgs: []
---
#
# 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
#
##
# Role includes for role programs
#
# Example:
#
# dependencies:
# - {
# role: my_role
# my_role_var0: "foo"
# my_role_var1: "bar"
# }
dependencies:
- role: edx_service
edx_service_name: "{{ programs_service_name }}"
edx_service_config: "{{ PROGRAMS_SERVICE_CONFIG }}"
edx_service_repos: "{{ PROGRAMS_REPOS }}"
edx_service_user: "{{ programs_user }}"
edx_service_home: "{{ programs_home }}"
edx_service_packages:
debian: "{{ programs_debian_pkgs }}"
redhat: "{{ programs_redhat_pkgs }}"
- supervisor
---
#
# 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 programs
#
# Overview:
#
#
# Dependencies:
#
#
# Example play:
#
#
- name: add gunicorn configuration file
template:
src: edx/app/programs/programs_gunicorn.py.j2
dest: "{{ programs_home }}/programs_gunicorn.py"
sudo_user: "{{ programs_user }}"
- name: install application requirements
pip:
requirements: "{{ programs_requirements_base }}/{{ item }}"
virtualenv: "{{ programs_venv_dir }}"
state: present
sudo_user: "{{ programs_user }}"
with_items: "{{ programs_requirements }}"
- name: migrate
shell: >
chdir={{ programs_code_dir }}
DB_MIGRATION_USER={{ COMMON_MYSQL_MIGRATE_USER }}
DB_MIGRATION_PASS={{ COMMON_MYSQL_MIGRATE_PASS }}
{{ programs_venv_dir }}/bin/python ./manage.py migrate --noinput
sudo_user: "{{ programs_user }}"
environment: "{{ programs_environment }}"
when: migrate_db is defined and migrate_db|lower == "yes"
- name: write out the supervisor wrapper
template:
src: "edx/app/programs/programs.sh.j2"
dest: "{{ programs_home }}/{{ programs_service_name }}.sh"
mode: 0650
owner: "{{ supervisor_user }}"
group: "{{ common_web_user }}"
- name: write supervisord config
template:
src: "edx/app/supervisor/conf.d.available/programs.conf.j2"
dest: "{{ supervisor_available_dir }}/{{ programs_service_name }}.conf"
owner: "{{ supervisor_user }}"
group: "{{ common_web_user }}"
mode: 0644
- name: setup the programs env file
template:
src: "./{{ programs_home }}/{{ programs_service_name }}_env.j2"
dest: "{{ programs_home }}/programs_env"
owner: "{{ programs_user }}"
group: "{{ programs_user }}"
mode: 0644
- name: enable supervisor script
file:
src: "{{ supervisor_available_dir }}/{{ programs_service_name }}.conf"
dest: "{{ supervisor_cfg_dir }}/{{ programs_service_name }}.conf"
state: link
force: yes
when: not disable_edx_services
- name: update supervisor configuration
shell: "{{ supervisor_ctl }} -c {{ supervisor_cfg }} update"
when: not disable_edx_services
- name: create symlinks from the venv bin dir
file:
src: "{{ programs_venv_dir }}/bin/{{ item }}"
dest: "{{ COMMON_BIN_DIR }}/{{ item.split('.')[0] }}.programs"
state: link
with_items:
- python
- pip
- django-admin.py
- name: create symlinks from the repo dir
file:
src: "{{ programs_code_dir }}/{{ item }}"
dest: "{{ COMMON_BIN_DIR }}/{{ item.split('.')[0] }}.programs"
state: link
with_items:
- manage.py
- name: restart the application
supervisorctl:
state: restarted
supervisorctl_path: "{{ supervisor_ctl }}"
config: "{{ supervisor_cfg }}"
name: "{{ programs_service_name }}"
when: not disable_edx_services
sudo_user: "{{ supervisor_service_user }}"
#!/usr/bin/env bash
# {{ ansible_managed }}
{% set programs_venv_bin = programs_home + "/venvs/" + programs_service_name + "/bin" %}
{% if COMMON_ENABLE_NEWRELIC_APP %}
{% set executable = programs_venv_bin + '/newrelic-admin run-program ' + programs_venv_bin + '/gunicorn' %}
{% else %}
{% set executable = programs_venv_bin + '/gunicorn' %}
{% endif %}
{% if COMMON_ENABLE_NEWRELIC_APP %}
export NEW_RELIC_APP_NAME="{{ PROGRAMS_NEWRELIC_APPNAME }}"
export NEW_RELIC_LICENSE_KEY="{{ NEWRELIC_LICENSE_KEY }}"
{% endif -%}
source {{ programs_home }}/programs_env
{{ executable }} -c {{ programs_home }}/programs_gunicorn.py {{ PROGRAMS_GUNICORN_EXTRA }} programs.wsgi:application
# {{ ansible_managed }}
{% for name,value in programs_environment.items() -%}
{%- if value -%}
export {{ name }}="{{ value }}"
{% endif %}
{%- endfor %}
"""
gunicorn configuration file: http://docs.gunicorn.org/en/develop/configure.html
{{ ansible_managed }}
"""
timeout = {{ programs_gunicorn_timeout }}
bind = "{{ programs_gunicorn_host }}:{{ programs_gunicorn_port }}"
pythonpath = "{{ programs_code_dir }}"
workers = {{ PROGRAMS_GUNICORN_WORKERS }}
worker_class = "{{ PROGRAMS_GUNICORN_WORKER_CLASS }}"
{{ PROGRAMS_GUNICORN_EXTRA_CONF }}
#
# {{ ansible_managed }}
#
[program:{{ programs_service_name }}]
command={{ programs_home }}/{{ programs_service_name }}.sh
user={{ common_web_user }}
directory={{ programs_code_dir }}
stdout_logfile={{ supervisor_log_dir }}/%(program_name)s-stdout.log
stderr_logfile={{ supervisor_log_dir }}/%(program_name)s-stderr.log
killasgroup=true
stopasgroup=true
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