diff options
author | Adrien Thebo <adrien@puppetlabs.com> | 2011-03-28 11:01:19 -0700 |
---|---|---|
committer | Adrien Thebo <adrien@puppetlabs.com> | 2011-03-28 11:01:19 -0700 |
commit | 56b5f10e876b29f9a2fd1906087ebb3cb5d47035 (patch) | |
tree | 2102060100d806bf691a4fbd1dccd5270b1a2f26 /lib | |
parent | 4a9cb92655dfcd307dabf07a90660f5e26f13e94 (diff) | |
download | facter-56b5f10e876b29f9a2fd1906087ebb3cb5d47035.tar.gz facter-56b5f10e876b29f9a2fd1906087ebb3cb5d47035.tar.xz facter-56b5f10e876b29f9a2fd1906087ebb3cb5d47035.zip |
(#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.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/facter/macaddress.rb | 12 |
1 files changed, 12 insertions, 0 deletions
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 @@ -13,6 +13,18 @@ Facter.add(:macaddress) do 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 ether = [] |