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
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

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.