Search code examples
chef-infrachef-recipecookbookrecipe

Do Chef environments follow cookbook dependencies?


  1. I have 2 cookbooks A and B
  2. They each have 2 versions V1 and V2
  3. In the metadata.rb of cookbook A I have depends 'B', '=V2'
  4. I have an env named ENV1 that has V1 of cookbook B pinned

Now for nodes assigned to ENV1 that use cookbook A will they respected the version of cookbook B pinned in ENV1 (V1) or will they use the version specified in cookbook A's metadata file (V2).

Basically just want to know that if I pin a version of a cookbook in an env there is no way any nodes assigned the env can use a different version.


Solution

  • All the relevant constraints get considered. So the environment a node is in are absolute constraints (they must be fulfilled), and the constraints on each available cookbook version are exposed to the solver. It will attempt to find a set of cookbook versions that have mutually valid constraints. If it fails to find one, you will get an error.