Chef convergence fails with ERROR: Unable to determine node name: configure node_name or configure the system's hostname and fqdn

Chef convergence fails with ERROR: Unable to determine node name: configure node_name or configure the system's hostname and fqdn

我的服务器无法收敛以下消息。我无法确定此错误的来源。

我正在复制并粘贴以下 client.log 消息后的 Chef 堆栈跟踪:

奇怪的是 client.rb 文件 stacktrace 所指的甚至不存在于此框中。

任何帮助将不胜感激!

[root@xyz chef]# tail client.log

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 

[2016-04-21T11:47:24-06:00] INFO: *** Chef 11.12.8 ***
[2016-04-21T11:47:24-06:00] INFO: Chef-client pid: 7309
[2016-04-21T11:47:24-06:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2016-04-21T11:47:24-06:00] ERROR: Unable to determine node name: configure node_name or configure the system's hostname and fqdn
[2016-04-21T11:47:24-06:00] ERROR: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
[2016-04-21T11:47:24-06:00] ERROR: Sleeping for 3600 seconds before trying again
[2016-04-21T11:51:10-06:00] INFO: SIGTERM received, exiting gracefully

堆栈跟踪:

cat /var/chef/cache/chef-stacktrace.out
Generated at 2016-04-21 11:47:24 -0600
Chef::Exceptions::CannotDetermineNodeName: Unable to determine node name:    configure node_name or configure the system's hostname and fqdn
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-  11.12.8/lib/chef/client.rb:299:in `node_name'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/client.rb:313:in `register'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/client.rb:416:in `do_run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/client.rb:213:in `block in run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/client.rb:207:in `fork'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/client.rb:207:in `run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/application.rb:217:in `run_chef_client'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/application/client.rb:328:in `block in run_application'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/application/client.rb:317:in `loop'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/application/client.rb:317:in `run_application'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/application.rb:67:in `run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/bin/chef-client:26:in `<top (required)>'
/usr/bin/chef-client:23:in `load'
/usr/bin/chef-client:23:in `<main>'[root@xyz chef]# 

如您所见,配置文件不存在。您必须创建它并定义提到的选项。有关详细信息,请参阅 documentation

您需要在 /etc/chef/client.rb 中配置一个 node_name。有时 Ohai 可以自己解决这个问题,但在您的情况下似乎并非如此。检查 hostnamehostname -f/etc/hostname 文件以查看您的服务器的配置。

我个人总是在 Chef 中定义我的 node_name,然后使用节点名称设置主机名和 fqdn...而不是 Chef 文档推荐的相反方式,具体取决于您的设置。

例如,我的 client.rb 看起来像:

chef_server_url "..."
client_fork true
log_location "/var/log/chef/client.log"
validation_client_name "...-validator"
verify_api_cert true # you might not want this one unless you have a valid cert
node_name "my_node_name" # Add this line
...

来自大厨client.rbdocs

node_name The name of the node. Determines which configuration should be applied and sets the client_name, which is the name used when authenticating to a Chef server. The default value is the FQDN of the chef-client, as detected by Ohai. In general, Chef recommends that you leave this setting blank and let Ohai assign the FQDN of the node as the node_name during each chef-client run.

作为上述方法的替代方法,修复您的服务器,以便 hostname -f 显示某些内容。

正如其他人指出的那样,11.12.8 在这一点上是一种古老的代码。您似乎确实添加了补丁以将 ohai[:machinename] 添加到 node_name 的检测中,这意味着它应该回退到 hostname (至少应该是空字符串 I会想吗?我们可以为主机名设置一个空字符串吗?)这样可以避免异常。

也许你的ohai版本也太旧了node[:machinename]?但是ohai和chef-client的补丁基本上是同时进去的

我真的是最后一个接触 node_name 检测代码的人,我看不出你会如何遇到那个异常...

我最好的建议是看看您是否可以在更新版本的 chef-client 综合安装上复制它,因为 "should" 永远不会发生。可能为了调试它,我们需要知道 ohai 在您的机器上的输出是什么(特别包括 hostnamemachinenamefqdndomain 值)。还有 运行 /bin/hostname/bin/hostname -f.

的输出