Is it safe to change the IP address and domain name of an Chef Node

chef

I have a Chef Node that I'm initially setting up on one network that I need to (physically) move to another network. When this happens, I want the IP address and domain name to change, and the Node name and simple hostname to stay the same.

I know I can do this by deleting the Chef Node and recreating it. Could I also do it by editing Node attributes? Or would that break the client keys or (worse still) the server?

(I'm using Chef 10.16.2 …)

Best Answer

Recreating the node (and client) with the new name is one option, but you can preserve the ones you already have. This requires client configuration - by the time the node retrieves attributes from the Chef server, it's already decided what its name is.

By default, chef-client will set the node name to the fully-qualified domain name of the host, as returned by ohai. You can check what name will be used by invoking ohai directly:

zts@chef ~ % ohai fqdn
[
  "chef.nat0.cryptocracy.com"
]

If that changes when you move the host, you'll need to edit /etc/chef/client.rb to set the desired nodename:

node_name "mynode.example.com"

Take a look at Chef Docs - client.rb for more about this configuration file.