Created
July 26, 2014 01:58
-
-
Save notsobad/52530b890338f8fde1a2 to your computer and use it in GitHub Desktop.
Use fabric and svn to deploy code to multi servers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from fabric.api import task, run, env, cd | |
''' | |
* fab version | |
* fab deploy user:password:version | |
* fab reload_ui | |
''' | |
__author__ = 'notsobad' | |
env.key_filename = '~/.ssh/ui.rsa' | |
env.hosts = ['ui1', 'ui2'] | |
def run_app(cmd): | |
if env.user == 'root': | |
cmd = 'sudo -u app %s' % cmd | |
return run(cmd) | |
@task | |
def version(): | |
run_app('svnversion /home/notsobad/ui') | |
@task | |
def reload_ui(): | |
run_app('touch /tmp/.ui-reload') | |
@task | |
def deploy(username, password, to_version): | |
with cd('/home/notsobad/ui'): | |
cmd = 'svn up -r {to_version} --username {username} --password "{password}" .'.format(username=username, password=password, to_version=to_version) | |
run_app(cmd) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment