Reputation: 6681
Is it possible to undo a bootstrap?
I have to connect my node to a different Chef server. It is not possible to run the bootstrap twice. This will fail with unauthorized.
jupiter2 [2015-02-13T21:06:26+01:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
jupiter2 Chef Client failed. 0 resources updated in 0.856840378 seconds
jupiter2 [2015-02-13T21:06:26+01:00] ERROR: 401 "Unauthorized"
jupiter2 [2015-02-13T21:06:26+01:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
If possible I would rather not reinstall the OS but unfortunately undoing a boostrap does not seem to be possible. There is 'no' knife command and there is 'no' procedure for reversing the bootstrap.
Upvotes: 1
Views: 1809
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: 1
Reputation: 77951
Running the following SSH command will stop chef client and remove the current client configuration:
ssh root@myhost "service chef-client stop; mv /etc/chef /etc/chef.bak"
Knife bootstrap will re-create the "/etc/chef" directory.
Upvotes: 1