(I think this is the right StackExchange for this question, since it's a development use case, not a sysadmin use case. If not please feel free to relocate it to the correct StackExchange.)
My app uses Vagrant + Chef solo provisioner to set up a local development environment. I arbitrarily chose a CentOS 6.5 box to host a MySQL database and a RabbitMQ bus since for development the VM box doesn't matter--all that matters is that the app has some instances to connect to. So I'm using the mysql
community cookbook and the rabbitmq
community cookbook, among others. I'm also using the database
cookbook to create a database and a user.
The problem is that Chef seems to want me to pull in a bunch of irrelevant external dependencies, even though my Vagrant environment is strictly controlled. For example, rabbitmq
wants erlang
(fine, obviously), but erlang
wants apt
, which isn't relevant for CentOS.
Similarly, the database
cookbook wants aws
and postgresql
, which again aren't relevant for my local Vagrant environment.
Can I exclude these dependencies without having to modify the cookbooks themselves? How?
No, this is not possible with Chef at this time. There have been many proposals for conditional dependencies, but none that got far enough to even call theoretical. Remember that these extra cookbooks don't hurt anything because their recipes won't be run. If you would like to propose a way to handle this kind of thing, I would encourage you to submit and RFC.
The longer version is that dependency resolution and constraint solving happens on the server, which means it needs to be based entirely on static data. So because of this, all dependencies need to be stated even if they won't all be used at runtime.