首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使用食谱在Windows上获取Basic Chef场景

无法使用食谱在Windows上获取Basic Chef场景
EN

Stack Overflow用户
提问于 2016-04-16 12:46:37
回答 1查看 438关注 0票数 1

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

运行以下程序

代码语言:javascript
复制
C:\chef>mkdir cookbooks
C:\chef>cd cookbooks
C:\chef\cookbooks>chef generate cookbook test_chef

将以下内容放入C:\chef\cookbooks\test_chef\Berksfile

代码语言:javascript
复制
source 'https://supermarket.chef.io'

metadata
cookbook 'windows', '~> 1.39.2'

将以下内容放入C:\chef\cookbooks\test_chef\recipes\default.rb

代码语言:javascript
复制
windows_feature "NetFx3" do
  action :install
  all true
end

运行以下程序

代码语言:javascript
复制
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文件夹,chef客户端仍然尝试使用windows_feature。

我基本上是一字不差地遵循一个在线示例。

EN

回答 1

Stack Overflow用户

发布于 2016-04-16 14:19:43

而不是将以下代码行添加到Berksfile

代码语言:javascript
复制
cookbook 'windows', '~> 1.39.2'

将此行添加到您的metadata.rb

代码语言:javascript
复制
depends 'windows', '~> 1.39.2'

伯克架仍然可以从超市下载这个依赖项(因为它被添加为source),但chef-client不会在你的食谱之前加载windows食谱,因此windows_feature资源将是已知的。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36660212

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档