True using of knife search in separate script/recipe context


I want to search nodes that was run recipes.

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

My file is:


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"


I found this example at (,

but i am frusrating to use it because of fuzzier_query var not
understandable for me.
fuzzier_query = "tags:||#{@query} OR roles:#{@query} OR
fqdn:#{@query} OR addresses:#{@query}"|

knife_search =
knife_search.name_args = [‘node’, fuzzier_query]

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