Way to rename a chef cookbook

chefchef-serverconfiguration-management

My cookbook conflicts with a community cookbook.
There doesn't seem to be a knife option to rename or delete a cookbook.

Is there a way to delete a chef cookbook from a server or a way to rename an existing cookbook?

Best Answer

I just realized what to do. (And that my question was improperly using the word recipe instead of cookbook)

So, my current state is that I have a cookbook called (for example) cookbook_name and I want to import a community cookbook of the same name.

cookbook_name (existing)
cookbook_name (new)

I figure it's easier to rename my cookbook since I wrote it and know every place I refer to the cookbook name.

Rename my old cookbook on the local filesystem:

mv cookbook_name new_cookbook_name

update the metadata file:

sed -i "s/cookbook_name/new_cookbook_name/" new_cookbook_name/metadata.rb

upload to chef server

knife cookbook upload new_cookbook_name

place the new cookbook in the cookbook home path:

mv ~/cookbook_name ${cookbook/path}/cookbook_name

and upload the new cookbook overwriting the old

knife cookbook upload cookbook_name

Now I have my old cookbook uploaded with a new name and I can upload the new cookbook and the chef server will happily overwrite the old cookbook with the new one.

Also, knife supports cookbook delete

knife cookbook delete COOKBOOK VERSION (options)
Related Topic