我正在使用厨师开源版本13.6.4并且遇到了我无法用Policyfile解决的问题。我根据下面给出的最简单的烹饪书创建了一个简单的Policyfile(cookbooks \ test_prospero \ default.rb)
root_install_path = 'e:\\prospero'.freeze
node_fqdn = node['fqdn'].to_s.downcase
Chef::Log.info "Detected node : #{node_fqdn}"
Policyfile.rb是:
name "test_prospero"
default_source :chef_repo, '../'
run_list "test_prospero::default"
cookbook "test_prospero"
我安装了具有以下结果的策略文件:
Microsoft Windows [Version 10.0.16299.192]
(c) 2017 Microsoft Corporation. All rights reserved.
c:\chef-data\chef-repo\policies>chef install
Building policy test_prospero
Expanded run list: recipe[test_prospero::default]
Caching Cookbooks...
Installing test_prospero 0.1.2
Lockfile written to c:/chef-data/chef-repo/policies/Policyfile.lock.json
Policy revision id: 4e4b44089fe5a4ccd6656d419153e6d642d21c3392be2f74126b69f477c59118
将其推到服务器上:
Uploading policy to policy group build-group
Using test_prospero 0.1.2 (8232678b)
c:\ chef-data \ chef-repo \ policies> chef show-policy
test_prospero
=============
* build-group: 4e4b44089f
使用以下配置client.rb:
在一个已经引导的节点上运行chef_server_url "https://chef.sage.ch/organizations/sage-system"
validation_client_name "sage-system-validator"
file_cache_path "c:/chef/cache"
file_backup_path "c:/chef/backup"
cache_options ({:path => "c:/chef/cache/checksums", :skip_expires => true})
node_name "Prospero-9.9.9-RELEASE-Deploy-S1VW1730"
log_level :info
log_location STDOUT
trusted_certs_dir "c:/chef/trusted_certs"
policy_name "test_prospero"
policy_group "build-group"
use_policyfile true
policy_document_native_api true
current_version = Gem::Version.new(Chef::VERSION)
unless Gem::Requirement.new(">= 12.7").satisfied_by?(current_version)
puts("!" * 80)
puts(<<-MESSAGE)
This Chef Repo requires features introduced in Chef 12.7, but you are using
Chef #{Chef::VERSION}. Please upgrade to Chef 12.7 or later.
MESSAGE
puts("!" * 80)
exit!(1)
end
在dos提示符下运行chef-client我遇到以下错误:
c:\>chef-client
Starting Chef Client, version 13.6.4
[2018-01-29T16:48:48+01:00] INFO: *** Chef 13.6.4 ***
[2018-01-29T16:48:48+01:00] INFO: Platform: x64-mingw32
[2018-01-29T16:48:48+01:00] INFO: Chef-client pid: 3288
[2018-01-29T16:48:48+01:00] INFO: The plugin path C:\chef\ohai\plugins does not exist. Skipping...
Using policy 'test_prospero' at revision '4e4b44089fe5a4ccd6656d419153e6d642d21c3392be2f74126b69f477c59118'
[2018-01-29T16:48:55+01:00] INFO: Run List is [["recipe[test_prospero::default]"]]
[2018-01-29T16:48:55+01:00] INFO: Run List expands to [test_prospero::default@0.1.2 (8232678)]
[2018-01-29T16:48:55+01:00] INFO: Starting Chef Run for Prospero-9.9.9-RELEASE-Deploy-S1VW1730
[2018-01-29T16:48:55+01:00] INFO: Running start handlers
[2018-01-29T16:48:55+01:00] INFO: Start handlers complete.
[2018-01-29T16:48:55+01:00] INFO: Error while reporting run start to Data Collector. URL: https://chef.sage.ch/organizations/sage-system/data-collector Exception: 404 -- 404 "Not Found" (This is n
al if you do not have Chef Automate)
resolving cookbooks for run list: ["test_prospero::default@0.1.2 (8232678)"]
[2018-01-29T16:48:55+01:00] INFO: Loading cookbooks [test_prospero@0.1.2]
Synchronizing Cookbooks:
Installing Cookbook Gems:
Compiling Cookbooks...
================================================================================
Recipe Compile Error
================================================================================
Chef::Exceptions::RecipeNotFound
--------------------------------
could not find recipe default for cookbook test_prospero
System Info:
------------
chef_version=13.6.4
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:
[2018-01-29T16:48:55+01:00] ERROR: Running exception handlers
Running handlers complete
[2018-01-29T16:48:55+01:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 06 seconds
[2018-01-29T16:48:55+01:00] FATAL: Stacktrace dumped to c:/chef/cache/chef-stacktrace.out
[2018-01-29T16:48:55+01:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2018-01-29T16:48:55+01:00] FATAL: Chef::Exceptions::RecipeNotFound: could not find recipe default for cookbook test_prospero
我尝试了各种default_source配置,并使用导出运行它与厨师零,没有问题,阅读文档和其他网站(例如YoloVer),似乎没有人有相同的情况。
不使用policyfile运行的同一本食谱不会产生任何错误!
c:\>chef-client -o test_prospero
Starting Chef Client, version 13.6.4
[2018-01-29T17:19:55+01:00] INFO: *** Chef 13.6.4 ***
[2018-01-29T17:19:55+01:00] INFO: Platform: x64-mingw32
[2018-01-29T17:19:55+01:00] INFO: Chef-client pid: 816
[2018-01-29T17:19:55+01:00] INFO: The plugin path C:\chef\ohai\plugins does not exist. Skipping...
[2018-01-29T17:20:01+01:00] WARN: Run List override has been provided.
[2018-01-29T17:20:01+01:00] WARN: Original Run List: []
[2018-01-29T17:20:01+01:00] WARN: Overridden Run List: [recipe[test_prospero]]
[2018-01-29T17:20:01+01:00] INFO: Run List is [recipe[test_prospero]]
[2018-01-29T17:20:01+01:00] INFO: Run List expands to [test_prospero]
[2018-01-29T17:20:01+01:00] INFO: Starting Chef Run for Prospero-9.9.9-RELEASE-Deploy-S1VW1730
[2018-01-29T17:20:01+01:00] INFO: Running start handlers
[2018-01-29T17:20:01+01:00] INFO: Start handlers complete.
[2018-01-29T17:20:02+01:00] INFO: Error while reporting run start to Data Collector. URL: https://chef.sage.ch/organizations/sage-system/data-collector Exception: 404 -- 404 "Not Found" (This is norm
al if you do not have Chef Automate)
resolving cookbooks for run list: ["test_prospero"]
[2018-01-29T17:20:02+01:00] INFO: Loading cookbooks [test_prospero@0.1.2]
[2018-01-29T17:20:02+01:00] INFO: Skipping removal of obsoleted cookbooks from the cache
Synchronizing Cookbooks:
[2018-01-29T17:20:02+01:00] INFO: Storing updated cookbooks/test_prospero/metadata.rb in the cache.
[2018-01-29T17:20:02+01:00] INFO: Storing updated cookbooks/test_prospero/README.md in the cache.
[2018-01-29T17:20:02+01:00] INFO: Storing updated cookbooks/test_prospero/chefignore in the cache.
[2018-01-29T17:20:02+01:00] INFO: Storing updated cookbooks/test_prospero/recipes/default.rb in the cache.
- test_prospero (0.1.2)
Installing Cookbook Gems:
Compiling Cookbooks...
[2018-01-29T17:20:02+01:00] INFO: Detected node : s1vw1730.sage.ch
Converging 0 resources
[2018-01-29T17:20:02+01:00] WARN: Skipping final node save because override_runlist was given
[2018-01-29T17:20:02+01:00] INFO: Chef Run complete in 0.896052 seconds
[2018-01-29T17:20:02+01:00] INFO: Skipping removal of unused files from the cache
Running handlers:
[2018-01-29T17:20:02+01:00] INFO: Running report handlers
Running handlers complete
[2018-01-29T17:20:02+01:00] INFO: Report handlers complete
Chef Client finished, 0/0 resources updated in 07 seconds
您对此问题有任何线索或解决方案吗? 非常感谢你的帮助。
答案 0 :(得分:0)
食谱必须位于食谱中的recipes/
子文件夹中,因此cookbooks\test_prospero\recipes\default.rb
。