Chef:未定义的方法`platform_version'

时间:2017-04-24 09:58:08

标签: chef

当chef_client运行食谱时,我收到一条错误消息。到目前为止,我已经弄清楚它告诉我:

  

未定义的方法`platform_version'

我尝试使用centos / 7,版本:1611.011703.01执行配方。在这里,您可以看到完整的跟踪:

==> default: ================================================================================
==> default: Recipe Compile Error in /var/chef/cache/cookbooks/living-development/recipes/default.rb
==> default: ================================================================================
==> default:
==> default: NoMethodError
==> default: -------------
==> default: undefined method `platform_version' for #<Chef::Node::Attribute:0x00000004f4f480>
==> default:
==> default: Cookbook Trace:
==> default: ---------------
==> default:   /var/chef/cache/cookbooks/mongodb3/recipes/package_repo.rb:26:in `from_file'
==> default:   /var/chef/cache/cookbooks/mongodb3/recipes/default.rb:20:in `from_file'
==> default:   /var/chef/cache/cookbooks/living-development/recipes/mongodb.rb:9:in `from_file'
==> default:   /var/chef/cache/cookbooks/living-development/recipes/default.rb:11:in `from_file'
==> default:
==> default: Relevant File Content:
==> default: ----------------------
==> default: /var/chef/cache/cookbooks/mongodb3/recipes/package_repo.rb:
==> default:
==> default:  19:
==> default:  20:  pkg_major_version = node['mongodb3']['version'].to_f # eg. 3.0, 3.2
==> default:  21:
==> default:  22:  # Setup default package version attribute to install
==> default:  23:  pkg_version = node['mongodb3']['version']
==> default:  24:  case node['platform_family']
==> default:  25:    when 'rhel', 'fedora'
==> default:  26>>     pkg_version =  "#{node['mongodb3']['version']}-1.el#{node.platform_version.to_i}" # ~FC019
==> default:  27:      if node['platform'] == 'amazon'
==> default:  28:        pkg_version = "#{node['mongodb3']['version']}-1.amzn1" # ~FC019
==> default:  29:      end
==> default:  30:  end
==> default:  31:
==> default:  32:  # Setup default package repo url attribute for each platform family or platform
==> default:  33:  case node['platform']
==> default:  34:    when 'redhat', 'oracle','centos', 'fedora' # ~FC024
==> default:  35:      pkg_repo = "https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/#{pkg_major_version}/#{node['kernel']['machine'] =~ /x86_64/ ? 'x86_64' : 'i686'}"
==> default:
==> default: System Info:
==> default: ------------
==> default: chef_version=13.0.118
==> default: platform=centos
==> default: platform_version=7.3.1611
==> default: ruby=ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
==> default: program_name=chef-client worker: ppid=12132;start=09:52:48;
==> default: executable=/opt/chef/bin/chef-client
==> default:
==> default: Running handlers:
==> default: [2017-04-24T09:53:06+00:00] ERROR: Running exception handlers
==> default: Running handlers complete
==> default: [2017-04-24T09:53:06+00:00] ERROR: Exception handlers complete
==> default: Chef Client failed. 0 resources updated in 18 seconds
==> default: [2017-04-24T09:53:06+00:00] INFO: Sending resource update report (run-id: 30b10346-fc52-4aac-86cd-f76ccd8e0576)
==> default: [2017-04-24T09:53:07+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
==> default: [2017-04-24T09:53:07+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
==> default: [2017-04-24T09:53:07+00:00] ERROR: undefined method `platform_version' for #<Chef::Node::Attribute:0x00000004f4f480>
==> default: [2017-04-24T09:53:07+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.

有什么想法吗?

周围的工作:

config.vm.provision "chef_client" do |chef|
    ...
    chef.version = '12.19.36'
end

1 个答案:

答案 0 :(得分:4)

我们删除了Chef 13中节点属性的方法语法。代码需要更新为4/21/2017 4/09/2017 4/02/2017 4/01/2017