Commit 1cc75f50 by Jason Bau

Merge pull request #91 from edx/jarv/fab-updates

Jarv/fab updates
parents 3a22b4fa c8204751
...@@ -4,7 +4,6 @@ import re ...@@ -4,7 +4,6 @@ import re
import socket import socket
from functools import partial from functools import partial
from dogapi import dog_stats_api
from fabric.api import task, sudo, runs_once, execute from fabric.api import task, sudo, runs_once, execute
from fabric.api import cd, env, abort, parallel, prefix from fabric.api import cd, env, abort, parallel, prefix
from fabric.colors import white, green, red from fabric.colors import white, green, red
...@@ -222,8 +221,6 @@ def deploy(auto_migrate=False): ...@@ -222,8 +221,6 @@ def deploy(auto_migrate=False):
metric_name = 'fabric.deployment' metric_name = 'fabric.deployment'
# pre checkout commands # pre checkout commands
with dog_stats_api.timer(metric_name, tags=package_tags +
['step:pre_commands']):
with prefix("export GIT_SSH=/tmp/git.sh"): with prefix("export GIT_SSH=/tmp/git.sh"):
for cmd in env.pre_post['pre']: for cmd in env.pre_post['pre']:
noopable(sudo)(cmd) noopable(sudo)(cmd)
...@@ -238,7 +235,6 @@ def deploy(auto_migrate=False): ...@@ -238,7 +235,6 @@ def deploy(auto_migrate=False):
'existance:' + 'existing' if existing_repo else 'absent', 'existance:' + 'existing' if existing_repo else 'absent',
] ]
with dog_stats_api.timer(metric_name, tags=repo_tags + ['step:clone']):
if existing_repo: if existing_repo:
if not files.exists(os.path.join(pkg.repo_root, '.git'), if not files.exists(os.path.join(pkg.repo_root, '.git'),
use_sudo=True): use_sudo=True):
...@@ -256,15 +252,12 @@ def deploy(auto_migrate=False): ...@@ -256,15 +252,12 @@ def deploy(auto_migrate=False):
if '~' in pkg.name: if '~' in pkg.name:
_update_course_xml(pkg, pkg.name.split('~')[1]) _update_course_xml(pkg, pkg.name.split('~')[1])
with dog_stats_api.timer(metric_name, tags=repo_tags +
['step:requirements']):
_install_requirements(pkg) _install_requirements(pkg)
_install_gemfile(pkg) _install_gemfile(pkg)
_install_npm_package(pkg) _install_npm_package(pkg)
# with dog_stats_api.timer(metric_name, tags=repo_tags + ['step:fact']): # drop a file for puppet so it knows that
# # drop a file for puppet so it knows that # code is installed for the service
# # code is installed for the service
# with cd('/etc/facter/facts.d'): # with cd('/etc/facter/facts.d'):
# pkg_config = PackageInfo() # pkg_config = PackageInfo()
# if pkg.repo_name in pkg_config.service_repos: # if pkg.repo_name in pkg_config.service_repos:
...@@ -274,12 +267,8 @@ def deploy(auto_migrate=False): ...@@ -274,12 +267,8 @@ def deploy(auto_migrate=False):
# 'echo "{0}_installed=true" > {0}_installed.txt'.format( # 'echo "{0}_installed=true" > {0}_installed.txt'.format(
# pkg.repo_name.replace("-", "_"))) # pkg.repo_name.replace("-", "_")))
# with dog_stats_api.timer(metric_name, tags=package_tags + pkg_version()
# ['step:pkg_version']):
# pkg_version()
with dog_stats_api.timer(metric_name, tags=package_tags +
['step:post_commands']):
# post checkout commands # post checkout commands
with prefix("export GIT_SSH=/tmp/git.sh"): with prefix("export GIT_SSH=/tmp/git.sh"):
for cmd in env.pre_post['post']: for cmd in env.pre_post['post']:
...@@ -384,15 +373,6 @@ def _install_requirements(pkg): ...@@ -384,15 +373,6 @@ def _install_requirements(pkg):
# suspended # suspended
sudo('{0} {1}'.format(AA_COMPLAIN, AA_SANDBOX_POLICY)) sudo('{0} {1}'.format(AA_COMPLAIN, AA_SANDBOX_POLICY))
# Run old-style requirements TODO: remove
_run_if_changed(pkg, 'pre-requirements.txt', partial(
pip_install, file='pre-requirements.txt', venv='/opt/edx'),
'cat *requirements.txt')
_run_if_changed(pkg, 'requirements.txt', partial(
pip_install, file='requirements.txt', venv='/opt/edx'),
'cat *requirements.txt')
# end old-style requirements
# Run new-style requirements # Run new-style requirements
for venv in VIRTUAL_ENVS: for venv in VIRTUAL_ENVS:
if not files.exists(venv): if not files.exists(venv):
...@@ -409,7 +389,6 @@ def _install_requirements(pkg): ...@@ -409,7 +389,6 @@ def _install_requirements(pkg):
if files.exists(AA_ENFORCE) and files.exists(AA_SANDBOX_POLICY): if files.exists(AA_ENFORCE) and files.exists(AA_SANDBOX_POLICY):
sudo('{0} {1}'.format(AA_ENFORCE, AA_SANDBOX_POLICY)) sudo('{0} {1}'.format(AA_ENFORCE, AA_SANDBOX_POLICY))
@task @task
@runs_once @runs_once
def deploy_with_puppet(): def deploy_with_puppet():
......
# datadog integration configuration # datadog integration configuration
datadog_api: '' datadog_api: ''
# repo_dirs : Exhaustive list of repo-dirs and their corresponding repo-names # repo_dirs : Exhaustive list of repo-dirs and their corresponding repo-names
...@@ -21,12 +20,16 @@ repo_dirs: ...@@ -21,12 +20,16 @@ repo_dirs:
/opt/wwc/grading-controller: edx/grading-controller /opt/wwc/grading-controller: edx/grading-controller
/opt/wwc/ease: edx/ease /opt/wwc/ease: edx/ease
/opt/wwc/edx-platform: edx/edx-platform /opt/wwc/edx-platform: edx/edx-platform
/opt/wwc/data/cs50: MITx/cs50
/opt/wwc/data/edx4edx: MITx/edx4edx
/opt/wwc/data/700x: MITx/700x
/opt/wwc/xqueue: edx/xqueue /opt/wwc/xqueue: edx/xqueue
/opt/wwc/xserver: edx/xserver /opt/wwc/xserver: edx/xserver
/opt/wwc/certificates: edx/certificates /opt/wwc/certificates: edx/certificates
/opt/wwc/drupal: MITx/drupal
/opt/wwc/latex2edx: edx/latex2edx_xserver /opt/wwc/latex2edx: edx/latex2edx_xserver
/opt/wwc/worker: edx/edx-platform /opt/wwc/worker: edx/edx-platform
/opt/sysadmin: MITx/sysadmin
# {pre,post}_checkout_regex: # {pre,post}_checkout_regex:
# What actions to take before and after a repo checkout. # What actions to take before and after a repo checkout.
# Commands will be grouped together if multiple matches are made # Commands will be grouped together if multiple matches are made
...@@ -134,22 +137,34 @@ post_checkout_regex: !!omap ...@@ -134,22 +137,34 @@ post_checkout_regex: !!omap
- ^edx-platform$|^content-.*$: - ^edx-platform$|^content-.*$:
- | - |
# Requirements files have been moved, so check the location first #install local requirements for the platform
if [[ -e /opt/wwc/edx-platform/local-requirements.txt ]]; then if [[ -e /opt/wwc/edx-platform/requirements/edx/local.txt ]]; then
cd /opt/wwc/edx-platform cd /opt/wwc/edx-platform
sudo -E /opt/edx/bin/pip install -q --upgrade --no-deps -r \ sudo -E /opt/edx/bin/pip install -q --upgrade --no-deps --ignore-installed \
/opt/wwc/edx-platform/local-requirements.txt --exists-action w -r /opt/wwc/edx-platform/requirements/edx/local.txt
fi fi
# Then check the new location #install local requirements for the sandbox
if [[ -e /opt/wwc/edx-platform/requirements/local.txt ]]; then
if [[ -e /etc/apparmor.d/code.sandbox ]]; then
sudo /usr/sbin/aa-complain /etc/apparmor.d/code.sandbox
if [[ -e /opt/wwc/edx-platform/requirements/edx-sandbox/local.txt ]]; then
cd /opt/wwc/edx-platform cd /opt/wwc/edx-platform
sudo -E /opt/edx/bin/pip install -q --upgrade --no-deps -r \ sudo -E /opt/edx-sandbox/bin/pip install -q --upgrade --no-deps --ignore-installed \
/opt/wwc/edx-platform/requirements/local.txt --exists-action w -r /opt/wwc/edx-platform/requirements/edx-sandbox/local.txt
fi
sudo /usr/sbin/aa-enforce /etc/apparmor.d/code.sandbox
fi fi
- ^edx-platform$: - ^edx-platform$:
- | - |
# On servers running the workers, which run from the same cloned
# repo, we don't want to run collect static. This could cause
# problems because the cache's are shared with the edx-platform instances
# it's also simply not necessary for the workers as they have no
# view component.
edx_workers_status=$(service edx-workers status 2>/dev/null || true)
# git.py already handle prerequisites, so don't let rake try to install them as well # git.py already handle prerequisites, so don't let rake try to install them as well
if [[ -z $edx_workers_status ]]; then
export NO_PREREQ_INSTALL=1 export NO_PREREQ_INSTALL=1
# This is not a developer workspace, so we don't want to do the workspace migrations # This is not a developer workspace, so we don't want to do the workspace migrations
# Instead, we rely on having a clean checkout every time # Instead, we rely on having a clean checkout every time
...@@ -177,7 +192,16 @@ post_checkout_regex: !!omap ...@@ -177,7 +192,16 @@ post_checkout_regex: !!omap
--pythonpath=/opt/wwc/edx-platform --settings=lms.envs.aws \ --pythonpath=/opt/wwc/edx-platform --settings=lms.envs.aws \
--noinput --verbosity=0 --noinput --verbosity=0
fi fi
fi
- | - |
# On servers running the workers, which run from the same cloned
# repo, we don't want to run collect static. This could cause
# problems because the cache's are shared with the edx-platform instances
# it's also simply not necessary for the workers as they have no
# view component.
edx_workers_status=$(service edx-workers status 2>/dev/null || true)
# git.py already handle prerequisites, so don't let rake try to install them as well
if [[ -z $edx_workers_status ]]; then
export NO_PREREQ_INSTALL=1 export NO_PREREQ_INSTALL=1
export SKIP_WS_MIGRATIONS=1 export SKIP_WS_MIGRATIONS=1
export RBENV_ROOT=/opt/www/.rbenv export RBENV_ROOT=/opt/www/.rbenv
...@@ -203,7 +227,7 @@ post_checkout_regex: !!omap ...@@ -203,7 +227,7 @@ post_checkout_regex: !!omap
$RUN django-admin.py update_templates \ $RUN django-admin.py update_templates \
--pythonpath=/opt/wwc/edx-platform --settings=cms.envs.aws --pythonpath=/opt/wwc/edx-platform --settings=cms.envs.aws
fi fi
fi
- ^edx-platform$|^content-.*$: - ^edx-platform$|^content-.*$:
- | - |
edxapp_status=$(service edxapp status 2>/dev/null || true) edxapp_status=$(service edxapp status 2>/dev/null || 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