Re: [Puppet Users] custom fact should not run on Solaris

2013-12-19 Thread Erik Dalén
you should put the code of the fact inside the setcode block, so: require 'facter' Facter.add(:spacewalk) do confine :osfamily => "RedHat" setcode do f = File.new("/etc/sysconfig/rhn/up2date") text = f.read if text =~ /sv2653/ then "true" else "false" end end

Re: [Puppet Users] custom fact should not run on Solaris

2013-12-19 Thread Andreas Dvorak
Dear all thank you for helping me. My solution is this: require 'facter' Facter.add(:spacewalk) do confine :osfamily => "RedHat" f = File.new("/etc/sysconfig/rhn/up2date") text = f.read if text =~ /sv2653/ then setcode do "true" end else setcode do "false" end end

Re: [Puppet Users] custom fact should not run on Solaris

2013-12-18 Thread Jeff Bachtel
I think that pattern's still good. Possibly that's the difference between a nil fact being set and the fact being missing, however. Jeff On 12/18/2013 10:40 AM, Felix Frank wrote: Yes, exactly, but this begs the question: Am I out of date for adding confine :operatingsystem => %w{Debi

Re: [Puppet Users] custom fact should not run on Solaris

2013-12-18 Thread Felix Frank
Yes, exactly, but this begs the question: Am I out of date for adding confine :operatingsystem => %w{Debian SLES OpenSUSE CentOS} outside the setcode block? Thanks, Felix On 12/18/2013 04:34 PM, Jeff Bachtel wrote: > Facts are autoloaded from all modules and distributed to all agents, >

Re: [Puppet Users] custom fact should not run on Solaris

2013-12-18 Thread Jeff Bachtel
Facts are autoloaded from all modules and distributed to all agents, because that step occurs before the DSL is parsed for manifests (as it should be, because the DSL can be (is) impacted by facts). It is up to the custom fact to case itself out of execution for certain operating systems. For

[Puppet Users] custom fact should not run on Solaris

2013-12-18 Thread Andreas Dvorak
Dear all I have a module spacewalk with a custom fact to define if the server has been registered to spacewalk. The module should only run on RedHat server class profiles::base { ... case $::osfamily { redhat:{ include spacewalk include logrotate include postfix }