4

I've got a Chef node, bootstrapped with

knife bootstrap my.example.com --ssh-user USER --ssh-password 'PASSWORD' --sudo --use-sudo-password --node-name my.example.com

If I then format the node, how can I get Chef running on it again? I don't want to do knife client delete my.example.com as that will delete all the data from knife node edit my.example.com

Greg
  • 375
  • 1
  • 3
  • 13
  • All your node data is gone, as this is stored on the Chef server. The only thing that is on the client is the client key and (if not deleted) a validation key (to register as a client). Or what do you mean with "format the server"? Delete everything? What's your ultimate goal? – StephenKing Nov 16 '15 at 14:44
  • My goal is that if I have a server that gets destroyed, I can use Chef to re-install all the software & configs that was on it – Greg Nov 16 '15 at 16:23
  • At the moment, I can't get chef to run on the new server without having to delete the client and recreate the run-list – Greg Nov 16 '15 at 16:23
  • Ah okay, I get your point (for you server = node). Thought you mean server = chef server. – StephenKing Nov 16 '15 at 16:24
  • Ahh good point - I'll fix that – Greg Nov 16 '15 at 16:26
  • A short note: All data should be stored (and versioned!) in cookbooks/roles/environments. Never use `knife node edit` because of exactly this issue. You end up in a snowflake server that isn't reproducible anymore. – StephenKing Nov 16 '15 at 16:28
  • There is [knife client reregister](https://docs.chef.io/knife_client.html#reregister). I haven't used it, but you might call that on your workstation and copy over the key file to the node. – StephenKing Nov 16 '15 at 16:28
  • Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/31661/discussion-between-greg-and-stephenking). – Greg Nov 16 '15 at 16:35

2 Answers2

1

If you bring client.pem across to the new installation and use the same node_name in your /etc/chef/client.rb file then the new installation should inherit the client registration on chef server, so you don't need to deregister and re-register the node from the server.

aaaarrgh
  • 121
  • 3
-1

You will need to copy down the important data from the chef server (knife download nodes/my.example.com if you want to be lazy), delete the node and client from the server, and then rebootstrap. You could do with with only clearing the client, but you'll have to repair the ACLs manually and its generally a less convenient approach.

coderanger
  • 858
  • 4
  • 13