- From: Zac Stevens <
>
- To:
- Cc:
- Subject: [chef] Re: Re: Re: search returns for nodes sometimes reduced or empty
- Date: Wed, 6 Jun 2012 16:30:42 +0100
Hi Dan,
On Wed, Jun 6, 2012 at 4:00 PM, Dan Adams
<
>
wrote:
>
Thanks for the response - no, I set a new, manually-set attribute (nothing
>
from ohai) that contained an array of the nodes returned via searching on a
>
combinatino of environment and role. Ie i search for all app servers in the
>
staging environment, and get back an array of hashes containing the node
>
information for 1-4 hosts. The problem is that if I have, say, 4 app servers
>
that have that role assigned in that environment, sometimes search returns 4
>
and sometimes 3, sometimes 2.
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 am hoping that the fix suggested by Ian works, since he says it worked for
>
him. However, given that I don't really *need* search as such - I don't care
>
what nodes are currently reporting as having the role, just what hosts are
>
*assigned* that role in their definitions file - is there another better way
>
that I can access this information from recipes other than via search?
Each node has a run_list, which contains both recipes and roles.
Roles can provide more run_list items - including other roles, which
may add still more. So, when chef-client runs, it looks at the
run_list and expands the items on it as far as it can. This process
produces the "expanded run list", and chef-client puts these expanded
lists into the "roles" and "recipes" attributes.
You can see this by comparing the following:
knife node show <yournode> -a run_list
knife node show <yournode> -a roles
knife node show <yournode> -a recipes
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\]"
I don't use "knife node from file", and can't readily confirm that
that empties data out of the node in the way you describe - if it
does, that's going to cause you problems if you're searching the
contents of a node's "roles". I've tried "knife node edit", and that
appears to leave the "roles" list unchanged.
Zac
Archive powered by MHonArc 2.6.16.