From 5d9fdee2d793d06e5e194b0760a1d566ee191263 Mon Sep 17 00:00:00 2001 From: Ricky Zhou Date: Sun, 9 Jan 2011 18:35:14 -0500 Subject: Use iproute2 utility for ipaddress fact. net-tools is deprecated, and /sbin/ip seems to list interfaces in a more reasonable order, compared to /sbin/ifconfig's alphabetical order output. --- lib/facter/ipaddress.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/facter/ipaddress.rb b/lib/facter/ipaddress.rb index 5260504..e8b2c38 100644 --- a/lib/facter/ipaddress.rb +++ b/lib/facter/ipaddress.rb @@ -26,10 +26,10 @@ Facter.add(:ipaddress) do confine :kernel => :linux setcode do ip = nil - output = %x{/sbin/ifconfig} + output = %x{/sbin/ip addr show} output.split(/^\S/).each { |str| - if str =~ /inet addr:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/ + if str =~ /inet ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/ tmp = $1 unless tmp =~ /^127\./ ip = tmp -- cgit