Override a depends?


I’m using the chef_nginx cookbook. In its metadata.rb, it defines this:

depends 'build-essential'

That’s because it might also compile from source. But I’m not going to compile; I’m going to install from distro packages.

How do I “override” this depends for my environment? I could of course clone or fork the cookbook and modify the metadata.rb, but doing so, I’ll lose the ability to easily get the changes, that might be done in future to the cookbook.


Perhaps not exactly what you’re looking for, but you can override the cookbook for your entire organization by uploading a blank cookbook named ‘build-essential’ to your chef server. I’ve heard of of people doing this for this exact cookbook to avoid getting build tools on their servers.

To limit by environment, all I can think of is to give this blank cookbook a version number like ‘0.0.999’ and then pin this version (the real build-essential is on version 8 now). Admittedly though this makes the original hack even hackier…

Hi Christopher

Having a blank cookbook is a clever idea. Thanks for that :grinning: I’ll do that.

You said, that I should pin that version 0.0.999. how would I do that?


Am 26.06.2017 5:32 nachm. schrieb “Christopher Crebolder” <

If you have in your metadata.rb of the blank cookbook version '0.0.999' you can add a constraint such as '= 0.0.999' in either the environment or a wrapping cookbook as described here: https://docs.chef.io/cookbook_versions.html#environments or here: https://docs.chef.io/environments.html#environment-formats.

You should only really need to do this if the community cookbook is calling the default recipe of build-essential and installing tools you don’t want, or you want to make sure no one else in your organization uses this cookbook if you have a policy against it or something. If it’s just coming across as a dependency but not getting called it won’t do anything.