Skip to content

Instantly share code, notes, and snippets.

@marcuswestin
Last active December 26, 2015 11:19
Show Gist options
  • Save marcuswestin/7143067 to your computer and use it in GitHub Desktop.
Save marcuswestin/7143067 to your computer and use it in GitHub Desktop.
Base fabfile.py constructs
from fabric.api import local, run, put, env, sudo, cd, lcd, settings
env.user = 'ubuntu'
env.key_filename = './private-key.pem'
isLocal = False
go = lcd if isLocal else cd
do = local if isLocal else run
sudo_do = local if isLocal else sudo
def do_something():
with go('foo/bar'):
do('pwd')
sudo_do('pwd')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment