2

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?

jorfus
  • 715
  • 7
  • 14

2 Answers2

3

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)
jorfus
  • 715
  • 7
  • 14
0

Another suggestion, using Atom editor, you can see easily where you need to change the name of a cookbook named base. After renaming, deleting the one that you upload to your chef-server and done! :)

enter image description here

Valter Silva
  • 190
  • 10