我是廚師的新手,並開始使用用戶庫編寫簡單的食譜。我Berksfile:致命錯誤:NoMethodError:未定義的方法`unreachable_cookbook?'爲零:NilClass
[email protected]:~/chef-repo$ cat Berksfile
site :opscode
cookbook "users"
,然後我跑:
berks install
和我的食譜:
[email protected]:~/chef-repo$ ls cookbooks/
users
終於我的食譜:
[email protected]:~/chef-repo$ cat blah-users.rb
include_recipe "users"
users_manage "blah-dev" do
group_id 1001
action [ :remove, :create ]
end
當我appply我得到一個錯誤:
[email protected]:~/chef-repo$ chef-apply blah-users.rb
[2015-05-04T09:05:48-04:00] FATAL: Stacktrace dumped to /home/name/.chef/cache/chef-stacktrace.out
[2015-05-04T09:05:48-04:00] FATAL: NoMethodError: undefined method `unreachable_cookbook?' for nil:NilClass
我相當肯定的是,include_recipe「用戶」是問題(至少第一個)。我也發現這行Stacktrace轉儲到/home/name/.chef/cache/chef-stacktrace.out有趣的是,在那個位置沒有文件。
我嘗試過和沒有sudo。所以我不認爲這是一個權限問題。
我運行一個本地安裝的廚師服務器12.3看起來能正常運行罰款......
感謝
~/chef-repo$ sudo chef-apply blah-users.rb -l debug
[2015-05-04T13:17:50-04:00] DEBUG: Building node object for tbrown
[2015-05-04T13:17:50-04:00] DEBUG: Extracting run list from JSON attributes provided on command line
[2015-05-04T13:17:50-04:00] DEBUG: Applying attributes from json file
[2015-05-04T13:17:50-04:00] DEBUG: Platform is ubuntu version 14.04
[2015-05-04T13:17:50-04:00] INFO: Run List is []
[2015-05-04T13:17:50-04:00] INFO: Run List expands to []
[2015-05-04T13:17:50-04:00] DEBUG: Loading Recipe users via include_recipe
[2015-05-04T13:17:50-04:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2015-05-04T13:17:50-04:00] DEBUG: NoMethodError: undefined method `unreachable_cookbook?' for nil:NilClass
/opt/chefdk/embedded/apps/chef/lib/chef/run_context.rb:257:in `unreachable_cookbook?'
/opt/chefdk/embedded/apps/chef/lib/chef/run_context.rb:155:in `load_recipe'
/opt/chefdk/embedded/apps/chef/lib/chef/run_context.rb:142:in `block in include_recipe'
/opt/chefdk/embedded/apps/chef/lib/chef/run_context.rb:141:in `each'
/opt/chefdk/embedded/apps/chef/lib/chef/run_context.rb:141:in `include_recipe'
/opt/chefdk/embedded/apps/chef/lib/chef/dsl/include_recipe.rb:26:in `include_recipe'
blah-users.rb:1:in `run_chef_recipe'
/opt/chefdk/embedded/apps/chef/lib/chef/application/apply.rb:168:in `instance_eval'
/opt/chefdk/embedded/apps/chef/lib/chef/application/apply.rb:168:in `run_chef_recipe'
/opt/chefdk/embedded/apps/chef/lib/chef/application/apply.rb:180:in `run_application'
/opt/chefdk/embedded/apps/chef/lib/chef/application/apply.rb:193:in `run'
/opt/chefdk/embedded/apps/chef/bin/chef-apply:25:in `<top (required)>'
/usr/bin/chef-apply:51:in `load'
/usr/bin/chef-apply:51:in `<main>'
[2015-05-04T13:17:50-04:00] FATAL: NoMethodError: undefined method `unreachable_cookbook?' for nil:NilClass
願你嘗試用'廚師申請等等,users.rb的-l debug'。總之,我不確定廚師 - 申請可以用於依賴(即需要從另一個食譜的配方),因爲它只是用來運行一小部分內部資源,並且沒有烹飪書的加載(所以沒有讀取'metadata.rb'因爲沒有)。我能想到的最佳解決方法是使用chef-solo或chef-zero(請參閱http://docs.chef.io查看已發佈的信息),並在其metadata.rb文件中具有正確的依賴關係。 – Tensibai
metadata.rb需要「依賴」「用戶」菜譜 – akaphenom
您可能想要添加該答案(並接受它),以便稍後有人發現此問題時,他們可以輕鬆找到答案。 –