Skip to content

Instantly share code, notes, and snippets.

@earzur
Created March 8, 2012 14:05
Show Gist options
  • Select an option

  • Save earzur/2001122 to your computer and use it in GitHub Desktop.

Select an option

Save earzur/2001122 to your computer and use it in GitHub Desktop.
Some problem with chef search
run_date = Time.now
ruby_block "add current date" do
block do
node[:test_last_chef_run] = run_date.to_i
node.save
end
action :create
end
ruby_block "search for matching nodes ..." do
block do
nodes = search(:node,"test_last_chef_run:#{run_date.to_i}")
Chef::Log.info "Found #{nodes.size} nodes : #{nodes.to_s} "
end
action :create
end
@earzur
Copy link
Author

earzur commented Mar 8, 2012

the nodes array in the second block always comes empty - this problem prevents the mongodb cookbook to find a member of a replicaset it has just configured (at bootstrap time - when the node isn't registered yet).

Is there a way to make sure the node is in the index before calling :search ?

should i force the current node in the search results instead ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment