From d6967a0630dec168059316426b0eb4228b27e451 Mon Sep 17 00:00:00 2001 From: Adrien Thebo Date: Mon, 28 Mar 2011 11:01:19 -0700 Subject: (#6613) Switch solaris macaddress fact to netstat - ifconfig on solaris will only return the mac address if run as root. netstat -np will provide the information to any user. --- lib/facter/macaddress.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/facter/macaddress.rb b/lib/facter/macaddress.rb index 4a12384..bf23ef6 100644 --- a/lib/facter/macaddress.rb +++ b/lib/facter/macaddress.rb @@ -12,6 +12,18 @@ Facter.add(:macaddress) do end end +Facter.add(:macaddress) do + confine :operatingsystem => "Solaris" + setcode do + ether = [] + output = Facter::Util::Resolution.exec("/usr/bin/netstat -np") + output.each_line do |s| + ether.push($1) if s =~ /(?:SPLA)\s+(\w{2}:\w{2}:\w{2}:\w{2}:\w{2}:\w{2})/ + end + ether[0] + end +end + Facter.add(:macaddress) do confine :operatingsystem => %w{FreeBSD OpenBSD} setcode do -- cgit