This repository has been archived by the owner on Jun 26, 2018. It is now read-only.
/
fabfile.py
68 lines (49 loc) · 1.67 KB
/
fabfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import os
from os.path import join as pjoin
from fabric.api import (env, execute, lcd, local, parallel,
run, roles, task)
from fabdeploytools.rpm import RPMBuild
from fabdeploytools import helpers
import fabdeploytools.envs
import deploysettings as settings
env.key_filename = settings.SSH_KEY
fabdeploytools.envs.loadenv(settings.CLUSTER)
ROOT, TRUNION = helpers.get_app_dirs(__file__)
SCL_NAME = getattr(settings, 'SCL_NAME', False)
if SCL_NAME:
helpers.scl_enable(SCL_NAME)
VIRTUALENV = os.path.join(ROOT, 'venv')
PYTHON = os.path.join(VIRTUALENV, 'bin', 'python')
@task
def create_virtualenv(update_on_change=False):
helpers.create_venv(VIRTUALENV, settings.PYREPO,
pjoin(TRUNION, 'prod-reqs.txt'),
update_on_change=update_on_change)
@task
def setup_install():
with lcd(TRUNION):
local("%s setup.py install" % PYTHON)
@task
def update_info(ref='origin/master'):
helpers.git_info(TRUNION)
with lcd(TRUNION):
local("/bin/bash -c "
"'source /etc/bash_completion.d/git && __git_ps1'")
@task
def deploy():
helpers.deploy(name='trunion',
env='{0}-{1}'.format(settings.ENV, settings.APPNAME),
cluster=settings.CLUSTER,
domain=settings.DOMAIN,
root=ROOT,
package_dirs=['trunion', 'venv', 'ssl'])
helpers.restart_uwsgi(getattr(settings, 'UWSGI', []))
@task
def pre_update(ref=settings.UPDATE_REF):
local('date')
execute(helpers.git_update, TRUNION, ref)
execute(update_info, ref)
@task
def update():
execute(create_virtualenv)
execute(setup_install)