Skip to content

Instantly share code, notes, and snippets.

@joewilliams
Created December 9, 2009 19:40
Show Gist options
  • Save joewilliams/252726 to your computer and use it in GitHub Desktop.
Save joewilliams/252726 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'rest_client'
require 'json'
require 'net/ssh'
servers_json = RestClient.get("http://localhost:5984/chef/_design/nodes/_view/ec2_hostnames")
servers = JSON.parse(servers_json)
servers["rows"].each do |row|
Net::SSH.start(
row["value"][0],
"user",
:port => 22,
:keys => "~/.ssh/somekey",
:paranoid => false ) do |ssh|
puts ""
puts row["value"][0]
puts row["value"][1]
output = ssh.exec! "ls"
puts output
puts ""
end
end
function(doc) {
if (doc.chef_type == "node") {
emit(doc.name, [doc.attributes.ec2.public_hostname, doc.attributes.tags[0]]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment