Commit 6388e042 by John Jarvis

Merge branch 'master' into jarv/termination-support

parents 6fba64ba 3269926c
---
- hosts: tag_aws_cloudformation_stack-name_feanilpractice:&tag_group_edxapp - hosts: tag_aws_cloudformation_stack-name_feanilpractice:&tag_group_edxapp
sudo: True sudo: True
vars_files: vars_files:
...@@ -7,3 +8,13 @@ ...@@ -7,3 +8,13 @@
- common - common
- nginx - nginx
- edxapp - edxapp
- hosts: tag_aws_cloudformation_stack-name_feanilpractice:&tag_group_xserver
sudo: True
vars_files:
- "{{ secure_dir }}/vars/edxapp_continuous_integration_vars.yml"
- "{{ secure_dir }}/vars/users.yml"
roles:
- common
- nginx
- xserver
# this gets all running prod webservers
#- hosts: tag_environment_prod:&tag_function_webserver #- hosts: tag_environment_prod:&tag_function_webserver
# or we can get subsets of them by name
- hosts: ~tag_Name_app(10|20)_prod - hosts: ~tag_Name_app(10|20)_prod
#- hosts: tag_environment_prod:&tag_function_webserver #- hosts: ~tag_Name_app(11|21)_prod
## these are cold hosts:
#- hosts: ~tag_Name_app(12|22)_prod
## this is the test box
#- hosts: ~tag_Name_app4_prod
## you can also do security group, but don't do that
#- hosts: security_group_edx-prod-EdxappServerSecurityGroup-NSKCQTMZIPQB #- hosts: security_group_edx-prod-EdxappServerSecurityGroup-NSKCQTMZIPQB
sudo: True sudo: True
vars_files:
- "{{ secure_dir }}/vars/edxapp_prod_vars.yml"
- "{{ secure_dir }}/vars/users.yml"
- "{{ secure_dir }}/vars/edxapp_prod_users.yml"
vars: vars:
secure_dir: '../../../configuration-secure/ansible' secure_dir: '../../../configuration-secure/ansible'
# this indicates the path to site-specific (with precedence) # this indicates the path to site-specific (with precedence)
# things like nginx template files # things like nginx template files
local_dir: '../../../configuration-secure/ansible/local' local_dir: '../../../configuration-secure/ansible/local'
vars_files:
- "{{ secure_dir }}/vars/edxapp_prod_vars.yml"
- "{{ secure_dir }}/vars/users.yml"
- "{{ secure_dir }}/vars/edxapp_prod_users.yml"
- "{{ secure_dir }}/vars/shib_prod_vars.yml"
roles: roles:
- common - common
- nginx - nginx
- edxapp - edxapp
- apache
- shibboleth
# run this role last # run this role last
- in_production - in_production
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
- "{{ secure_dir }}/vars/users.yml" - "{{ secure_dir }}/vars/users.yml"
- "{{ secure_dir }}/vars/edxapp_prod_users.yml" - "{{ secure_dir }}/vars/edxapp_prod_users.yml"
- "{{ secure_dir }}/vars/shib_prod_vars.yml" - "{{ secure_dir }}/vars/shib_prod_vars.yml"
vars: vars:
secure_dir: '../../../configuration-secure/ansible' secure_dir: '../../../configuration-secure/ansible'
# this indicates the path to site-specific (with precedence) # this indicates the path to site-specific (with precedence)
......
- hosts: tag_environment_stage:&tag_function_webserver
sudo: True
vars:
secure_dir: ../../../edx-secret/ansible
local_dir: ../../../edx-secret/ansible/local
vars_files:
- "{{ secure_dir }}/vars/edxapp_stage_vars.yml"
- "{{ secure_dir }}/vars/users.yml"
- "{{ secure_dir }}/vars/edxapp_stage_users.yml"
roles:
- common
- nginx
# - gunicorn
- edxapp
#- in_production
- hosts: tag_Name_jumpbox_prod
sudo: True
vars_files:
- "{{ secure_dir }}/vars/users.yml"
vars:
secure_dir: '../../../configuration-secure/ansible'
# this indicates the path to site-specific (with precedence)
# things like nginx template files
local_dir: '../../../configuration-secure/ansible/local'
roles:
- common
\ No newline at end of file
# ansible reads $ANSIBLE_CONFIG, ansible.cfg, ~/.ansible.cfg or /etc/ansible/ansible.cfg
[defaults]
# Always have these for using the configuration repo
jinja2_extensions=jinja2.ext.do
hash_behaviour=merge
# These are environment-specific defaults
forks=10
#forks=1
log_path=stage-edx-ansible.log
transport=ssh
hostfile=./ec2.py
extra_vars='key=deployment name=edx-stage group=edx-stage region=us-west-1'
user=ubuntu
[ssh_connection]
# example from https://github.com/ansible/ansible/blob/devel/examples/ansible.cfg
#ssh_args=-o ControlMaster=auto -o ControlPersist=60s -o ControlPath=/tmp/ansible-ssh-%h-%p-%r
ssh_args=-F stage-ssh-config
scp_if_ssh=True
#### edx-stage VPC
Host 54.241.183.3
#Host vpc-jumpbox
HostName 54.241.183.3
User ubuntu
ForwardAgent yes
Host *.us-west-1.compute.internal
User ubuntu
ForwardAgent yes
ProxyCommand ssh -W %h:%p ubuntu@54.241.183.3
Host *
ForwardAgent yes
SendEnv LANG LC_*
HashKnownHosts yes
GSSAPIAuthentication yes
GSSAPIDelegateCredentials no
# this gets all running prod webservers
- hosts: tag_environment_prod:&tag_function_xqueue
# or we can get subsets of them by name
#- hosts: ~tag_Name_xserver(1|2)_prod
#- hosts: security_group_edx-prod-EdxappServerSecurityGroup-NSKCQTMZIPQB
sudo: True
vars:
secure_dir: '../../../configuration-secure/ansible'
# this indicates the path to site-specific (with precedence)
# things like nginx template files
local_dir: '../../../configuration-secure/ansible/local'
vars_files:
- "{{ secure_dir }}/vars/edxapp_prod_vars.yml"
- "{{ secure_dir }}/vars/users.yml"
- "{{ secure_dir }}/vars/edxapp_prod_users.yml"
roles:
- common
- nginx
- xqueue
# this gets all running prod webservers
- hosts: tag_environment_prod:&tag_function_xserver
# or we can get subsets of them by name
#- hosts: ~tag_Name_xserver(1|2)_prod
#- hosts: security_group_edx-prod-EdxappServerSecurityGroup-NSKCQTMZIPQB
sudo: True
vars:
secure_dir: '../../../configuration-secure/ansible'
# this indicates the path to site-specific (with precedence)
# things like nginx template files
local_dir: '../../../configuration-secure/ansible/local'
vars_files:
- "{{ secure_dir }}/vars/edxapp_prod_vars.yml"
- "{{ secure_dir }}/vars/users.yml"
- "{{ secure_dir }}/vars/edxapp_prod_users.yml"
roles:
- common
- nginx
- xserver
...@@ -15,9 +15,9 @@ WSGIRestrictEmbedded On ...@@ -15,9 +15,9 @@ WSGIRestrictEmbedded On
SetEnv SERVICE_VARIANT lms SetEnv SERVICE_VARIANT lms
WSGIScriptAlias / {{platform_code_dir}}/lms/wsgi_apache_lms.py WSGIScriptAlias / {{edx_platform_code_dir}}/lms/wsgi_apache_lms.py
<Directory {{platform_code_dir}}/lms> <Directory {{edx_platform_code_dir}}/lms>
<Files wsgi_apache_lms.py> <Files wsgi_apache_lms.py>
Order deny,allow Order deny,allow
Allow from all Allow from all
...@@ -39,7 +39,7 @@ WSGIRestrictEmbedded On ...@@ -39,7 +39,7 @@ WSGIRestrictEmbedded On
require valid-user require valid-user
</Location> </Location>
WSGIDaemonProcess lms user=www-data group=adm processes=1 python-path={{platform_code_dir}}:{{venv_dir}}/lib/python2.7/site-packages display-name=%{GROUP} WSGIDaemonProcess lms user=www-data group=adm processes=1 python-path={{edx_platform_code_dir}}:{{venv_dir}}/lib/python2.7/site-packages display-name=%{GROUP}
WSGIProcessGroup lms WSGIProcessGroup lms
WSGIApplicationGroup %{GLOBAL} WSGIApplicationGroup %{GLOBAL}
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
- update - update
- name: Creating env users - name: Creating env users
user: name={{ item.user }} groups={{ ",".join(item.groups) }} shell=/bin/bash user: name={{ item.user }} {% if item.groups %}groups={{ ",".join(item.groups) }}{% endif %} shell=/bin/bash
with_items: env_users with_items: env_users
when: env_users is defined when: env_users is defined
tags: tags:
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
- rsyslog - rsyslog
- screen - screen
- tree - tree
- git
tags: tags:
- pre_install - pre_install
- update - update
...@@ -77,6 +78,24 @@ ...@@ -77,6 +78,24 @@
- logging - logging
- update - update
# Install ssh keys for ubuntu account to be able to check out from edx-platform
# Temprory behavior, not needed after June 1. Perhaps still useful as a recipe.
# {{ secure_dir }} is relative to the top-level playbooks dir so there is some
- name: install read-only ssh key for edx-platform repo (private)
copy: src={{ secure_dir }}/files/git-identity dest=/etc/git-identity force=yes owner=ubuntu group=adm mode=600
tags:
- lms
- cms
- update
- name: upload ssh script
copy: src=git_ssh.sh dest=/tmp/git_ssh.sh force=yes owner=root group=adm mode=750
tags:
- lms
- cms
- update
- include: create_venv.yml - include: create_venv.yml
- include: edx_logging_base.yml - include: edx_logging_base.yml
......
...@@ -50,7 +50,6 @@ cd {{edx_platform_code_dir}} ...@@ -50,7 +50,6 @@ cd {{edx_platform_code_dir}}
BRANCH="origin/feature/edx-west/stanford-theme" BRANCH="origin/feature/edx-west/stanford-theme"
export GIT_SSH="/tmp/git_ssh.sh"
run git fetch origin -p run git fetch origin -p
run git checkout $BRANCH run git checkout $BRANCH
......
...@@ -40,10 +40,6 @@ ...@@ -40,10 +40,6 @@
- name: change memory commit settings -- needed for redis - name: change memory commit settings -- needed for redis
command: sysctl vm.overcommit_memory=1 command: sysctl vm.overcommit_memory=1
#Upload custom git ssh script
- name: upload ssh script
copy: src=git_ssh.sh dest=/tmp/git_ssh.sh force=yes owner=root group=adm mode=750
- name: set permissions on app_base_dir sgid for edx - name: set permissions on app_base_dir sgid for edx
file: path={{app_base_dir}} owner=root group=edx mode=2775 state=directory file: path={{app_base_dir}} owner=root group=edx mode=2775 state=directory
file: path={{venv_dir}} owner=root group=edx mode=2775 state=directory file: path={{venv_dir}} owner=root group=edx mode=2775 state=directory
...@@ -61,16 +57,12 @@ ...@@ -61,16 +57,12 @@
#Grab both repos or update #Grab both repos or update
- name: git checkout discern repo into discern_dir - name: git checkout discern repo into discern_dir
git: dest={{discern_dir}} repo={{discern_source_repo}} version={{discern_branch}} git: dest={{discern_dir}} repo={{discern_source_repo}} version={{discern_branch}}
environment:
GIT_SSH: /tmp/git_ssh.sh
notify: notify:
- restart celery - restart celery
- restart discern - restart discern
- name: git checkout ease repo into ease_dir - name: git checkout ease repo into ease_dir
git: dest={{ease_dir}} repo={{ease_source_repo}} version={{ease_branch}} git: dest={{ease_dir}} repo={{ease_source_repo}} version={{ease_branch}}
environment:
GIT_SSH: /tmp/git_ssh.sh
notify: notify:
- restart celery - restart celery
- restart discern - restart discern
...@@ -133,4 +125,4 @@ ...@@ -133,4 +125,4 @@
- name: Creating nginx config link {{ site_name }} - name: Creating nginx config link {{ site_name }}
file: src=/etc/nginx/sites-available/{{ site_name }} dest=/etc/nginx/sites-enabled/{{ site_name }} state=link owner=root group=root file: src=/etc/nginx/sites-available/{{ site_name }} dest=/etc/nginx/sites-enabled/{{ site_name }} state=link owner=root group=root
notify: restart nginx notify: restart nginx
\ No newline at end of file
discern_source_repo: git@github.com:edx/discern.git discern_source_repo: https://github.com/edx/discern.git
ease_source_repo: git@github.com:edx/ease.git ease_source_repo: https://github.com/edx/ease.git
ease_dir: $app_base_dir/ease ease_dir: $app_base_dir/ease
discern_dir: $app_base_dir/discern discern_dir: $app_base_dir/discern
discern_settings: discern.aws discern_settings: discern.aws
...@@ -9,4 +9,4 @@ discern_branch: dev ...@@ -9,4 +9,4 @@ discern_branch: dev
nginx_listen_port: 80 nginx_listen_port: 80
gunicorn_port: 7999 gunicorn_port: 7999
discern_user: discern discern_user: discern
site_name: discern site_name: discern
\ No newline at end of file
...@@ -11,8 +11,6 @@ ...@@ -11,8 +11,6 @@
# Do A Checkout # Do A Checkout
- name: git checkout edx-platform repo into $app_base_dir - name: git checkout edx-platform repo into $app_base_dir
git: dest={{edx_platform_code_dir}} repo={{lms_source_repo}} version={{lms_version}} git: dest={{edx_platform_code_dir}} repo={{lms_source_repo}} version={{lms_version}}
environment:
GIT_SSH: /tmp/git_ssh.sh
tags: tags:
- lms - lms
- cms - cms
......
...@@ -28,31 +28,6 @@ ...@@ -28,31 +28,6 @@
- lms-env - lms-env
- update - update
# Install ssh keys for ubuntu account to be able to check out from edx-platform
# Temprory behavior, not needed after June 1. Perhaps still useful as a recipe.
# {{ secure_dir }} is relative to the top-level playbooks dir so there is some
- name: install read-only ssh key for edx-platform repo (private)
copy: src={{ secure_dir }}/files/git-identity dest=/etc/git-identity force=yes owner=ubuntu group=adm mode=600
tags:
- lms
- cms
- update
- name: upload ssh script
copy: src=git_ssh.sh dest=/tmp/git_ssh.sh force=yes owner=root group=adm mode=750
tags:
- lms
- cms
- update
# Check out edx-platform repo to $app_base_dir
- name: install git and its recommends
apt: pkg=git state=present install_recommends=yes
tags:
- lms
- cms
- name: install a bunch of system packages on which LMS and CMS rely - name: install a bunch of system packages on which LMS and CMS rely
apt: pkg={{item}} state=present apt: pkg={{item}} state=present
with_items: lms_debian_pkgs with_items: lms_debian_pkgs
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
- install - install
- name: rbenv | update rbenv repo - name: rbenv | update rbenv repo
git: repo=git://github.com/sstephenson/rbenv.git dest=$rbenv_root version=v0.4.0 git: repo=https://github.com/sstephenson/rbenv.git dest=$rbenv_root version=v0.4.0
tags: tags:
- ruby - ruby
- install - install
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
- install - install
- name: rbenv | clone ruby-build repo - name: rbenv | clone ruby-build repo
git: repo=git://github.com/sstephenson/ruby-build.git dest=${tempdir.stdout}/ruby-build git: repo=https://github.com/sstephenson/ruby-build.git dest=${tempdir.stdout}/ruby-build
when_failed: $rbuild_present when_failed: $rbuild_present
tags: tags:
- ruby - ruby
......
...@@ -48,11 +48,11 @@ worker_core_mult: ...@@ -48,11 +48,11 @@ worker_core_mult:
#To turn off theming, specify edxapp_theme_name: '' #To turn off theming, specify edxapp_theme_name: ''
#Stanford, for example, uses edxapp_theme_name: 'stanford' #Stanford, for example, uses edxapp_theme_name: 'stanford'
edxapp_theme_name: '' edxapp_theme_name: ''
edxapp_theme_source_repo: 'git://github.com/Stanford-Online/edx-theme.git' edxapp_theme_source_repo: 'https://github.com/Stanford-Online/edx-theme.git'
edxapp_theme_version: 'HEAD' edxapp_theme_version: 'HEAD'
# make this the public URL instead of writable # make this the public URL instead of writable
lms_source_repo: git://github.com/edx/edx-platform.git lms_source_repo: https://github.com/edx/edx-platform.git
lms_version: 'HEAD' lms_version: 'HEAD'
local_requirements_file: "{{ edx_platform_code_dir }}/requirements/edx/local.txt" local_requirements_file: "{{ edx_platform_code_dir }}/requirements/edx/local.txt"
pre_requirements_file: "{{ edx_platform_code_dir }}/requirements/edx/pre.txt" pre_requirements_file: "{{ edx_platform_code_dir }}/requirements/edx/pre.txt"
...@@ -73,7 +73,6 @@ lms_debian_pkgs: ...@@ -73,7 +73,6 @@ lms_debian_pkgs:
- gcc - gcc
- gfortran - gfortran
- ghostscript - ghostscript
- git
- github-cli - github-cli
- graphviz - graphviz
- graphviz-dev - graphviz-dev
...@@ -101,6 +100,7 @@ lms_debian_pkgs: ...@@ -101,6 +100,7 @@ lms_debian_pkgs:
- libxml2-dev - libxml2-dev
- libxml2-utils - libxml2-utils
- libxslt1-dev - libxslt1-dev
- lynx-cur
- maven2 - maven2
- mongodb - mongodb
- mongodb-clients - mongodb-clients
...@@ -150,4 +150,4 @@ deploy_environment: ...@@ -150,4 +150,4 @@ deploy_environment:
SKIP_WS_MIGRATIONS: 1 SKIP_WS_MIGRATIONS: 1
RBENV_ROOT: "{{ rbenv_root }}" RBENV_ROOT: "{{ rbenv_root }}"
GEM_HOME: "{{ gem_home }}" GEM_HOME: "{{ gem_home }}"
PATH: "{{ venv_dir }}/bin:{{ edx_platform_code_dir }}/bin:{{ rbenv_root }}/bin:{{ rbenv_root }}/shims:{{ gem_home }}/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games" PATH: "{{ venv_dir }}/bin:{{ edx_platform_code_dir }}/bin:{{ rbenv_root }}/bin:{{ rbenv_root }}/shims:{{ gem_home }}/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
...@@ -6,27 +6,9 @@ ...@@ -6,27 +6,9 @@
# - ruby/tasks/main.yml # - ruby/tasks/main.yml
# - npm/tasks/main.yml # - npm/tasks/main.yml
--- ---
- name: Make sure LMS is running - name: Make sure edxapp is running
service: name=lms state=started service: name=edxapp state=started
tags: tags:
- lms
- lms-env
- production
- update
- name: Make sure CMS is running
service: name=cms state=started
tags:
- cms
- cms-env
- production
- update
- name: Make sure LMS-preview is running
service: name=lms-preview state=started
tags:
- lms-preview
- lms-preview-env
- production - production
- update - update
......
upstream app_server { upstream app_server {
# For a TCP configuration: # For a TCP configuration:
server 127.0.0.1:{{ xqueue.gunicorn_port }} fail_timeout=0; server 127.0.0.1:{{ xqueue_gunicorn_port }} fail_timeout=0;
} }
server { server {
listen {{ xqueue.nginx_port }} default_server; listen {{ xqueue_nginx_port }} default_server;
location / { location / {
try_files $uri @proxy_to_app; try_files $uri @proxy_to_app;
......
...@@ -21,19 +21,21 @@ ...@@ -21,19 +21,21 @@
- xqueue - xqueue
- name: create xqueue application config - name: create xqueue application config
template: src=xqueue_env.json.j2 dest=$app_base_dir/env.json mode=640 owner=www-data group=adm template: src=xqueue.env.json.j2 dest=$app_base_dir/env.json mode=0640 owner=www-data group=adm
tags: tags:
- xqueue - xqueue
- name: create xqueue auth file - name: create xqueue auth file
template: src=xqueue_auth.json.j2 dest=$app_base_dir/auth.json mode=640 owner=www-data group=adm template: src=xqueue.auth.json.j2 dest=$app_base_dir/auth.json mode=0640 owner=www-data group=adm
tags: tags:
- xqueue - xqueue
- name: creating xqueue upstart script - name: creating xqueue upstart script
sudo: True template: src=xqueue.conf.j2 dest=/etc/init/xqueue.conf mode=0640 owner=root group=adm
template: src=xqueue_conf.j2 dest=/etc/init/xqueue_conf owner=root group=root
tags: tags:
- xqueue - xqueue
# Install nginx site
- include: ../../nginx/tasks/nginx_site.yml state=link site_name=xqueue
- include: deploy.yml - include: deploy.yml
#/etc/init/xqueue_conf #/etc/init/xqueue.conf
description "xqueue server" description "xqueue server"
author "edX <info@edx.org>" author "edX <info@edx.org>"
...@@ -6,15 +6,15 @@ author "edX <info@edx.org>" ...@@ -6,15 +6,15 @@ author "edX <info@edx.org>"
respawn respawn
respawn limit 3 30 respawn limit 3 30
env PID=/var/tmp/xqueue_pid env PID=/var/tmp/xqueue.pid
env WORKERS={{ ansible_processor_cores * 2 }} env WORKERS={{ ansible_processor_cores * 2 }}
env PORT={{ xqueue_gunicorn_port }} env PORT={{ xqueue_gunicorn_port }}
env LANG=en_US.UTF-8 env LANG=en_US.UTF-8
env DJANGO_SETTINGS_MODULE=xqueue_aws_settings env DJANGO_SETTINGS_MODULE=xqueue.aws_settings
env SERVICE_VARIANT="xqueue" env SERVICE_VARIANT="xqueue"
chdir {{ xqueue_code_dir }} chdir {{ xqueue_code_dir }}
setuid www-data setuid www-data
exec {{ venv_dir }}/bin/gunicorn --preload -b 127.0.0.1:$PORT -w $WORKERS --timeout=300 --pythonpath={{ xqueue_code_dir }} xqueue_wsgi exec {{ venv_dir }}/bin/gunicorn --preload -b 127.0.0.1:$PORT -w $WORKERS --timeout=300 --pythonpath={{ xqueue_code_dir }} xqueue.wsgi
...@@ -14,7 +14,7 @@ xqueue_gunicorn_port: 8040 ...@@ -14,7 +14,7 @@ xqueue_gunicorn_port: 8040
xqueue_auth_config: {} xqueue_auth_config: {}
xqueue_env_config: {} xqueue_env_config: {}
xqueue_source_repo: https://github.com/edx/xqueue_git xqueue_source_repo: https://github.com/edx/xqueue.git
xqueue_version: 'HEAD' xqueue_version: 'HEAD'
xqueue_pre_requirements_file: "{{ xqueue_code_dir }}/pre-requirements.txt" xqueue_pre_requirements_file: "{{ xqueue_code_dir }}/pre-requirements.txt"
xqueue_post_requirements_file: "{{ xqueue_code_dir }}/requirements.txt" xqueue_post_requirements_file: "{{ xqueue_code_dir }}/requirements.txt"
......
sandbox hard core 0
sandbox hard data 100000
sandbox hard fsize 10000
sandbox hard memlock 10000
sandbox hard nofile 20
sandbox hard rss 10000
sandbox hard stack 100000
sandbox hard cpu 0
sandbox hard nproc 8
sandbox hard as 32000
sandbox hard maxlogins 1
sandbox hard priority 19
sandbox hard locks 4
sandbox hard sigpending 100
sandbox hard msgqueue 100000
sandbox hard nice 19
- name: restart nginx
service: name=nginx state=restarted
- name: stop xserver
service: name=xserver state=stopped
tags:
- deploy
- name: checkout code
git: dest={{ xserver_code_dir }} repo={{ xserver_source_repo }} version={{ xserver_version }}
tags:
- deploy
- name: install requirements
pip: requirements="{{ xserver_requirements_file }}" virtualenv="{{ venv_dir }}" state=present
tags:
- deploy
- name: install sandbox requirements
pip: requirements="{{ xserver_requirements_file }}" virtualenv="{{ xserver_sandbox_venv_dir }}" state=present
tags:
- deploy
- name: create xserver application config
template: src=xserver.env.json.j2 dest={{ app_base_dir }}/env.json mode=640 owner=www-data group=adm
tags:
- deploy
- name: checkout grader code
git: dest={{ xserver_grader_dir }} repo={{ xserver_grader_source }} version={{ xserver_grader_version }}
environment:
GIT_SSH: /tmp/git_ssh.sh
tags:
- deploy
- name: start xserver
service: name=xserver state=started
tags:
- deploy
# Provision and bring up xserver
---
- name: ensure sandbox group exists
group: name=sandbox
- name: ensure sandbox user exists
user: name=sandbox group=sandbox
- name: create sandbox python directory
file: path={{ xserver_sandbox_venv_dir }} owner=ubuntu group=adm mode=2775 state=directory
- name: create sandbox python
command: /usr/local/bin/virtualenv {{ xserver_sandbox_venv_dir }} --distribute creates={{ xserver_sandbox_venv_dir }}/bin/activate
# Make sure this line is in the common-session file.
- name: ensure pam-limits module is loaded
lineinfile:
dest=/etc/pam.d/common-session
regexp="session required pam_limits.so"
line="session required pam_limits.so"
- name: set sandbox limits
copy: src={{ item }} dest=/etc/security/limits.d/sandbox.conf
first_available_file:
- "{{ secure_dir }}/sandbox.conf"
- "sandbox.conf"
- name: ensure apparmor package
apt: pkg=apparmor-utils state=present
- name: load python-sandbox apparmor profile
template: src={{ item }} dest=/etc/apparmor.d/edx_apparmor_sandbox
first_available_file:
- "{{ secure_dir }}/files/edx_apparmor_sandbox.j2"
- "usr.bin.python-sandbox.j2"
- name: enforce app-armor rules
command: aa-enforce {{ xserver_sandbox_venv_dir }}
- name: setup upstart script
template: src=xserver.conf.j2 dest=/etc/init/xserver.conf owner=root group=root
- name: install system dependencies of xserver
apt: pkg={{ item }} state=present
with_items: xserver_debian_pkgs
- include: nginx.yml
- include: deploy.yml
- name: add xserver nginx configuration
template: src=simple-proxy.j2 dest=/etc/nginx/sites-available/simple-proxy
notify:
- restart nginx
- name: enable xserver nginx configuration
file: src=/etc/nginx/sites-available/simple-proxy dest=/etc/nginx/sites-enabled/simple-proxy state=link
notify:
- restart nginx
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##
upstream app_server {
# For a TCP configuration:
server 127.0.0.1:{{ xserver_port }} fail_timeout=0;
}
server {
listen {{ xserver_nginx_port }} default_server;
location / {
try_files $uri @proxy_to_app;
}
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://app_server;
}
}
#include <tunables/global>
/usr/bin/python-sandbox {
#include <abstractions/base>
/usr/bin/python-sandbox mr,
/usr/include/python2.7/** r,
/usr/local/lib/python2.7/** r,
/usr/lib/python2.7** rix,
/tmp/** rix,
}
# gunicorn
description "gunicorn server"
author "Calen Pennington <cpennington@mitx.mit.edu>"
start on started edxapp
stop on stopped edxapp
respawn
respawn limit 3 30
env PID=/var/tmp/xserver.pid
env NEW_RELIC_CONFIG_FILE={{ app_base_dir }}/newrelic.ini
env NEWRELIC={{ venv_dir }}/bin/newrelic-admin
env WORKERS={{ ansible_processor|length }}
env PORT={{ xserver_port }}
env LANG=en_US.UTF-8
env DJANGO_SETTINGS_MODULE=xserver_aws_settings
env SERVICE_VARIANT="xserver"
chdir {{ xserver_code_dir }}
setuid www-data
exec {{ venv_dir }}/bin/gunicorn --preload -b 127.0.0.1:$PORT -w $WORKERS --timeout=30 --pythonpath={{ xserver_code_dir }} pyxserver_wsgi:application
{{ xserver_env_config | to_nice_json }}
# Variables for the xserver.
---
xserver_code_dir: "{{ app_base_dir }}/xserver"
xserver_source_repo: "git://github.com/edx/xserver.git"
# This should probably be overridden in the playbook or groupvars
# with the default pointing to the head of master.
xserver_version: HEAD
xserver_grader_dir: "{{ app_base_dir }}/data/content-mit-600x~2012_Fall"
xserver_grader_source: "git@github.com:/MITx/6.00x.git"
xserver_grader_version: HEAD
xserver_sandbox_venv_dir: "{{ venv_dir }}_apparmor_sandbox"
xserver_requirements_file: "{{ xserver_code_dir }}/requirements.txt"
xserver_port: 8050
xserver_nginx_port: 18050
xserver_debian_pkgs:
- build-essential
- gcc
- gfortran
- liblapack-dev
- libxml++2.6-dev
- libxml2-dev
- libxml2-utils
- libxslt1-dev
- python-dev
...@@ -25,31 +25,30 @@ ...@@ -25,31 +25,30 @@
#see http://atechie.net/2009/07/merging-hashes-in-yaml-conf-files/ #see http://atechie.net/2009/07/merging-hashes-in-yaml-conf-files/
xqueue: xqueue_env_config:
env_config: 'XQUEUES':
'XQUEUES': # push queue
# push queue 'edX-DemoX': 'http://localhost:18050'
- 'edX-DemoX': 'http://localhost:18050'
# pull queues # pull queues
- 'test-pull': !!null 'test-pull': !!null
- 'certificates': !!null 'certificates': !!null
- 'open-ended': !!null 'open-ended': !!null
'XQUEUE_WORKERS_PER_QUEUE': 12 'XQUEUE_WORKERS_PER_QUEUE': 12
'LOGGING_ENV' : 'sandbox' 'LOGGING_ENV' : 'sandbox'
'LOG_DIR' : '/mnt/logs' 'LOG_DIR' : '/mnt/logs'
'SYSLOG_SERVER' : 'syslog.a.m.i4x.org' 'SYSLOG_SERVER' : 'syslog.a.m.i4x.org'
'RABBIT_HOST' : 'localhost' 'RABBIT_HOST' : 'localhost'
'S3_BUCKET_PREFIX' : 'sandbox-bucket' 'S3_BUCKET_PREFIX' : 'sandbox-bucket'
auth_config: xqueue_auth_config:
'AWS_ACCESS_KEY_ID' : '' 'AWS_ACCESS_KEY_ID' : ''
'AWS_SECRET_ACCESS_KEY' : '' 'AWS_SECRET_ACCESS_KEY' : ''
'REQUESTS_BASIC_AUTH': ['edx', 'edx'] 'REQUESTS_BASIC_AUTH': ['edx', 'edx']
'USERS': {'lms': 'password'} 'USERS': {'lms': 'password'}
'RABBITMQ_USER': 'edx' 'RABBITMQ_USER': 'edx'
'RABBITMQ_PASS': 'edx' 'RABBITMQ_PASS': 'edx'
'DATABASES': 'DATABASES':
'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'xqueue', 'USER': 'root', 'PASSWORD': '', 'HOST': 'localhost', 'PORT': '3306' } 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'xqueue', 'USER': 'root', 'PASSWORD': '', 'HOST': 'localhost', 'PORT': '3306' }
......
# ansible reads $ANSIBLE_CONFIG, ansible.cfg, ~/.ansible.cfg or /etc/ansible/ansible.cfg
[defaults]
# Always have these for using the configuration repo
jinja2_extensions=jinja2.ext.do
hash_behaviour=merge
# These are environment-specific defaults
forks=10
#forks=1
log_path=stage-edx-ansible.log
transport=ssh
hostfile=./ec2.py
extra_vars='key=deployment name=edx-stage group=edx-stage region=us-west-1'
user=ubuntu
[ssh_connection]
# example from https://github.com/ansible/ansible/blob/devel/examples/ansible.cfg
#ssh_args=-o ControlMaster=auto -o ControlPersist=60s -o ControlPath=/tmp/ansible-ssh-%h-%p-%r
ssh_args=-F stage-ssh-config
scp_if_ssh=True
#### edx-stage VPC
Host 54.241.183.3
#Host ec2-54-241-183-3.us-west-1.compute.amazonaws.com
#Host vpc-jumpbox
#HostName ec2-54-241-183-3.us-west-1.compute.amazonaws.com
HostName 54.241.183.3
User ubuntu
ForwardAgent yes
Host *.us-west-1.compute.internal
User ubuntu
ForwardAgent yes
#ProxyCommand ssh -W %h:%p ec2-54-241-183-3.us-west-1.compute.amazonaws.com
#ProxyCommand ssh -W %h:%p vpc-jumpbox
ProxyCommand ssh -W %h:%p ubuntu@54.241.183.3
Host *
ForwardAgent yes
SendEnv LANG LC_*
HashKnownHosts yes
GSSAPIAuthentication yes
GSSAPIDelegateCredentials no
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