It would be really good to have this logged by default. I got into a problem where as far as I can see chef chose to one version over an other of recipe and it took me a while to figure out that this was happening. Having the versions logged would have helped identify the problem.
Here is what happened. Imagine three cookbooks A,B, C. B and C depend on A. But they don't necessarily depend on the same version of A because B and C just do different things. Now imagine B depends explicitly on version 1 of A and C depends explicitly on version 2 of A. Finally lets say I add B and C to the run list of a node.
The question is: Which version of A will be used? What I saw was that version 1 was being used for both. Has anyone else experienced this? Is this expected behavior. It does not seem to respect the cookbook' depends' contract.
Cheers,
Florian
-----Original Message-----
From: Julian C. Dunn [mailto:jdunn@aquezada.com]
Sent: 10 October 2013 14:44
To: chef@lists.opscode.com
Subject: [chef] Re: which cookbook version used in chef-client run?
It's a little dirty, but if you crack open the run context you can do it:
---8<--- cut here ---8<---
log "---Writing all ckbks and versions---"
cookbooks = @run_context.cookbook_collection
log "The recipes were these: #{cookbooks.keys.map {|x| cookbooks.name + " " + cookbooks.version} }"
log "---End Writing all ckbks and versions---
---8<--- cut here ---8<---
Credit goes to Sean Horn for this tidbit of code.
On Thu, Oct 10, 2013 at 6:03 AM, Florian Hehlen florian.hehlen@gmail.com wrote:
Hi,
Is there a way to list or to log which cookbook version was used
during a chef-client run. I know I can crack open metadata.rb files in
the chef/cache directory but that is a bit clunky. It is also usefull
information to log I would say.
Cheers,
Flo
--
[ Julian C. Dunn jdunn@aquezada.com * Sorry, I'm ]
[ WWW: Julian Dunn's Blog - Commentary on media, technology, and everything in between. * only Web 1.0 ]
[ gopher://sdf.org/1/users/keymaker/ * compliant! ]
[ PGP: 91B3 7A9D 683C 7C16 715F 442C 6065 D533 FDC2 05B9 ]
LEGAL DISCLAIMER
This communication and any attached documents are strictly confidential and/or legally privileged and they may not be used or disclosed by someone who is not a named recipient. If you have received this electronic communication in error please notify the sender by replying to this electronic communication inserting the word "misdirected" as the subject and delete this communication from your system.