Update: As mentioned by Dan DeLeo, he discussed this feature on Chef 11 In-Depth: Attributes Changes last year when Chef 11 was released. I somehow never got a chance to use it, and thought this post would be a helpful example.
Earlier today I was reminded by Steven Danna about a newer feature of Chef called debug_value
. This is a method on the node
object (Chef::Node
) which will show where in Chef’s attribute hierarchy a particular attribute or sub-attribute was set on the node.
Fire up a chef shell in client mode on the node you want to see:
1
|
|
For example, I’ll use my minecraft server, using the excellent minecraft cookbook.
1 2 |
|
The cookbook itself sets a node['minecraft']
attribute hash.
1 2 |
|
Of note are the server properties attributes, which I customize in the role. Here is the node['minecraft']['properties']
attributes hash on my node:
1 2 |
|
And I can see where these were set using the #debug_value
method. Each sub-attribute should be passed as an argument.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
|
From the role, we can see some properties attributes are set:
1 2 3 4 5 6 7 8 9 10 |
|
Note that even though these are also set by default, we get them in the output here too.