Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Small ruby/fog program to run a linux command via ssh on all of your cloud servers, displaying the returned output from each server

View run
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
#!/usr/bin/ruby
#############################################
# Ruby / Fog Cloud Server Command Runner
#
# Author: Paul Reiber paul@reiber.org
#
# Usage: run commandline-to-run-on-all-servers
#
# Assumptions:
# * You are using the Rackspace Cloud
# * Your cloud servers are in the dfw datacenter (if not, fix the rackspace_region)
# * All servers on the cloud account have key-based root ssh access.
# ...if they don't have ssh key-based access here are the steps:
# http://www.rackspace.com/knowledge_center/article/secure-shell-ssh
#
# The 'oj' gem requirement is only there to eliminate the irritating warning about the default JSON parser
#
require 'rubygems'
require 'fog'
require 'pp'
require 'oj'
 
# populate the following with your correct username, api_key, and region details
service = Fog::Compute.new({ :provider => 'Rackspace', :version => :v2,
:rackspace_region => :dfw, :rackspace_username => 'YOUR-CLOUD-USERNAME', :rackspace_api_key => 'YOUR-CLOUD-API-KEY' })
 
# running a command on all servers and reporting the results is as simple as the following:
service.servers.each {|n| puts n.name; pp n.ssh [ARGV] }
 
# thats all it takes!

Hi..I am working on fog azure ..can you please tell how to execute fog azure command..any link or resource will be helpful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.