Puppet Function: simplib::inspect
- Defined in:
- functions/inspect.pp
- Function type:
- Puppet Language
Overview
Prints the passed variable’s Ruby type and value for debugging purposes
This uses a “Notify“ resource to print the information during the client run.
class my_test(
String $var1,
Hash $var2
)
simplib::inspect('var1')
simplib::inspect('var2')
...
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 |
# File 'functions/inspect.pp', line 28
function simplib::inspect (
String $var_name,
Enum['json','yaml', 'oneline_json'] $output_type = 'json'
) {
if $output_type == 'oneline_json' {
$_output_type = 'json'
}
else {
$_output_type = $output_type
}
$var_value = inline_template("<%= scope[@var_name].to_${_output_type} %>")
$var_class = inline_template('<%= scope[@var_name].class %>')
if $output_type == 'oneline_json' {
$_separator = ' '
}
else {
$_separator = "\n"
}
notify { "DEBUG_INSPECT_${var_name}":
message => "Type => ${var_class}${_separator}Content =>${_separator}${var_value}"
}
}
|