From 6aa5f947f028d4492e2389b85e9121f3bc98c34f Mon Sep 17 00:00:00 2001 From: Stephen Gran Date: Sun, 4 Apr 2010 13:35:38 +0100 Subject: [PATCH] I don't know why confine doesn't work, but let's try to work around it Signed-off-by: Stephen Gran --- facts/ipaddresses.rb | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/facts/ipaddresses.rb b/facts/ipaddresses.rb index d03bbbc4..eddbe66d 100644 --- a/facts/ipaddresses.rb +++ b/facts/ipaddresses.rb @@ -1,26 +1,34 @@ Facter.add("v4ips") do confine :kernel => :linux addrs = [] - %x{ip addr list}.each do |line| - next unless line =~ /\s+inet/ - next if line =~ /scope (link|host)/ - if line =~ /\s+inet\s+(\S+)\/\d{1,2} .*/ - addrs << $1 + if FileTest.exist?("/bin/ip") + %x{ip addr list}.each do |line| + next unless line =~ /\s+inet/ + next if line =~ /scope (link|host)/ + if line =~ /\s+inet\s+(\S+)\/\d{1,2} .*/ + addrs << $1 + end end end + ret = addrs.join(",") + if ret.empty? + ret = 'no' + end setcode do - addrs.join(",") + ret end end Facter.add("v6ips") do confine :kernel => :linux addrs = [] - %x{ip addr list}.each do |line| - next unless line =~ /\s+inet/ - next if line =~ /scope (link|host)/ - if line =~ /\s+inet6\s+(\S+)\/\d{1,3} .*/ - addrs << $1 + if FileTest.exist?("/bin/ip") + %x{ip addr list}.each do |line| + next unless line =~ /\s+inet/ + next if line =~ /scope (link|host)/ + if line =~ /\s+inet6\s+(\S+)\/\d{1,3} .*/ + addrs << $1 + end end end ret = addrs.join(",") -- 2.39.2