Skip to content

Instantly share code, notes, and snippets.

@spidaman
Created June 14, 2010 22:56
Show Gist options
  • Save spidaman/438446 to your computer and use it in GitHub Desktop.
Save spidaman/438446 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'chef/node'
require 'chef/rest'
# set chef_server_url and node_name & get the path to key file
# look in ~/.chef/knife.rb
Chef::Config[:client_key] = "/path/to/key"
rest = Chef::REST.new(chef_server_url, node_name)
results = rest.get_rest("search/node?q=role:WEBSERVER_ROLE")
# got search meta data, an array of nodes is under the 'rows' key
nodes = results['rows']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment