Skip to content

Instantly share code, notes, and snippets.

@stucchio
Created November 25, 2010 14:30
Show Gist options
  • Save stucchio/715461 to your computer and use it in GitHub Desktop.
Save stucchio/715461 to your computer and use it in GitHub Desktop.
One fabric command, multiple roles
#Must be run with role foo, since foo has sudo access or other permissions
@hosts(*env.roledefs['foo'])
def do_foo_actions():
sudo("mkdir /usr/local/program")
sudo("chown -R bar:bar /usr/local/program")
#Most of the work here is done in role bar. But the folder /usr/local/program must exist before we can deploy
@hosts(*env.roledefs['bar'])
def deploy_program():
for h in env.roledefs['foo']:
with settings(host_string=h):
do_foo_actions()
#From here on out, commands will be run as hadoop rather than hadoopadmin
put(..., "/usr/local/program")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment