A collection of task oriented solutions in Puppet

 

Display fact resolution timings

Challenge

Facter takes a long time to run and you want to know which fact is the culprit.

Solution

$ facter -t
...
fact='augeasversion', resolution='<anonymous>': 2.57ms
fact='uptime', resolution='<anonymous>': 0.02ms
fact='hardwareisa', resolution='<anonymous>': 0.71ms
fact='lsbdistrelease', resolution='<anonymous>': 0.01ms
fact='network_virbr0', resolution='<anonymous>': 5.27ms
...

Explanation

There are times, mostly when you are writing your own facts, that something causes facter or puppet to take a lot longer than you would normally expect. Running facter with the -t or --timing option will trace each facts resolution and print how long it takes. This will often be enough to pinpoint the misbehaving fact and for the real work to begin.