Created
May 10, 2019 11:13
-
-
Save kovalbogdan95/729bf5cd44d26d65c41fadb0770b2f26 to your computer and use it in GitHub Desktop.
Fabric script to run command on several hosts
This file contains hidden or 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
# pip3 install fabric3==1.14.post1 | |
# Usage: fab cmd:'whoami' | |
from fabric.api import * | |
env.hosts = [ | |
'[email protected]', | |
'[email protected]', | |
'[email protected]', | |
] | |
@task | |
@parallel | |
with settings(warn_only=True): | |
def cmd(command): | |
run(command) | |
@task | |
@parallel | |
with settings(warn_only=True): | |
def su(command): | |
sudo(command) | |
@task | |
def ping(output): | |
""" Sanity check """ | |
print(f'pong!') | |
print(f'hello {output}!')% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment