Skip to content

Instantly share code, notes, and snippets.

@Cinderhaze
Created October 15, 2016 15:43
Show Gist options
  • Save Cinderhaze/6d1e90dec0184284eb25910b5ce06b5f to your computer and use it in GitHub Desktop.
Save Cinderhaze/6d1e90dec0184284eb25910b5ce06b5f to your computer and use it in GitHub Desktop.
How to pretty-print hashes and arrays for puppet debugging
ubuntu@ubuntu:~$ puppet apply pretty.pp [12/46]
Notice: Scope(Class[main]): {one => 1, two => [dos, 2]}
Notice: Scope(Class[main]):
{
"one": "1",
"two": [
"dos",
"2"
]
}
Notice: Compiled catalog for dawiest-vpcsc1afm in environment production in 0.12 seconds
Notice: Applied catalog in 0.02 seconds
#Example puppet code with an inline template to pretty-print a hash
$hash = { 'one' => '1',
'two' => [ 'dos', '2' ],
}
$content = inline_template("
<%- require 'json' -%>
<%= JSON.pretty_generate(@hash) %>
")
notice($hash)
notice($content)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment