1

I know that the following custom fact matches the string I want, as if I add a 'puts' or 'print' ahead of the $1 it prints the correct string. But as show the fact returns nothing. A blank.

  Facter.add(:myhost) do
    confine :kernel => "Linux"
    setcode do
      fh = File.open('/etc/enc_params.conf')
      fh.each_line do |line|
        if line =~ /\Amyhost.*\s(\w+)\Z/
          $1
        end
      end
    end
  end
spoovy
  • 354
  • 4
  • 15

1 Answers1

2

For the record!

Facter.add(:myhost) do
  confine :kernel => "Linux"
   fh = File.open('/etc/enc_params.conf')
   fh.each_line do |line|
   if line =~ /\Amyhost.*\s(\w+)\Z/
     r = $1
     setcode do
       r
     end
   end
 end

end

spoovy
  • 354
  • 4
  • 15