from __future__ import with_statement from fabric.api import * #from fabric.operations import * env.hosts = ['root@localhost','root@192.168.1.10'] env.passwords = {'root@localhost':'PASSWORD','root@192.168.1.10':'PASSWORD'} env.roledefs = { 'junDev': ['root@localhost'], 'testServer': ['root@192.168.1.10'] } @roles('testServer') def deploy_django(): put("test.tar.gz", "/tmp/") with cd("/tmp"): run('tar zxvf %s.tar.gz' % (app_name)) with cd('/home/html/deploy/'): run('python deploy.py')