How to rollback to the previous chef cookbook version

Hi,

Example I have a cookbook with the version 1.2.8.4. I uploaded to chef server. I realized I did something wrong with the cookbook content how do i rollback to previous version 1.2.8.3. Since this is production cookbook I do not want to take risk uploading wrong cookbook. I just changed the cookbook version in the metadata.rb still I see chef-server is using my recent cookbook I uploaded 1.2.8.4.

Does anyone have have suggestions to do better.

Thanks
Chefy

Use Git.

You can use knife cookbook delete to remove the broken version from your Chef Server. If you don’t want to delete it, you can also use environment restrictions to lock that node down to force the older version, though this might be tricky if you aren’t already using chef environments. Also check out the knife-solve plugin to see which version of each cookbook is going to be used on a node.

Knife cookbook delete

Then select 1.2.8.4 to remove.

Nathan Clemons
DevOps Engineer
Moxie Cloud Services (MCS)

O +1.425.467.5075
M +1.360.861.6291
E nclemons@gomoxie.com
W www.gomoxie.comhttp://www.gomoxie.com/

Hey, use knife cookbook delete <cookbok>@<version> to remove specific version of cookbook.

Sorry, I do not want to delete the present cookbook, and I want to roll back to the previous version without deleting the current version.

@cheffy,

The knife cookbook delete command will remove the cookbook from the Chef Server. You may specify both the name of the cookbook and the version of the cookbook you would like to delete. When you specify a version, only that version of the cookbook will be removed from the Chef Server. All other versions of the cookbook will remain on the Chef Server.

The knife cookbook delete command will not change any of the files you have locally. You will still have the current version on your local file system.

Based on my understanding of your initial question I believe this is what you are looking for. Perhaps we need more detail about the exact thing you are trying to accomplish?

Thanks,
Nathen

pin cookbook version in enviroment

1 Like

Thanks @nathenharvey