I might be doing something wrong, but here is the situation. Standalone Chef server 12.3.0. CentOS 6.3 running on AWS.
During execution of knife bootstrap
I am applying hostname:default recipe to change server's FQDN along with some other recipes. Everything iseems to be fine. Chef server shows newly boostrapped instance, but Node Name column is still showing old FQDN, smth like ip-x-x-x-x.aws-region-name.compute.internal.
Then I try to ssh this host and run chef-client
I am getting following error:
[ec2-user@newHostName ~]$ sudo chef-client
Starting Chef Client, version 12.3.0
Chef encountered an error attempting to load the node data for "newHostName"
Authentication Error:
----------------
Failed to authenticate to the chef server (http 401).
Server Response:
----------------
Failed to authenticate as 'newHostName'. Ensure that your node_name and client key are correct.
Relevant Config Settings:
-------------------------
chef_server_url "https://chefServerDomain/organizations/organizationName"
node_name "newHostName"
client_key "/etc/chef/client.pem"
If these settings are correct, your client_key may be invalid, or
you may have a chef user with the same client name as this node.
[2015-05-04T12:36:03-07:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
Chef Client failed. 0 resources updated in 0.962848623 seconds
[2015-05-04T12:36:03-07:00] ERROR: 401 "Unauthorized"
[2015-05-04T12:36:03-07:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
I have checked closed issue #8 on GitHub, according to which I need manually change client.rb file and include node_name parameter. At the same time Chef client.rb documentation indicates that I should not do that :
node_name is used to determine which configuration should be applied and to set the client_name (which is the name used when authenticating to a Chef server). The default value is set automatically to be the FQDN of the chef-client, as detected by Ohai. In general, leaving this setting blank and letting Ohai assign the FQDN of the node as the node_name during each chef-client run is the recommended approach.
After cleaning up /etc/chef/* folder, removing this instance from Chef server and re-bootstrapping EC2 instance again I was able to make it work. FQDN was displayed correctly in Chef server under Node Name column as newServerName.
Could you please advise, what should I do to avoid double bootsrapping?
pass the node name you want the node to use into with "-N hostname" to the bootstrap command. Then it will register properly with the final node name.