Chef infra Can';无法使用烹饪书在Windows上实现基本的厨师场景

Chef infra Can';无法使用烹饪书在Windows上实现基本的厨师场景,chef-infra,chef-recipe,windows-server,Chef Infra,Chef Recipe,Windows Server,在Windows服务器上安装了Chef client和DK,试图在本地模式下使用具有Windows功能的配方 运行以下命令 C:\chef>mkdir cookbooks C:\chef>cd cookbooks C:\chef\cookbooks>chef generate cookbook test_chef 将以下内容放入C:\chef\cookbooks\test\u chef\Berksfile source 'https://supermarket.chef.io

在Windows服务器上安装了Chef client和DK,试图在本地模式下使用具有Windows功能的配方

运行以下命令

C:\chef>mkdir cookbooks
C:\chef>cd cookbooks
C:\chef\cookbooks>chef generate cookbook test_chef
将以下内容放入C:\chef\cookbooks\test\u chef\Berksfile

source 'https://supermarket.chef.io'

metadata
cookbook 'windows', '~> 1.39.2'
将以下内容放入C:\chef\cookbooks\test\u chef\recipes\default.rb

windows_feature "NetFx3" do
  action :install
  all true
end
运行以下命令

C:\chef\cookbooks\test_chef>berks vendor install
Resolving cookbook dependencies...
Fetching 'test_chef' from source at .
Using chef_handler (1.3.0)
Using test_chef (0.1.0) from source at .
Using windows (1.39.2)
Vendoring chef_handler (1.3.0) to install/chef_handler
Vendoring test_chef (0.1.0) to install/test_chef
Vendoring windows (1.39.2) to install/windows

C:\chef\cookbooks\test_chef>chef-client --local-mode --runlist 'recipe[test_chef]
[2016-04-16T04:44:06+00:00] WARN: No config file found or specified on command line, using command line options.
Starting Chef Client, version 12.8.1
resolving cookbooks for run list: ["test_chef"]
Synchronizing Cookbooks:
  - test_chef (0.1.0)
Installing Cookbook Gems:
Compiling Cookbooks...
←[0m
================================================================================
Recipe Compile Error in C:/Users/admin/.chef/local-mode-cache/cache/cookbooks/test_chef/recipes/default.rb
================================================================================

NoMethodError
-------------
No resource or method named `windows_feature' for `Chef::Recipe "default"'

←[0m
Running handlers:
[2016-04-16T04:44:10+00:00] ERROR: Running exception handlers
Running handlers complete
[2016-04-16T04:44:10+00:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 03 seconds
[2016-04-16T04:44:10+00:00] FATAL: Stacktrace dumped to C:/Users/admin/.chef/local-mode-cache/cache/chef-stacktrace.out
[2016-04-16T04:44:10+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2016-04-16T04:44:10+00:00] FATAL: NoMethodError: No resource or method named `windows_feature' for `Chef::Recipe "defau
lt"'
因此,即使我正在使用berks供应商安装,并且它成功地将windows cookbook下载到cookbooks文件夹,chef客户端仍然尝试使用windows_功能


我基本上是逐字跟随一个在线示例。

而不是将以下行添加到您的
Berksfile

cookbook 'windows', '~> 1.39.2'
将此行添加到您的
元数据.rb

depends 'windows', '~> 1.39.2'

Berkshelf仍然可以从超市下载此依赖项(因为它被添加为
源代码
),但是也不是
chef-client
会在你的菜谱之前加载windows菜谱,因此
windows\u功能
资源会被知道。

这有什么实际区别吗?缺少菜谱:-------------没有这样的菜谱:windows我还需要berksfile还是什么吗?所以我做了berks供应商菜谱,然后是chef客户端,现在我得到了未初始化的常量chef::Provider::WindowsFeature::ServerManagerCmd正如所说,Berkshellf将从定义的源(即chef supermarket)下载烹饪书。这包含了
metadata.rb
中指定的食谱的依赖项。当执行
chef-client
时,它将在chef运行的编译阶段加载所有cookbooks的资源,从而使它们对所有cookbooks可用。这就是为什么需要在
metadata.rb
中将其指定为依赖项。