Access facts values in Puppet provider

532 views
Skip to first unread message

Andriy Yurchuk

unread,
Apr 26, 2013, 1:06:54 AM4/26/13
to puppet...@googlegroups.com
I'm writing a custom Puppet service provider and I need to access one of my facts value inside provider to then be able to use the value inside startcmd/stopcmd. There is a confine which can test whether a fact exists, but how do I actually get the value of the fact?

jcbollinger

unread,
Apr 26, 2013, 9:20:36 AM4/26/13
to puppet...@googlegroups.com


On Friday, April 26, 2013 12:06:54 AM UTC-5, Andriy Yurchuk wrote:
I'm writing a custom Puppet service provider and I need to access one of my facts value inside provider to then be able to use the value inside startcmd/stopcmd. There is a confine which can test whether a fact exists, but how do I actually get the value of the fact?


As far as I know, providers do not have direct access to node facts.  They run on the target node, not on the master, so they cannot draw data from the master's environment unless it is provided to them via resource parameters.  On the other hand, providers can (and often do) directly interact with the target node to obtain any information they need.  Although it would be roundabout, your provider could probably even use Facter to (re-)compute the data you want.


John

Andriy Yurchuk

unread,
Apr 26, 2013, 10:23:32 AM4/26/13
to puppet...@googlegroups.com
Found out this can be done via Facter['my_fact'].value
Reply all
Reply to author
Forward
0 new messages