Chef: remove the node with a knife and add it later

Say knife node delete 'NODENAME' to remove the node from the chef's server, leaving the corresponding virtual machine as it is.

Is it possible, if I need to make changes to this server in the future, again add the virtual machine as a node and run the chef client (or any other chef team) on it?

+7
chef
source share
4 answers

Our use case involves creating virtual machines and loading them (using the host name as the name of the node chef). Nodes are often deleted and created over and over with the same name. When we destroy the virtual machine, we run two cleanup commands in Chef.

 knife node delete --yes NODENAME knife client delete --yes NODENAME 

Keep in mind that in our case, we are not interested in storing information about what the node was doing (i.e., a launch list or other attributes).

If you do not want to remove the server, you can run the above two commands to clear the node from the chef server, and then run the following commands on the machine to remove the chef locally. Once you're done, you can again chef load the machine again.

 #depending on how you installed chef yum -y remove chef OR rpm -e `rpm -q chef` # rpm -q chef returns the version of chef installed rm -rf /var/chef rm -rf /etc/chef rm -rf /opt/chef 
+12
source share

I think after removing the node from your chef server, the credentials of the machines you deleted disappeared from the server. Again, if you want to add the same node again, you must delete the client.pem file (/etc/chef/client.pem) in this node that was created by the previous download.

+3
source share

Attributes disappeared after removing node. Thus: no.

+2
source share

With this command, knife node delete 'NODENAME' you remove the node from the chef organization. But remember that node information (mainly a yml file), including various cookbooks, is stored in SCM. So you need to delete the entry or comment on the node you want to delete and register the code. So the next time you upload the cookbooks to the chef server, node will not be visible.

If you want to add it back, add it to your cookbook and write down the code. This is for SCM. Then upload the cookbook to the chef server. Now - when you make a customer chef, he will fail in a trembling hand.

Delete the /etc/chef/client.pem file (make sure the validation.pem file already exists) on the node. And run chef-client again

+1
source share

All Articles