2016-11-27 3 views
-1
Recipe Compile Error in /var/chef/cache/cookbooks/ambari/recipes/blueprints.rb 

NoMethodError 
------------- 
    undefined method `[]' for nil:NilClass 

Cookbook Trace: 
--------------- 
    /var/chef/cache/cookbooks/ambari/recipes/blueprints.rb:54:in `block in from_file' 
    /var/chef/cache/cookbooks/ambari/recipes/blueprints.rb:53:in `from_file' 
    /var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat /monkeypatches/chef/run_context.rb:347:in `load_recipe' 

Relevant File Content: 
---------------------- 
/var/chef/cache/cookbooks/ambari/recipes/blueprints.rb: 

    47:  end 
    48: end 
    49: 
    50: basic_auth_parameters = "--user #{node['ambari']['admin_user']}:#{node['ambari']['admin_password']}" 
    51: 
    52: 
    53: file '/tmp/blueprint.json' do 
    54>> content Chef::JSONCompat.to_json_pretty(node['ambari']['blueprints']['blueprint_json'].to_hash) 
    55: end 
    56: 
    57: file '/tmp/cluster.json' do 
    58: content Chef::JSONCompat.to_json_pretty(node['ambari']['blueprints']['cluster_json'].to_hash) 
    59: end 
    60: 
    61: execute 'Init Blueprints' do 
    62: command "curl #{basic_auth_parameters} -H 'X-Requested-By:ambari-cookbook' --data @/tmp/blueprint.json #{ambari_server_fqdn}:8080/api/v1/blueprints/#{node['ambari']['blueprints']['blueprint_name']}" 
    63: end 

Platform: 
--------- 
x86_64-linux 


Running handlers: 
    [2016-11-27T13:15:03-06:00] ERROR: Running exception handlers 
Running handlers complete 
    [2016-11-27T13:15:03-06:00] ERROR: Exception handlers complete 
Chef Client failed. 0 resources updated in 09 seconds 
    [2016-11-27T13:15:03-06:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out 
    [2016-11-27T13:15:03-06:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report 
    [2016-11-27T13:15:03-06:00] ERROR: undefined method `[]' for nil:NilClass 
    [2016-11-27T13:15:03-06:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1) 

答えて

2

ノード属性の仲介キーの1つが設定されていません。クックブックの属性ファイルにデフォルト値を設定するか、設定されていることを確認してください。

+0

回答ありがとうございます。以下のコード行に入力ファイルを指定する必要があります。以下のコードコンテンツの入力を指定する方法がありません。Chef :: JSONCompat.to_json_pretty(node ['ambari'] [ chef :: JSONCompat.to_json_pretty(node ['ambari'] ['blueprints'] ['cluster_json']。to_hash) – kasi

+0

基本シェフのチュートリアルはhttps ://learn.chef.io/ですが、一般的には、クックブックのアトリビュートファイルのデフォルト値を設定してから、ロールや環境やポリシーでオーバーライドを設定します。 – coderanger