Skip to content

Instantly share code, notes, and snippets.

@pix0r
Created March 8, 2012 18:49
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • 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": [
"user@staging01.mycompany.com",
"user@staging02.mycompany.com",
],
},
"production": {
"hosts": [
"user@www01.mycompany.com",
"user@www02.mycompany.com",
],
},
}
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