4

I'm trying to specify both a cookbook version and a recipe on a nodes run_list and so far haven't been able to figure out how to do so. I can specify the version just fine and that works, and I can specify the recipe and that works, but if I attempt to do both it fails.

Working:

recipe[cookbook@1.2.3]

Also working:

recipe[cookbook::recipe]

But this fails:

recipe[cookbook::recipe@1.2.3]

I also tried this which failed as well

recipe[cookbook@1.2.3::recipe]
Orclev
  • 161
  • 1
  • 7
  • This is a bug in at least version 12.4.0 of Chef, other versions might be affected. I've provided an answer below that details this. – Orclev Jul 02 '15 at 20:08

2 Answers2

2

As of chef 12.4.1 and 12.5 The correct way to specify a version and a recipe to run is:

cookbook::recipe@version

More details below:

So, it looks like the proper way to do this is the first way I posted above. 12.something of Chef added support for specifying both version and recipe in the run list, but it's currently broken in 12.4.0. The next versions of Chef, 12.4.1 and 12.5.0, should both support specifying the recipe and the version again

Dave
  • 103
  • 3
Orclev
  • 161
  • 1
  • 7
  • The proper way is to specify cookbook version dependencies in the `metadata.rb` of a cookbook OR using a chef environment. – Roland Jul 02 '15 at 23:38
0

You can only version cookbooks on a per-cookbook level, not a per-recipe level.

Roland
  • 369
  • 3
  • 9
  • Yes, but that wasn't my question. I want a specific version of the cookbook, and I want to run the recipe from that version on the node. I'm not trying to mix and match recipes from different versions of the same cookbook. If I leave the version off, it's the same as running that recipe from the latest version which ISN'T what I want to do. – Orclev Jul 02 '15 at 16:05
  • Then, why did you try the versioning on a per-recipe level? Sorry, but your question was not clear. – Roland Jul 02 '15 at 23:37