Chef + NoMethodError未定义的方法`[]'为nil:NilClass

时间:2016-12-12 23:43:20

标签: chef chef-recipe

我是Chef / DevOps的新手 - 尝试在下载其依赖项后在Windows节点上安装postgresql(5.1.0)。我收到以下错误

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

    Platform:
    ---------
    i386-mingw32

    [2016-12-12T10:37:22-05:00] DEBUG: Re-raising exception: NoMethodError - undefined method `[]' for nil:NilClass
    C:/chef/cache/cookbooks/postgresql/recipes/client.rb:35:in `from_file'
      C:/opscode/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42-universal-mingw32/lib/chef/mixin/from_file.rb:30:in `instance_eval'
      C:/opscode/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42-universal-mingw32/lib/chef/mixin/from_file.rb:30:in `from_file'
      C:/opscode/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42-universal-mingw32/lib/chef/cookbook_version.rb:233:in `load_recipe'
      C:/opscode/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42-universal-mingw32/lib/chef/run_context.rb:338:in `load_recipe'
      C:/opscode/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42-universal-mingw32/lib/chef/run_context.rb:294:in `block in include_recipe'
      C:/opscode/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42-universal-mingw32/lib/chef/run_context.rb:293:in `each'
      C:/opscode/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42-universal-mingw32/lib/chef/run_context.rb:293:in `include_recipe'
      C:/opscode/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42-universal-mingw32/lib/chef/dsl/include_recipe.rb:26:in `include_recipe'
      C:/chef/cache/cookbooks/postgresql/recipes/server.rb:22:in `from_file'
      C:/opscode/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42-universal-mingw32/lib/chef/mixin/from_file.rb:30:in `instance_eval'
      C:/opscode/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42-universal-mingw32/lib/chef/mixin/from_file.rb:30:in `from_file'
      C:/opscode/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42-universal-mingw32/lib/chef/cookbook_version.rb:233:in `load_recipe'
      C:/opscode/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42-universal-mingw32/lib/chef/run_context.rb:338:in `load_recipe'
      C:/opscode/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42-universal-mingw32/lib/chef/run_context/cookbook_compiler.rb:141:in `block in compile_recipes'
      C:/opscode/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42-universal-mingw32/lib/chef/run_context/cookbook_compiler.rb:138:in `each'
      C:/opscode/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42-universal-mingw32/lib/chef/run_context/cookbook_compiler.rb:138:in `compile_recipes'
      C:/opscode/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42-universal-mingw32/lib/chef/run_context/cookbook_compiler.rb:75:in `compile'
      C:/opscode/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42-universal-mingw32/lib/chef/run_context.rb:187:in `load'
      C:/opscode/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42-universal-mingw32/lib/chef/policy_builder/expand_node_object.rb:97:in `setup_run_context'
      C:/opscode/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42-universal-mingw32/lib/chef/client.rb:510:in `setup_run_context'

然后我在Berkshelf上发现了这个SO,基于它创建了一个Berksfile

     cookbook "postgresql"

它仅下载了以下依赖项'compat_resources','mingw','ohai','seven_zip'和'windows'

现在我最终得到了这个错误:

    ================================================================================
    Error Resolving Cookbooks for Run List:
    ================================================================================

    Missing Cookbooks:
    ------------------
    The following cookbooks are required by the client but don't exist on the server:
    * apt
    * build-essential
    * openssl


    Expanded Run List:
    ------------------
    * postgresql::server

    Platform:
    ---------
    i386-mingw32

我查看了metadata.json,可以看到Windows未被列为受支持的平台之一。那是什么原因?

    "platforms": {
    "ubuntu": ">= 12.04",
    "debian": ">= 7.0",
    "opensuse": ">= 13.0",
    "suse": ">= 12.0",
    "fedora": ">= 0.0.0",
    "opensuseleap": ">= 0.0.0",
    "amazon": ">= 0.0.0",
    "redhat": ">= 6.0",
    "centos": ">= 6.0",
    "scientific": ">= 6.0",
    "oracle": ">= 6.0"
},

需要帮助解决这个问题。

0 个答案:

没有答案