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
end

or even simplify it to:

require 'facter'
Facter.add(:spacewalk) do
  confine :osfamily => "RedHat"
  setcode { !!(File.read("/etc/sysconfig/rhn/up2date") =~ /sv2653/) }
end



On 19 December 2013 14:26, Andreas Dvorak <andreas.dvo...@gmail.com> wrote:

> 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
> end
>
> Best regards
> Andreas
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to puppet-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/9f5a8416-960f-470d-84b8-1903c0315f00%40googlegroups.com
> .
>
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Erik Dalén

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CAAAzDLfbRLrNnjDfbqyBskyzScde%2BiOEVmV1iMpneQC%3DjK_Egg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to