From 8a3479db80ae1c4fc0c22c7ff733ad193e63a0fb Mon Sep 17 00:00:00 2001 From: Benedikt Trefzer Date: Fri, 2 Jun 2017 14:58:56 +0200 Subject: [PATCH] check if /proc/bus/pci/devices is available This avoids an error thrown if the file is not available. Hint: the facter code is executed even if the module is not included on the catalog. Change-Id: Ie7a3dce6d42d3b2274bb5578862d677841e7bdc3 --- lib/facter/pci_address.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/facter/pci_address.rb b/lib/facter/pci_address.rb index 83a749f9..73e2d354 100644 --- a/lib/facter/pci_address.rb +++ b/lib/facter/pci_address.rb @@ -1,6 +1,10 @@ require 'facter' -drivers_details=Facter::Util::Resolution.exec("cat /proc/bus/pci/devices") -drivers_lines=drivers_details.split("\n") +if File.file?("/proc/bus/pci/devices") + drivers_details=File.read("/proc/bus/pci/devices") + drivers_lines=drivers_details.split("\n") +else + drivers_lines=Array.new +end drivers=Hash.new drivers_lines.each do |line| line = line.gsub(/^\s+|\s+$/m, '').split(" ")