How to dump all data available in a template


#1

I’m in the process of learning Chef. To help with that, I would like to dump all the data passed to a template, or at least dump “node”.

One thing I tried was the following template file.

<% require ‘YAML’ %>
<% y node %>

It gave this error: “cannot load such file – YAML”

Any suggestions as to how I can do this in any way?


#2

You’ll want:
<% require 'yaml' %>

But I’m not sure where y sends its output ($stdout?). Maybe you want:
<%= node.to_yaml %>


#3

Thanks a lot JosB. Spot on.

What worked was:

<% require ‘yaml’ %>
<%= node.to_yaml %>