Custom fact that requires inifile

49 views
Skip to first unread message

Mark Rosedale

unread,
Oct 17, 2014, 11:03:36 AM10/17/14
to puppet...@googlegroups.com
Hello,

I'm looking to implement a custom fact that tells my puppet config if a machine is configured a certain way. What I want to do is parse the configuration's ini file and see if a certain setting is turned on or off. I'm looking at using the ruby gem inifile to do this. 

Couple of questions. I'm assuming that facts, unlike functions, are run on the node, correct? So if that is the case what is the best way to distribute this gem to all hosts? 

Final question. Am I barking up the wrong tree trying to use this library to parse an ini file? Has anyone else done this type of thing?  

Craig White

unread,
Oct 17, 2014, 12:19:09 PM10/17/14
to puppet...@googlegroups.com
It would seem to me that I would not eagerly use another gem to obtain information from a file when ruby has File and vast string compare options but the choice is yours. Then there are tools like augeas (sp?).

Gems can be managed as a package using the gem provider so it's fairly easy to get puppet clients to install gems and note that facts run first so the first pass, the fact will not have information as the gem would likely have to be installed and the second pass, the fact can be derived.

Felix Frank

unread,
Nov 5, 2014, 4:27:44 PM11/5/14
to puppet...@googlegroups.com
Hi,

this makes me cringe a little :-)

You're both not completely off track, but then there's much better option.

As custom facts always run from a Puppet context, you have access to Puppet's own API. Say a fact needs to incorporate the value of the 'server' setting in some way:

setcode do
  server_name_setting = Puppet['server']
  # ... code that uses the value
end

HTH,
Felix
Reply all
Reply to author
Forward
0 new messages