2

我正在使用厨师来引导一个节点。我创建了加密数据包并将节点上的密钥复制为 /etc/chef/encrypted_data_bag_secret。

当我尝试引导节点时,出现以下错误:

================================================================================
Recipe Compile Error in /var/chef/cache/cookbooks/webapps-configs/recipes/httpd.rb
================================================================================
 Net::HTTPServerException
 ------------------------
 404 "Not Found"
 Cookbook Trace:
 ---------------
   /var/chef/cache/cookbooks/webapps-configs/recipes/httpd.rb:12:in `from_file'
 Relevant File Content:
 ----------------------
 /var/chef/cache/cookbooks/webapps-configs/recipes/httpd.rb:

  10:
  11:  CHEF_ENV = node.chef_environment
  12>> http_ssl_creds = Chef::EncryptedDataBagItem.load("#{CHEF_ENV}", "http-ssl")
  13:  PRIVATE_KEY = http_ssl_creds["private_key"]
  14:  CHAIN_FILE= http_ssl_creds["chain_file"]
  15:  CERT= http_ssl_creds["cert"]
  16:

 ERROR: Running exception handlers
 FATAL: Saving node information to /var/chef/cache/failed-run-data.json
 ERROR: Exception handlers complete
 Chef Client failed. 0 resources updated
 FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
 FATAL: Net::HTTPServerException: 404 "Not Found"

这是堆栈跟踪:

Net::HTTPServerException: 404 "Not Found"
/opt/chef/embedded/lib/ruby/1.9.1/net/http.rb:2632:in `error!'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/rest.rb:199:in `block in raw_http_request'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/rest.rb:280:in `retriable_rest_request'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/rest.rb:164:in `raw_http_request'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/rest.rb:158:in `api_request'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/rest.rb:99:in `get'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/data_bag_item.rb:149:in `load'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/encrypted_data_bag_item.rb:294:in `load'
/var/chef/cache/cookbooks/webapps-configs/recipes/httpd.rb:12:in `from_file'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/mixin/from_file.rb:30:in `instance_eval'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/mixin/from_file.rb:30:in `from_file'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/cookbook_version.rb:346:in `load_recipe'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/run_context.rb:151:in `load_recipe'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/run_context/cookbook_compiler.rb:139:in `block in compile_recipes'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/run_context/cookbook_compiler.rb:137:in `each'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/run_context/cookbook_compiler.rb:137:in `compile_recipes'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/run_context/cookbook_compiler.rb:74:in `compile'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/run_context.rb:86:in `load'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/client.rb:224:in `setup_run_context'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/client.rb:467:in `do_run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/client.rb:200:in `run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/application.rb:190:in `run_chef_client'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/application/client.rb:297:in `block in run_application'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/application/client.rb:290:in `loop'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/application/client.rb:290:in `run_application'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/application.rb:73:in `run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/bin/chef-client:26:in `<top (required)>'
/usr/bin/chef-client:23:in `load'
/usr/bin/chef-client:23:in `<main>'

任何帮助或指示?

4

2 回答 2

3

我已经解决了这个问题。似乎环境没有正确创建。所以当我引导节点时,它的环境被设置为“_default”,因此节点无法找到这些项目。

我通过传递 --environment 参数重新创建了环境并引导节点,并且我能够毫无问题地引导。

再次感谢所有贡献者的投入。这个社区太棒了!

于 2013-03-21T12:20:08.233 回答
2

尝试将以下行添加到您的食谱中:

  11. CHEF_ENV = node.chef_environment
+ 12. Chef::Config[:encrypted_data_bag_secret]
  13. http_ssl_creds = Chef::EncryptedDataBagItem.load("#{CHEF_ENV}", "http-ssl")
  14. PRIVATE_KEY = http_ssl_creds['private_key']
  15. CHAIN_FILE= http_ssl_creds['chain_file']
  16. CERT= http_ssl_creds['cert']

另一个要检查的是节点环境是你的加密数据包的名称。

由于您已将/etc/chef/encrypted_data_bag_secret复制到节点,因此应该可以解决问题。

于 2013-03-20T23:24:23.743 回答