Adding a fact to Pfacter
While dabbling with Puppet I’ve spent a fair amount of time investigating facter, one of the tools (although puppet uses it as a library) it’s built on. While I quite like the format it uses to define a fact I’m hampered by my lack of ruby experience; simple things take me longer than they should. So when I noticed Pfacter while looking for a module on CPAN recently I thought I’d have a look at how it could be done in perl.
Firstly I have to mention the install, or rather lack of one. The module doesn’t install via CPAN on Linux (and after looking at its CPAN Testers page it seems I’m not the only one with the problem) which makes it a bit of a pain. Once I’d hand wrangled an install I decided to see what it picked up about the system and how to add my own fact.
I can’t complain about the number of built in facts, it’s pretty
comparable to the original facter (which I’ve added my own custom facts to
now.) Adding a fact was a little more complex. Once I’d written one (I
cribbed from the existing facts - but with strict and warnings added)
I dropped it in to the correct directory (which I found with
find / -name cfclasses.pm) and ran pfacter; and nothing
After re-checking the code of the ipv6.pm fact
I found the first major difference between the perl and ruby versions. Ruby
facter loads all the facts in a directory and attempts them all, pfacter
requires you to manually add them to the
@modules array before
it’ll run them. Once I’d done that and reran pfacter it showed that my
machine is ipv6 enabled.
So the verdict? It could be useful to pull out certain information about the system, I found the perl version easier to extend as it doesn’t add its own little language to the mix, but for most people the biggest selling point of facter is its use within puppet - which this version lacks. Still, it was interesting to see another (very) different approach to collecting system information.