From dc7363e837ecf95ff2c4a17ddd8c3065e414cf37 Mon Sep 17 00:00:00 2001 From: Paul Nasrat Date: Thu, 17 Jul 2008 13:31:18 +0100 Subject: Set macaddress on windows platform --- lib/facter/macaddress.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/facter/macaddress.rb b/lib/facter/macaddress.rb index 30d4b59..98e38b8 100644 --- a/lib/facter/macaddress.rb +++ b/lib/facter/macaddress.rb @@ -63,3 +63,17 @@ Facter.add(:macaddress) do ether[0] end end + +Facter.add(:macaddress) do + confine :kernel => %w(windows) + setcode do + ether = [] + output = %x{ipconfig /all} + output.split(/\r\n/).each do |str| + if str =~ /.*Physical Address.*: (\w{1,2}-\w{1,2}-\w{1,2}-\w{1,2}-\w{1,2}-\w{1,2})/ + ether.push($1.gsub(/-/, ":")) + end + end + ether[0] + end +end -- cgit