Created
October 15, 2016 15:43
-
-
Save Cinderhaze/6d1e90dec0184284eb25910b5ce06b5f to your computer and use it in GitHub Desktop.
How to pretty-print hashes and arrays for puppet debugging
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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