custom fact with variables

45 views
Skip to first unread message

SDM

unread,
Jan 7, 2013, 5:02:49 AM1/7/13
to puppet...@googlegroups.com
Hi,

do you know if it's possible to pass value to custom fact. 

I have a custom fact that check the presence of lv. The idea is to replace the lv name by a variable and check different lv.

in my .rb file :

Facter.add(:lv_dd_adm) do
  confine :kernel => "Linux"
  setcode do
    Facter::Util::Resolution.exec('lvs | grep -i lv_dd_adm | cut -c3-11')
  end
end

in my site.pp :
$variable = $::lv_dd_adm

Thanks in advance.
Regards


Seb

jcbollinger

unread,
Jan 7, 2013, 9:03:23 AM1/7/13
to puppet...@googlegroups.com


No, it is not possible.  It's also not a good idea.  Facter runs on the client, before any part of the node's manifests are parsed, therefore Facter cannot know anything about the node's (current) manifests.

Now, it is possible for you to install some kind of artifact on the client (e.g. a file) that your custom fact can interrogate to direct its evaluation, but that doesn't give you the current information for the node.  Rather, it gives you the information as of the most recent previous Puppet run, which may be stale.

Moreover, it is a really poor idea for the meaning of your facts to be context-sensitive.  It makes them much harder to use appropriately.

As an alternative, consider making the presence of facts context sensitive.  For example, have one or more lv-related facts for every lv in the system, using a naming scheme that includes the lv name.


John

Reply all
Reply to author
Forward
0 new messages