Search code examples
chef-infraknifecloud-init

How to script changing the node name of a client in chef from the client without knife


I have a "golden image" AMI and I want to put it in an autoscaling group that will take the image, rename it, and execute the run-llst. I just spent most of the day with cloud-config's chef feature, and it's not working because there are too many inconsistencies between the original chef environment and whatever cloud-config is using. It's also going to be less reliable and slow in the long-run because will have to chef from scratch every time. I want to take an instance that's had chef run on it and start from there. Looking around all I see are ways to do this manually and using knife. Is there a way to rewrite a few files and register the image with the chef server that way?


Solution

  • Look at the example I showed you last time. Thats exactly what it is for. The AMI has Chef pre-installed and has the validation certificate. At boot time, cloud-init runs the script I showed you which generates the client config and initial run list, and then registers with the chef server.