diff options
author | Paul Nasrat <pnasrat@googlemail.com> | 2008-07-17 12:46:14 +0100 |
---|---|---|
committer | Paul Nasrat <pnasrat@googlemail.com> | 2008-07-17 12:46:14 +0100 |
commit | 3ea1905e88176039f12fb96525b6c3dbc4080774 (patch) | |
tree | 8a8a59b2ef7b4da28085bc102cc22fa7a5df8dd4 | |
parent | 5e09ea1f66b83abe1f81ef0222a33962d3dcc35e (diff) | |
download | facter-3ea1905e88176039f12fb96525b6c3dbc4080774.tar.gz facter-3ea1905e88176039f12fb96525b6c3dbc4080774.tar.xz facter-3ea1905e88176039f12fb96525b6c3dbc4080774.zip |
Use ipconfig to determine ip address
-rw-r--r-- | lib/facter/ipaddress.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/facter/ipaddress.rb b/lib/facter/ipaddress.rb index 942c134..c97abe4 100644 --- a/lib/facter/ipaddress.rb +++ b/lib/facter/ipaddress.rb @@ -149,3 +149,22 @@ Facter.add(:ipaddress) do ip end end + +Facter.add(:ipaddress) do + confine :kernel => %w{windows} + setcode do + ip = nil + output = %x{ipconfig} + + output.split(/^\S/).each { |str| + if str =~ /IP Address.*: ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/ + tmp = $1 + unless tmp =~ /127\./ + ip = tmp + break + end + end + } + ip + end +end |