diff options
-rw-r--r-- | CHANGELOG | 2 | ||||
-rw-r--r-- | lib/facter.rb | 2 | ||||
-rw-r--r-- | lib/facter/ipmess.rb | 24 |
3 files changed, 14 insertions, 14 deletions
@@ -2,7 +2,7 @@ Added support to return multiple interfaces and their IP addresses and MAC addressess as facts. Returns interface_interfacename and macaddress_interfacename. Existing ipaddress and macaddress facts are - unchanged and still returned. Supports bith Linux and BSD. Closes #6. + unchanged and still returned. Currently Linux only. Closes #6. Added macaddress fact support for FreeBSD and OpenBSD - closes #37 diff --git a/lib/facter.rb b/lib/facter.rb index 802f848..e71eb0c 100644 --- a/lib/facter.rb +++ b/lib/facter.rb @@ -1004,7 +1004,7 @@ class Facter end end Facter.add(:ipaddress) do - confine :kernel => %w{NetBSD} + confine :kernel => %w{NetBSD} setcode do ip = nil output = %x{/sbin/ifconfig -a} diff --git a/lib/facter/ipmess.rb b/lib/facter/ipmess.rb index 777084f..abee8a2 100644 --- a/lib/facter/ipmess.rb +++ b/lib/facter/ipmess.rb @@ -44,7 +44,7 @@ if Facter.kernel == "Linux" confine :kernel => :linux setcode do fact - end + end end } } @@ -52,16 +52,16 @@ end if Facter.kernel == "FreeBSD" || Facter.kernel == "OpenBSD" || Facter.kernel == "NetBSD" - output = %x{/sbin/ifconfig -a} - int = nil - output.scan(/^(\w+)(\d+):/) { |str| - output_int = %x{/sbin/ifconfig #{str}} - int = "#{str}" - tmp1 = nil - tmp2 = nil - test = {} - output_int.each { |s| - int = "#{str}" + output = %x{/sbin/ifconfig -a} + int = nil + output.scan(/^(\w+)(\d+):/) { |str| + output_int = %x{/sbin/ifconfig #{str}} + int = "#{str}" + tmp1 = nil + tmp2 = nil + test = {} + output_int.each { |s| + int = "#{str}" tmp1 = $1 if s =~ /inet ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/ tmp2 = $1 if s =~ /(?:ether|lladdr)\s+(\w\w:\w\w:\w\w:\w\w:\w\w:\w\w)/ if tmp1 != nil && tmp2 != nil && int != "lo" @@ -71,7 +71,7 @@ if Facter.kernel == "FreeBSD" || Facter.kernel == "OpenBSD" || Facter.kernel == tmp1 = nil tmp2 = nil end - } + } test.each{|name,fact| Facter.add(name) do confine :kernel => :linux |