Closed mjallday closed 10 years ago
@mjallday you might need 2 just add the partial-search cookbook (https://github.com/opscode-cookbooks/partial_search) in metadata
@mjallday or you might need the chef node plugin
The partial search API is available in the Open Source Chef Server since 11.0.4
We're newer than that right?
yeah, but I think its most likely that we didn't include the parital_search cookbook.
try that and give it a whirl
One step further. Code that isn't tested always has bugs. Should figure out how to test code that doesn't work on chef solo
[2014-04-07T16:51:14+00:00] ERROR: Exception handlers complete
[2014-04-07T16:51:14+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
Chef Client failed. 88 resources updated in 140.93062393 seconds
[2014-04-07T16:51:14+00:00] ERROR:
Chef::Mixin::Template::TemplateError (undefined method `+' for nil:NilClass) on line #6:
4: <node name="<%= n['name'] %>"
5: description="<%= n['description'] || n['name'] %>"
6: tags="<%= (n['roles'] + n['recipes']).join(',') %>"
7: hostname="<%= n['fqdn'] %>"
8: osArch="<%= n['kernel_machine'] %>"
(erubis):6:in `block (2 levels) in evaluate'
(erubis):3:in `each'
(erubis):3:in `block in evaluate'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/erubis-2.7.0/lib/erubis/evaluator.rb:74:in `instance_ev
'
ok looks like: n['roles']
and n['recipes']
are supposed to be arrays but one of them is Nil.
so what I would do is n['roles'] ||= []
and n['recipes'] ||= []
whiich says not falsy or empty list
Will do. For the record here's what the issue is: The search query (knife search "roles:balanced-worker-integration and chef_environment:test"
) is returning way too many items, including a bunch of old un-bootstrapped nodes that have no roles or recipes associated with them.
This is weird because I ran knife status "roles:balanced-worker-integration
as my test query and it returned a single node which is my expected result. adding the and chef_environment:test
does not work as i would expect. The chef docs suggest you can run queries such as knife search node "chef_environment:QA AND platform:centos"
so it's not immediately clear why this is occurring.
Turns out that AND statement is case sensitive.
| ~/code/balanced/confucius @ mjallday-2 (confucius)(master)
| => knife status "chef_environment:test AND roles:balanced-worker-dev"
69 hours ago, bwrk-dev-test-e4kghh-10-3-109-45, ubuntu 12.04.
68 hours ago, bwrk-dev-test-04ypsw-10-3-108-97, ubuntu 12.04.
67 hours ago, bwrk-dev-test-xjbx24-10-3-109-70, ubuntu 12.04.
66 hours ago, bwrk-dev-test-6g6jat-10-3-109-143, ubuntu 12.04.
28 minutes ago, bwrk-dev-test-limhxl-10-3-108-34, ubuntu 12.04.
OK, this all be working now. I'm not going to fix the issue with the empty arrays since we don't have any valid nodes that have either empty roles or recipes.
@coderanger lmk if you have any ideas, i'm going to start debugging this.