Class: Praegustator::Wrappers::Chef

Inherits:
Object
  • Object
show all
Defined in:
lib/praegustator/wrappers/chef.rb

Class Method Summary collapse

Class Method Details

.search(query) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/praegustator/wrappers/chef.rb', line 8

def self.search query
  ::Chef::Config.from_file(File.expand_path(Praegustator.config['chef']['knife_location']))
  chef_query = ::Chef::Search::Query.new
  nodes = chef_query.search('node',query).first rescue []
  $stdout.puts "no node found for search criteria: #{query}" if nodes.empty?
  nodes.map{|n| Praegustator::Node.new n.name , n.ipaddress ,query}
end