From d5b6970282c2e978b5b7e35c6afb4da5c43c253e Mon Sep 17 00:00:00 2001 From: Andrew Otto Date: Tue, 8 May 2012 17:36:29 -0400 Subject: [PATCH] fabfile.py additions, still a bit to do --- fabfile.py | 55 +++++++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 49 insertions(+), 6 deletions(-) diff --git a/fabfile.py b/fabfile.py index eae72de..4c7131f 100644 --- a/fabfile.py +++ b/fabfile.py @@ -2,11 +2,40 @@ from fabric.api import * env.project_name = 'kraken-ui' -env.roledefs = { - 'test': ['less.ly'], - 'production': ['reportcard2.pmtpa.wmflabs'], -} +env.use_ssh_config = True # this is not working for me! +env.colors = True + + +# defaults + +# Hm. +env.local_dist_directory = 'tmp/dist' +env.dist_directory = 'dist' + + +# There should be a way to do this using stages. +# See: http://tav.espians.com/fabric-python-with-cleaner-api-and-parallel-deployment-support.html +# env.config_file = False +# env.stages = ['production', 'staging'] + +# environments +@task(alias='prod') +def production(): + """Set production environment variables""" + env.hosts = ['reportcard2.pmtpa.wmflabs'] + env.directory = '/srv/reportcard/kraken-ui' + env.owner = 'www-data' + env.group = 'www' + +@task +def staging(): + """Set staging environment variables""" + env.hosts = ['less.ly'] + env.directory = '/home/wmf/projects/kraken-ui' + env.user = 'wmf' + env.owner = 'wmf' + env.group = 'www' @task @@ -17,24 +46,38 @@ def bundle(): @task def fix_permissions(): """Recursively fixes permissions on the deployment host.""" + sudo('chmod -R g+w %s') + sudo('chown -R %(owner)s:%(group)s %(directory)s' % env) pass @task def update(): """Runs git pull on the deployment host.""" - pass + with cd(env.directory): + run('git pull') + @task def distribute(): """Copies tmp/dist to deployment host.""" + local("rsync -Caz -v %(local_dist_directory)s %(user)s@%(host)s:%(directory)s/%(dist_directory)s" % env) + # TODO: make sure the following works. + # rsync_project(local_dir=env.local_dist_directory, remote_dir="%(user)s@%(host)s:%(directory)s/%(dist_directory)s" % env) pass @task def restart_server(): """Restarts node.js server on the deployment host.""" + # need to work on this for less.ly + sudo("supervisor restart reportcard") pass @task def deploy(): """Full deployment of latest project""" - pass \ No newline at end of file + + +@task +def test(): + puts("user: %(user)s" % env) + run('whoami') \ No newline at end of file -- 1.7.0.4