Created
December 9, 2009 19:40
-
-
Save joewilliams/252726 to your computer and use it in GitHub Desktop.
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
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 |
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
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