Thanks John. That didn't work for me, not sure why, but this did:

require 'facter'

Facter.add("vgactrl") do
  confine :kernel => :linux
  ENV["PATH"]="/bin:/sbin:/usr/bin:/usr/sbin"
  setcode do
    controllers = []
    if Facter::Util::Resolution.which('lspci')
      output = Facter::Util::Resolution.exec('lspci')
      unless output.nil?
        output.split("\n").each do |line|
          if line =~ /VGA\s+compatible\s+controller/
            line.gsub!(/(\W)/, " ").gsub!(/\s+/," ")
            controllers << line
          end
        end
      end
    end
    controllers.join(',')
  end
end

I wonder if it is the version of Ruby I'm using? This is on EL7

Anyway, thanks for all the suggestions. I've decided that I don't need the 
actual string returned in the fact any more, but
I'll just set it to true or false in the facter script if it matches.

Cheers

On Sunday, 8 January 2017 18:08:09 UTC, John Gelnaw wrote:
>
>
> I've been using the following code for a really long time now-- I think I 
> 'borrowed' it from someone else.
>
> # videocards.rb                                                           
>        
>  
> controllers = [] 
> output = %x{lspci} 
> output.each_line {|s| 
>     controllers.push($1) if s =~ /VGA compatible controller: (.*)/ 
> } 
>  
> for vc in 0...controllers.length 
>     thecard = "videocard" + vc.to_s 
>     Facter.add(thecard) do 
>         setcode do 
>             controllers[vc] 
>         end 
>     end 
> end
>
>
> Obviously it's only going to work if lspci is in the path when puppet runs.
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/ac874a31-093e-4f7e-b4a2-d458fec2caa1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to