Search Doesn't Work in Attributes Files


#1

Hi, I am running Chef 0.10.4 and trying to use search to define default
attributes within an attribute file but it doesn’t seem to be working. Even
running,

search(:node, “:”) do |matching_node|
puts matching_node.to_s
end

I am able to run this successfully within a recipe, but I was wondering is this
the desired functionality?


#2

Yep - you should be doing search from recipes, but not from attribute
files. In general, any time you are computing a value and using it as
an attribute you likely want to do that in a recipe (it avoids some
interesting issues with when new data gets applied to your
attributes.)

You can still do everything you want - just set node.default and move along.

Best,
Adam

On Fri, Oct 21, 2011 at 2:38 PM, bjbq4d@gmail.com wrote:

Hi, I am running Chef 0.10.4 and trying to use search to define default
attributes within an attribute file but it doesn’t seem to be working. Even
running,

search(:node, “:”) do |matching_node|
puts matching_node.to_s
end

I am able to run this successfully within a recipe, but I was wondering is this
the desired functionality?


Opscode, Inc.
Adam Jacob, Chief Product Officer
T: (206) 619-7151 E: adam@opscode.com