FAQ
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

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/A4BAxQ7nA00J.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.

Search Discussions

  • Jcbollinger at Jan 7, 2013 at 2:30 pm

    On Monday, January 7, 2013 4:02:49 AM UTC-6, SDM wrote:
    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
    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

    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/pJIhYceTRuMJ.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedJan 7, '13 at 10:02a
activeJan 7, '13 at 2:30p
posts2
users2
websitepuppetlabs.com

2 users in discussion

SDM: 1 post Jcbollinger: 1 post

People

Translate

site design / logo © 2022 Grokbase