Skip to content

Instantly share code, notes, and snippets.

@anubhavsinha
Created August 23, 2014 00:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anubhavsinha/5b9478c203eaf136f801 to your computer and use it in GitHub Desktop.
Save anubhavsinha/5b9478c203eaf136f801 to your computer and use it in GitHub Desktop.
running different commands on different hosts.
from fabric.api import *
from fabric.context_managers import settings
hosts = ['10.10.6.234', '10.10.6.65']
env.user = 'ubuntu'
env.key_filename = '/home/as/work/credentials/pipeline.pem'
def local_uname():
local('uname -a')
def remote_uname():
for index, host in enumerate(hosts):
with settings(host_string=host):
run('echo hello'+str(index))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment