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.
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.
1 2 3 4
1 2 3 4 5
The output if very very ugly, but it works. If you want to check it out you can get it here.