[chef] true using of knife search in separate script/recipe context


Chronological Thread 
  • From: Vladimir Skubriev < >
  • To:
  • Subject: [chef] true using of knife search in separate script/recipe context
  • Date: Tue, 20 Aug 2013 17:15:46 +0400

I want to search nodes that was run recipes.

I want to check my code in separate file, after that integrate them into recipe

My file is:

#!/opt/chef/embedded/bin/ruby

require 'chef'
require 'chef/knife/search'

require 'chef/knife'
require 'chef/search/query'
require 'chef/knife/search'

# I think that i can search trivil with this method, but it is not working
# Will be ideal to use this method
nodes = search(:node, "*:*")

nodes.each do |nod|

        puts nod
        nod.recipe? "cbacula::client"

end

I found this example at ( http://www.opscode.com/blog/2011/04/22/chef-0-10-preview-knife-plugins-and-ui/),

but i am frusrating to use it because of fuzzier_query var not understandable for me.

fuzzier_query = &amp;quot;tags:*
OR roles: OR fqdn: OR addresses: &amp;quot;

knife_search = Chef::Knife::Search.new
knife_search.name_args = ['node', fuzzier_query]
knife_search.run

How can i find objects of class node on my chef server ?

I think that i am on the wrong way because recipe context and separate script not the same things.

I tried to use shef -z, but the documentation on its use, which I was found very small.

Thank you very much.
-- 
Best regards,

CVisionLab System Administrator
Vladmir Skubriev


  • [chef] true using of knife search in separate script/recipe context, Vladimir Skubriev, 08/20/2013

Archive powered by MHonArc 2.6.16.

§