Puppet Function: simplib::inspect

Defined in:
functions/inspect.pp
Function type:
Puppet Language

Overview

simplib::inspect(String $var_name, Enum['json','yaml'] $output_type = 'json')None

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.

Parameters:

  • var_name (String)

    The actual name of the variable, fully scoped, as a String

  • output_type (Enum['json','yaml']) (defaults to: 'json')

    The format that you wish to use to display the output during the run

Returns:

  • (None)


13
14
15
16
17
18
19
20
21
22
23
24
# File 'functions/inspect.pp', line 13

function simplib::inspect (
  String $var_name,
  Enum['json','yaml'] $output_type = 'json'
) {

  $var_value = inline_template("<%= scope[@var_name].to_${output_type} %>")
  $var_class = inline_template('<%= scope[@var_name].class %>')

  notify { "DEBUG_INSPECT_${var_name}":
    message => "Type => ${var_class}\nContent =>\n${var_value}"
  }
}