简体   繁体   English

Chef-client失败,因为client.rb中不存在node_name

[英]chef-client failing as node_name not present in client.rb

I followed a tutorial here to bootstrap and register a node to chef server. 我按照此处的指南进行引导,并将节点注册到Chef服务器。 The instance is in autoscaling group which is why I opted this method for bootstrapping. 该实例位于自动缩放组中,这就是为什么我选择此方法进行引导。 Scenario is - I am using client.rb, validation.pem, trusted_certs from s3 to newly launched instance via userdata. 方案是-我正在通过userdata使用从s3到新启动的实例的client.rb,validation.pem,trusted_certs。

client.rb client.rb

log_location     STDOUT
chef_server_url  "https://chef.myserver.org/organizations/org"
validation_client_name "org-validator"
# Using default node name (fqdn)
trusted_certs_dir "/etc/chef/trusted_certs"

After downloading required files following command get executed to run chef-client with $INSTANCE_ID as node_name. 下载所需文件后,执行以下命令以$ INSTANCE_ID作为node_name运行Chef-client。

chef-client -N $INSTANCE_ID -j /etc/chef/first-boot.json 厨师客户端-N $ INSTANCE_ID -j /etc/chef/first-boot.json

The initial bootstrapping is successful and the node gets registered to chef-server with instance-id as node-name but when running subsequent chef-client, it fails with the error: 初始引导成功,并且该节点以instance-id作为节点名注册到chef-server,但是在运行后续chef-client时,它失败并显示以下错误:

ERROR: 401 "Unauthorized" 

This is due to the node_name not present in client.rb. 这是由于node.name在client.rb中不存在。 How can I make the entry of node_name in client.rb during the very first chef-client run? 在第一次运行主客户端时,如何在client.rb中输入node_name?

This is generally handled in the userdata script or config, a la echo "node_name '$HOSTNAME'" >>/etc/chef/client.rb . 这通常在userdata脚本或配置中处理,例如echo "node_name '$HOSTNAME'" >>/etc/chef/client.rb The specifics can vary depending on your naming scheme, sometimes you'll make some string edits to $HOSTNAME or use a different name entirely. 具体情况可能会因您的命名方案而异,有时您会对$HOSTNAME进行一些字符串编辑,或者完全使用其他名称。 This isn't strictly required, but without a name in the config file, Chef uses whatever the current FQDN of the system is, and it sounds like something in the initial Chef run changes the FQDN. 这不是严格要求的,但是在配置文件中没有名称,Chef使用系统当前的FQDN,听起来像在Chef初始运行中更改了FQDN。 Another option is to just not do that. 另一种选择是不这样做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM