Hiera Debug

Page content

Introduction

After working with hiera from time with every growing code bases i have decided to write a super simple function. Hiera_debug this will allow the user to create a log file with information regarding each hiera lookup. This has allowed me to find out where in my manifests i am looking up variables and what they are return on each run. Its a very simple wrapper function for hiera that will output debug information into $logidr/hiera_debug_stephensmacbook. This file will be overwritten on every puppet run.

This includes the scopeing information of the hiera call, the default value, the value actually found and the actually variable requested.

Usage

If you want to find out what hiera is doing when looking up values simple change all hiera function calles to heira_debug, hiera_debug_array, hiera_debug_hash, hiera_debug_include. A simple regex will be able to do this for you.

Example manifest

$test = hiera_debug('wibble','default')
$test2 = hiera_debug('wibble2',['1','2','3'])
$test3 = hiera_debug_array('wibble2','default')
$test4 = hiera_debug_hash('wibble2',{ key1 =>  val1, key2 => val2})

Example logfile

{:version=>2228119500}
{:default=>"default", :value=>"default", :variablename=>"wibble", :lookscope=>"main"}
{:default=>["1", "2", "3"], :value=>["10", "11", "12"], :variablename=>"wibble2", :lookscope=>"main"}
{:default=>"default", :value=>"default", :variablename=>"wibble2", :lookscope=>"main"} 
{:default=>{"key1"=>"val1", "key2"=>"val2"}, :value=>{"key1"=>"val1", "key2"=>"val2"}, :variablename=>"wibble2", :lookscope=>"main"}

The output if very very ugly, but it works. If you want to check it out you can get it here.