Hi,
I'm working on custom fact that uses Facter::Util::Resolution.exec to run a command that returns output I want to parse with regex. If I write up a ruby shell script like:
#!/usr/bin/ruby
out = `<command>`
out = out.gsub!(/<regex>/, "\\1\\3")
puts "#{out}"
The desired output comes to the screen, every time, and on every system I run it.
If I modify the script to be a fact like so:
# custom fact
require 'facter'
Facter.add(:newfact) do
out = Facter::Util::Resolution.exec("<command>")
out = out.gsub!(/<regex>/, "\\1\\3")
secode { out }
end
A puppet run actually prints the full output of the command twice after syncing the fact. Running facter -p newfact does the same. On top, the printed output is the raw output not the regex filtered.
What am I doing wrong here?
Thanks!