Skip to content

Instantly share code, notes, and snippets.

@pix0r
Created March 8, 2012 18:49
Show Gist options
  • Save pix0r/2002643 to your computer and use it in GitHub Desktop.
Save pix0r/2002643 to your computer and use it in GitHub Desktop.
Sample Fabric environment setup
from fabric.api import env, run
from fabric.contrib.project import rsync_project
try:
from fabfile_local import *
except ImportError, e:
environments = {
"dev": {
"hosts": ["localhost"],
},
}
print "You can customize environments with fabfile_local.py"
def e(name='dev'):
print "Setting environment", name
env.update(environments[name])
env.environment = name
def host_type():
run('uname -s')
def rsync(remote_dir='/srv/myproject/'):
rsync_project(
remote_dir="/srv/myproject/",
local_dir="./",
exclude=("*_local.py", "*.pyc",),
)
environments = {
"staging": {
"hosts": [
"[email protected]",
"[email protected]",
],
},
"production": {
"hosts": [
"[email protected]",
"[email protected]",
],
},
}
fab e:production host_type
fab e:staging rsync
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment