- From: Joshua Timberman <
>
- To: "<
>" <
>
- Cc: "<
>" <
>
- Subject: [chef] Re: Re: Re: Re: Re: search returns for nodes sometimes reduced or empty
- Date: Sun, 10 Jun 2012 21:56:39 -0600
Do note that the nodes environment is accessed with "node.chef_environment"
method which is not a node attribute. The "node['chef_environment']" is an
attribute that won't exist unless you create it.
On Jun 6, 2012, at 11:17, Dan Adams
<
>
wrote:
>
Hi Zac
>
>
Thanks for your reply, you've been very helpful.
>
>
On 06.06.2012 16:30, Zac Stevens wrote:
>
> I may have been unclear in my question - sorry if below I repeat
>
> something you already know.
>
> When you are searching, what is your search query? Are you searching
>
> for "roles:yourrole" or something else?
>
>
I have been using something along the lines of this:
>
search(:node, "chef_environment:#{node['chef_environment']} AND role:xyz")
>
>
as given here on the manual:
>
http://wiki.opscode.com/display/chef/Search#Search-FindNodeswithaRoleintheRunList
>
>
in my recipes to return a list of nodes with the given environment and
>
role. However, I'm guessing that you are telling me that there are two ways
>
to search for role, one of which supplies the roles assigned to the node in
>
its config as imported, and the other that is dynamically updated based on
>
the outcome of the last run? I am very much looking to return the former
>
via search - a permanent value that is correct regardless of the outcome of
>
the last client run, and that is never null or empty.
>
>
> Say I have a role called "physical-server". This search will only
>
> find nodes that have role[physical-server] on their run_list, and have
>
> successfully run and saved their state back to the server:
>
>
>
> knife search node "roles:physical-server"
>
>
>
> On the other hand, this search will find all nodes with that item on
>
> their run_list, whether they have had a successful run or not:
>
>
>
> knife search node "run_list:role\[physical-server\]"
>
>
Aha! So I should simply change my search from the above listed current form
>
to the below? Brilliant!
>
search(:node, "chef_environment:#{node['chef_environment']} AND
>
run_list:role\[xyz\]")
>
>
It definitely sounds like you and Ian have both solved one part each of the
>
problems I was experiencing - that I was looking at the dynamic value when
>
I wanted the permanent one (independent of last run status), and that the
>
reason the dynamic one was letting me down so often was due to a bug in the
>
shipped value for maxFieldLength in solr.
>
>
Thanks very much indeed, I'm pretty confident that the combination of Ian's
>
suggested fix, and this config change above will solve the issues I was
>
seeing!
>
>
Cheers
>
>
Dan
Archive powered by MHonArc 2.6.16.