I have a simple cookbook named "foo" with a simple recipe in t recipes/default.rb.
I can run the cookbook/recipe manually by typing "chef-client -o foo" and the recipe is behaving as expected (The recipe is just a test to try to understand how Chef-client processes cookbooks/recipes and it just writes to a file).
I've installed the chef-client as a Windows service, and it is starting and running, but in Event Viewer, I am seeing this error:
Log Name: Application
Source: Chef
Date: 6/29/2015 12:53:45 PM
Event ID: 10003
Task Category: None
Level: Error
Keywords: Classic
User: N/A
Computer: WIN-NFJMV7R6OLU
Description:
Failed Chef Client run 336b73ca-7a27-4366-8a8e-f33b23e214ff in 0.265201 seconds.
Exception type: Chef::Exceptions::RecipeNotFound
Exception message: could not find recipe default.rb for cookbook foo
Exception backtrace: c:/opscode/chef/embedded/apps/chef/lib/chef/cookbook_version.rb:217:in `load_recipe'
c:/opscode/chef/embedded/apps/chef/lib/chef/run_context.rb:173:in `load_recipe'
c:/opscode/chef/embedded/apps/chef/lib/chef/run_context/cookbook_compiler.rb:140:in `block in compile_recipes'
c:/opscode/chef/embedded/apps/chef/lib/chef/run_context/cookbook_compiler.rb:138:in `each'
c:/opscode/chef/embedded/apps/chef/lib/chef/run_context/cookbook_compiler.rb:138:in `compile_recipes'
c:/opscode/chef/embedded/apps/chef/lib/chef/run_context/cookbook_compiler.rb:75:in `compile'
c:/opscode/chef/embedded/apps/chef/lib/chef/run_context.rb:96:in `load'
c:/opscode/chef/embedded/apps/chef/lib/chef/policy_builder/expand_node_object.rb:87:in `setup_run_context'
c:/opscode/chef/embedded/apps/chef/lib/chef/client.rb:256:in `setup_run_context'
c:/opscode/chef/embedded/apps/chef/lib/chef/client.rb:454:in `run'
c:/opscode/chef/embedded/apps/chef/lib/chef/application.rb:253:in `run_with_graceful_exit_option'
c:/opscode/chef/embedded/apps/chef/lib/chef/application.rb:230:in `block in run_chef_client'
c:/opscode/chef/embedded/apps/chef/lib/chef/local_mode.rb:39:in `with_server_connectivity'
c:/opscode/chef/embedded/apps/chef/lib/chef/application.rb:213:in `run_chef_client'
c:/opscode/chef/embedded/apps/chef/lib/chef/application/client.rb:375:in `run_application'
c:/opscode/chef/embedded/apps/chef/lib/chef/application.rb:60:in `run'
c:/opscode/chef/embedded/apps/chef/bin/chef-client:26:in `<top (required)>'
c:/opscode/chef/bin/chef-client:63:in `load'
c:/opscode/chef/bin/chef-client:63:in `<main>'
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="Chef" />
<EventID Qualifiers="0">10003</EventID>
<Level>2</Level>
<Task>0</Task>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2015-06-29T19:53:45.000000000Z" />
<EventRecordID>947</EventRecordID>
<Channel>Application</Channel>
<Computer>WIN-NFJMV7R6OLU</Computer>
<Security />
</System>
<EventData>
<Data>336b73ca-7a27-4366-8a8e-f33b23e214ff</Data>
<Data>0.265201</Data>
<Data>Chef::Exceptions::RecipeNotFound</Data>
<Data>could not find recipe default.rb for cookbook foo</Data>
<Data>c:/opscode/chef/embedded/apps/chef/lib/chef/cookbook_version.rb:217:in `load_recipe'
c:/opscode/chef/embedded/apps/chef/lib/chef/run_context.rb:173:in `load_recipe'
c:/opscode/chef/embedded/apps/chef/lib/chef/run_context/cookbook_compiler.rb:140:in `block in compile_recipes'
c:/opscode/chef/embedded/apps/chef/lib/chef/run_context/cookbook_compiler.rb:138:in `each'
c:/opscode/chef/embedded/apps/chef/lib/chef/run_context/cookbook_compiler.rb:138:in `compile_recipes'
c:/opscode/chef/embedded/apps/chef/lib/chef/run_context/cookbook_compiler.rb:75:in `compile'
c:/opscode/chef/embedded/apps/chef/lib/chef/run_context.rb:96:in `load'
c:/opscode/chef/embedded/apps/chef/lib/chef/policy_builder/expand_node_object.rb:87:in `setup_run_context'
c:/opscode/chef/embedded/apps/chef/lib/chef/client.rb:256:in `setup_run_context'
c:/opscode/chef/embedded/apps/chef/lib/chef/client.rb:454:in `run'
c:/opscode/chef/embedded/apps/chef/lib/chef/application.rb:253:in `run_with_graceful_exit_option'
c:/opscode/chef/embedded/apps/chef/lib/chef/application.rb:230:in `block in run_chef_client'
c:/opscode/chef/embedded/apps/chef/lib/chef/local_mode.rb:39:in `with_server_connectivity'
c:/opscode/chef/embedded/apps/chef/lib/chef/application.rb:213:in `run_chef_client'
c:/opscode/chef/embedded/apps/chef/lib/chef/application/client.rb:375:in `run_application'
c:/opscode/chef/embedded/apps/chef/lib/chef/application.rb:60:in `run'
c:/opscode/chef/embedded/apps/chef/bin/chef-client:26:in `<top (required)>'
c:/opscode/chef/bin/chef-client:63:in `load'
c:/opscode/chef/bin/chef-client:63:in `<main>'</Data>
</EventData>
</Event>
It seems like, when the Chef-client is run manually, it can find the recipe, but if it is run as a Windows service, for some reason, Chef-client can't find the recipes/default.rb?
Is there somethng else that I need to do to the recipe or cookbook in order to make it work with chef-client as a service?
Thanks, Jim
EDIT: Also, here is what knife, which run on my Chef workstation, shows for the node:
PS C:\Users\Administrator\chef-repo> knife node show node3
Node Name: node3
Environment: _default
FQDN: WIN-NFJMV7R6OLU
IP: 192.168.0.84
Run List: recipe[foo::default.rb]
Roles:
Recipes:
Platform: windows 6.1.7601
Tags:
EDIT 2:
Also, here's the chef-stacktrace.out from the node:
Generated at 2015-06-29 17:08:23 -0400
Chef::Exceptions::RecipeNotFound: could not find recipe default.rb for cookbook foo
c:/opscode/chef/embedded/apps/chef/lib/chef/cookbook_version.rb:217:in `load_recipe'
c:/opscode/chef/embedded/apps/chef/lib/chef/run_context.rb:173:in `load_recipe'
c:/opscode/chef/embedded/apps/chef/lib/chef/run_context/cookbook_compiler.rb:140:in `block in compile_recipes'
c:/opscode/chef/embedded/apps/chef/lib/chef/run_context/cookbook_compiler.rb:138:in `each'
c:/opscode/chef/embedded/apps/chef/lib/chef/run_context/cookbook_compiler.rb:138:in `compile_recipes'
c:/opscode/chef/embedded/apps/chef/lib/chef/run_context/cookbook_compiler.rb:75:in `compile'
c:/opscode/chef/embedded/apps/chef/lib/chef/run_context.rb:96:in `load'
c:/opscode/chef/embedded/apps/chef/lib/chef/policy_builder/expand_node_object.rb:87:in `setup_run_context'
c:/opscode/chef/embedded/apps/chef/lib/chef/client.rb:256:in `setup_run_context'
c:/opscode/chef/embedded/apps/chef/lib/chef/client.rb:454:in `run'
c:/opscode/chef/embedded/apps/chef/lib/chef/application.rb:253:in `run_with_graceful_exit_option'
c:/opscode/chef/embedded/apps/chef/lib/chef/application.rb:230:in `block in run_chef_client'
c:/opscode/chef/embedded/apps/chef/lib/chef/local_mode.rb:39:in `with_server_connectivity'
c:/opscode/chef/embedded/apps/chef/lib/chef/application.rb:213:in `run_chef_client'
c:/opscode/chef/embedded/apps/chef/lib/chef/application/client.rb:375:in `run_application'
c:/opscode/chef/embedded/apps/chef/lib/chef/application.rb:60:in `run'
c:/opscode/chef/embedded/apps/chef/bin/chef-client:26:in `<top (required)>'
c:/opscode/chef/bin/chef-client:63:in `load'
c:/opscode/chef/bin/chef-client:63:in `<main>'
EDIT 3:
OK, I GOT IT WORKING, but I don't understand why/how :(...
What happened was that I was trying to figure out what might be going on, and I happened to be looking at the management web app and saw that in the lower left box, "current cookbooks", it had an entry for JUST "foo".
So, I dragged the "foo" over to the right pane and deleted the "foo::default.rb".
Then, I waited, and sure enough, it started working... I started seeing Chef client run in Event viewer with no errors and also the recipe was writing to the hard drive (my test case).
Now, :
PS C:\Users\Administrator\chef-repo> knife node show node3
Node Name: node3
Environment: _default
FQDN: WIN-NFJMV7R6OLU
IP: 192.168.0.84
Run List: recipe[foo]
Roles:
Recipes: foo, foo::default
Platform: windows 6.1.7601
Tags:
PS C:\Users\Administrator\chef-repo>
So I'm glad it's working, but I'm puzzled why it wasn't working before???
Is this a bug in Chef-client?
Also, remember this worked when I ran chef-client from the command line... it just failed when run as a service.
knife node showlooks odd to me. I'd expectrecipe[foo::default]and notrecipe[foo::default.rb]. - Sneal