How to force chef-client to download and run same cookbook version again

2.6k views Asked by At

When I make modifications to my cookbook, I would like to test it on the chef-client(s). However, so far I have found, chef-client will only download and execute new versions of cookbook. This forces me to up the version of the cookbook every time I make a minor change to my cookbook. I would like to force chef client node to download and execute the same version of cookbook which has since changed.

I have tried deleting /var/chef/cache/* , it still downloads the cookbook with the pervious content which has since changed (even though version number has not).

Is this possible?

Thanks

2

There are 2 answers

1
coderanger On BEST ANSWER

chef-client will always download things as needed. The bigger problem is that most of the recent cookbook upload tools do it using freeze mode, which prevents any further changes to that version. In general this is a good thing, I would recommend you use Test Kitchen for trying out any tweaks and then bump and release when you are ready for that. You can also look in to the Policyfile system and workflow which doesn't use cookbook versions in the same way.

0
Derek On

Pin your cookbook versions in the environment file(s) necessary, and only upgrade it once it's passed your tests (kitchen, chefspec, a staging/integration with all systems that use it, etc). Some CI systems can even do this updating for you.