Created
November 25, 2010 14:30
-
-
Save stucchio/715461 to your computer and use it in GitHub Desktop.
One fabric command, multiple roles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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