厨师零在厨房测试中找不到食谱 运行

Chef zero can't find cookbook during kitchen test run

这快把我逼疯了,我刚开始在新映像 (win10) 上使用 chef,但出于某种原因,在使用 kitchen 测试食谱时找不到食谱?尝试回答这个问题:Chef solo can't find cookbook during kitchen test run 它抛出一个错误说 "Your Berksfile contains multiple entries named 'printserver'. Please remove duplicate dependencies, or put them in different groups.] on default-win-2012r2-standard-amd64-nocm" 厨房版本 1.17.0

----> Converging <default-win-2012r2-standard-amd64-nocm>...
   Preparing files for transfer
   Preparing dna.json
   Resolving cookbook dependencies with Berkshelf 6.3.1...
   Removing non-cookbook files before transfer
   Preparing validation.pem
   Preparing client.rb
 -----> Chef Omnibus installation detected (install only if missing)
   Transferring files to <default-win-2012r2-standard-amd64-nocm>
   Starting Chef Client, version 13.4.24
   resolving cookbooks for run list: ["printserver"]

   ================================================================================
   Error Resolving Cookbooks for Run List:
   ================================================================================

   Missing Cookbooks:
   ------------------
   No such cookbook: printserver

   Expanded Run List:
   ------------------
   * printserver

   System Info:
   ------------
   chef_version=13.4.24
   platform=windows
   platform_version=6.3.9600
   ruby=ruby 2.4.2p198 (2017-09-14 revision 59899) [x64-mingw32]
   program_name=C:/opscode/chef/bin/chef-client
   executable=C:/opscode/chef/bin/chef-client


   Running handlers:
   [2017-09-20T13:38:53-07:00] ERROR: Running exception handlers
   Running handlers complete
   [2017-09-20T13:38:53-07:00] ERROR: Exception handlers complete
   Chef Client failed. 0 resources updated in 03 seconds
   [2017-09-20T13:38:53-07:00] FATAL: Stacktrace dumped to C:/Users/vagrant/AppData/Local/Temp/kitchen/cache/chef-stacktrace.out
   [2017-09-20T13:38:53-07:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
   [2017-09-20T13:38:53-07:00] FATAL: Net::HTTPServerException: 412 "Precondition Failed"
 ------Exception-------
Class: Kitchen::ActionFailed
Message: 1 actions failed.
 Converge failed on instance <default-win-2012r2-standard-amd64-nocm>.  
Please see .kitchen/logs/default-win-2012r2-standard-amd64-nocm.log for more details
 Please see .kitchen/logs/kitchen.log for more details
Also try running `kitchen diagnose --all` for configuration

将以下内容添加到 Berksfile(在 "metadata" 下):

cookbook 'printserver'

澄清一下:如果这是您创建的食谱,您需要做一些事情:

如果您在本地有食谱,则需要添加 path: '../printserver/' 或类似内容。它需要相对于当前路径。

如果它在 github 上,请添加类似 git: 'git@github.com/my_org/printserver.git', 'master'

的内容

因此,将所有这些放在一起,在您的本地系统上使用相对路径:

cookbook 'printserver', path: '../printserver'

对于git:

cookbook 'printserver', git: 'git@github.com/your_org/printserver.git', 'master'

最后,运行berks install。如果仍然有问题,请告诉我。

我最后按顺序做了什么:

  • 将食谱从工作笔记本电脑带到家用 PC 上进行测试,按预期工作。
  • 卸载了 chef、vagrant 和 virtual box 并在家用 PC 上使用相同版本重新安装,仍然是同样的问题。
  • 此时我对花了多少时间试图解决这个问题感到恼火,所以我重新映像了笔记本电脑并重新安装了所有东西(最新版本),现在它可以正常工作了。

首先出了什么问题?我没有线索。

附带说明一下,如果有人对与 Chef 一起创建 windows 2012 打印服务器有任何好的参考,将会非常有帮助。

我通过向 Berksfile 添加 metadata 行解决了这个问题。