厨师" RecipeNotFound"将chef-client作为Windows服务运行时的异常

时间:2015-06-29 20:04:45

标签: chef

我有一个简单的食谱,名为" foo"使用t recipes / default.rb中的简单配方。

我可以通过输入" chef-client -o foo"手动运行食谱/食谱。并且配方的行为符合预期(配方只是一个测试,试图了解Chef-client如何处理cookbook / recipes,它只是写入文件)。

我已将chef-client安装为Windows服务,它正在启动并运行,但在事件查看器中,我看到了这个错误:

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 `&lt;top (required)&gt;'
c:/opscode/chef/bin/chef-client:63:in `load'
c:/opscode/chef/bin/chef-client:63:in `&lt;main&gt;'</Data>
  </EventData>
</Event>

看起来,当Chef-client手动运行时,它可以找到配方,但如果它作为Windows服务运行,由于某种原因,Chef-client无法找到配方/默认值。 RB?

我是否还需要对配方或食谱做些其他事情,以使其与厨师 - 客户服务一起使用?

谢谢, 吉姆

编辑:此外,这是在我的Chef工作站上运行的刀子显示节点:

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:

编辑2:

此外,这里是来自节点的chef-stacktrace.out:

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>'

编辑3:

好的,我 GOT IT WORKING ,但我不明白为什么/如何:(...

发生的事情是我试图找出可能发生的事情,而我正好看着管理网络应用程序,并在左下方框中看到了#34;当前的食谱&#34;,它有一个条目JUST&#34; foo&#34;。

所以,我拖着&#34; foo&#34;转到右侧窗格并删除&#34; foo :: default.rb&#34;。

然后,我等了,果然,它开始工作......我开始看到Chef客户端在事件查看器中运行没有错误,并且配方正在写入硬盘驱动器(我的测试用例)。

现在,:

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>

所以我很高兴它能够工作,但我很困惑为什么它之前没有工作???

这是Chef-client中的错误吗?

另外,请记住,当我从命令行运行chef-client时,这种方法很有效...它在作为服务运行时失败了。

1 个答案:

答案 0 :(得分:0)

Sneal绝对正确。在运行列表中,您省略了食谱名称的.rb。此外,如果您完全省略食谱名称,如

recipe[foo]

它会假设您正在寻找foo :: default。我强烈建议总是包括食谱名称,请注意,我只是试图解释一些看似奇怪的行为。