Skip to content

Instantly share code, notes, and snippets.

@kovalbogdan95
Created May 10, 2019 11:13
Show Gist options
  • Save kovalbogdan95/729bf5cd44d26d65c41fadb0770b2f26 to your computer and use it in GitHub Desktop.
Save kovalbogdan95/729bf5cd44d26d65c41fadb0770b2f26 to your computer and use it in GitHub Desktop.
Fabric script to run command on several hosts
# pip3 install fabric3==1.14.post1
# Usage: fab cmd:'whoami'
from fabric.api import *
env.hosts = [
'pi@192.168.0.111',
'pi@192.168.0.112',
'pi@192.168.0.113',
]
@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