From: Stephen Gran Date: Sun, 4 Apr 2010 12:35:38 +0000 (+0100) Subject: I don't know why confine doesn't work, but let's try to work around it X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=6aa5f947f028d4492e2389b85e9121f3bc98c34f;p=dsa-puppet.git I don't know why confine doesn't work, but let's try to work around it Signed-off-by: Stephen Gran --- 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(",")