Reputation: 18582
Say do a knife node delete 'NODENAME'
to delete the node from chef server while leaving the corresponding VM running like it is.
Is it possible, if I need to make changes to that server in the future, to add the VM again as a node and run chef-client on it (or any other chef command for that matter)?
Upvotes: 9
Views: 15576
Reputation: 827
Our use case involves creating virtual machines and chef bootstrapping them (using the hostname as the chef node name). Nodes are often deleted and created over and over with the same name. When we destroy the virtual machine we run the two commands to clean up in Chef.
knife node delete --yes NODENAME
knife client delete --yes NODENAME
Keep in mind that in our use case we are not interested in keeping any information about what the node was doing (i.e., its run list or other attributes).
If you don't want to delete the server, you can run the above two commands to clean up the node from the chef server and then run the following commands on the machine to remove chef locally. Once done you can chef bootstrap 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
Upvotes: 16
Reputation: 1399
By this command knife node delete 'NODENAME'
you delete a node from a chef organization. But remember the node information (mostly a yml file) including the various cookbooks are stored in an SCM. So, you need to delete the entry or comment out the node that you want to be removed and check-in the code. So that the next time you upload the cookbooks to the chef-server the node will not be seen.
When you want to add it back, add it to your cookbook & Check-in the code. This is for the SCM. Then upload the cookbook to the chef-server. Now - when you do a chef-client, it will fail in the hand shake.
Delete the /etc/chef/client.pem (make sure the validation.pem is already there) on the node. And re-run the chef-client
Upvotes: 1
Reputation: 537
I think, after delete the node from your chef server the credentials of the machines which you delete was gone from the server. Again if you want to add the same node again then you must delete the client.pem (/etc/chef/client.pem) file in that node which was created by the previous bootstrap.
Upvotes: 4