配方编译错误:未定义的方法`[]'为nil:NilClass

时间:2016-10-14 23:28:57

标签: tomcat jenkins chef chef-recipe cookbook

在此发布新内容......以及使用Chef ...但我正在制作一个简单的节点奴隶食谱,并继续在我制作的每本食谱上都出现此错误。我搜索并寻求帮助,但似乎无法在任何地方找到任何有关此问题的见解...任何帮助或建议都是真正的赞赏!

`安装Cookbook宝石:        编辑食谱......

   ================================================================================
   Recipe Compile Error in /tmp/kitchen/cache/cookbooks/jenkins/attributes/default.rb
   ================================================================================

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

   Cookbook Trace:
   ---------------
     /tmp/kitchen/cache/cookbooks/jenkins/attributes/default.rb:6:in `from_file'

   Relevant File Content:
   ----------------------
   /tmp/kitchen/cache/cookbooks/jenkins/attributes/default.rb:

     1:  default['jenkins']['user'] = 'jenkins'
     2:  default['jenkins']['group'] = 'jenkins'
     3:  default['jenkins']['home'] = '/home/jenkins'
     4:  default['jenkins']['work_dir'] = '/opt/jenkins'
     5:  
     6>> if node['tomcat']['base_version'] > 6
     7:    default['jenkins']['tomcat_service'] = 'tomcat'
     8:    default['jenkins']['install_dir'] = '/usr/share/tomcat/webapps'
     9:  else
    10:    default['jenkins']['tomcat_service'] = "tomcat#{node['tomcat']['base_version']}"
    11:    default['jenkins']['install_dir'] = "/usr/share/tomcat#{node['tomcat']['base_version']}/webapps"
    12:  end
    13:  default['jenkins']['build_dependencies'] = []
    14:  default['jenkins']['versioned_packages'] = []
    15:  # Example:

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


   Running handlers:
   [2016-10-14T22:58:04+00:00] ERROR: Running exception handlers
   Running handlers complete
   [2016-10-14T22:58:04+00:00] ERROR: Exception handlers complete
   Chef Client failed. 0 resources updated in 22 seconds
   [2016-10-14T22:58:04+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
   [2016-10-14T22:58:04+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
   [2016-10-14T22:58:04+00:00] ERROR: undefined method `[]' for nil:NilClass
   [2016-10-14T22:58:05+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)`

我的工作要求我运行此版本的Chef:

Chef Development Kit Version: 0.15.16 chef-client version: 12.11.18 delivery version: master (444effdf9c81908795e88157f01cd667a6c43b5f) berks version: 4.3.5 kitchen version: 1.10.0

1 个答案:

答案 0 :(得分:0)

node['tomcat']未设置,因此您无法使用其下方的值。这可能意味着您错过了metadata.rb文件中的依赖项。