我正在使用厨师来引导节点。我创建了加密数据包并将密钥复制到节点上/ 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>'
任何帮助或指示?
答案 0 :(得分:3)
我已经解决了这个问题。看来环境没有正确创建。因此,当我引导节点时,其环境被设置为“_default”,因此节点无法找到项目。
我重新创建了环境,并通过传递--environment参数来引导节点,并且我能够在没有任何问题的情况下进行引导。
再次感谢所有贡献者的投入。这个社区太棒了!
答案 1 :(得分: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 复制到节点,所以应该这样做。