厨师客户端无法读取机器元数据

时间:2017-02-08 11:07:45

标签: ruby chef

我和厨师一起安装了几台服务器。 其中一个在运行时开始失败

sudo chef-client -j /etc/chef/first-boot.json

仅在其中一台机器上

调试时,错误是

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

跟踪

/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/data_collector/messages/helpers.rb:133:in `read_node_uuid'
  /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/data_collector/messages/helpers.rb:111:in `node_uuid'
  /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/data_collector/messages.rb:40:in `run_start_message'
  /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/data_collector.rb:130:in `block in run_started'
  /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/data_collector.rb:307:in `disable_reporter_on_error'
  /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/data_collector.rb:128:in `run_started'
  /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/event_dispatch/dispatcher.rb:43:in `call'
  /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/event_dispatch/dispatcher.rb:43:in `block in call_subscribers'
  /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/event_dispatch/dispatcher.rb:34:in `each'
  /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/event_dispatch/dispatcher.rb:34:in `call_subscribers'

该行是

metadata["node_uuid"]

通过阅读data_collector_metadata.json文件

来获取元数据
    def metadata
              Chef::JSONCompat.parse(Chef::FileCache.load(metadata_filename))
   rescue Chef::Exceptions::FileNotFound
          {}
 end

我正在努力解决这个问题......为什么这会在某些服务器上运行,而且它不会

1 个答案:

答案 0 :(得分:0)

找出问题所在。 不同之处在于厨师 - 客户版本 启动脚本使用最新版本重新安装厨师。 使用这个bash

curl -L "https://www.opscode.com/chef/install.sh" | bash

我已修改为特定版本的bash

curl -LO https://omnitruck.chef.io/install.sh && sudo bash ./install.sh -v 12.15.19 && rm install.sh

它有效