From acc7e3f2e93c5c62f75623be077467f020eb899c Mon Sep 17 00:00:00 2001 From: Stephen Gran Date: Tue, 21 Sep 2010 21:30:45 +0100 Subject: [PATCH] first stab at a v4ips fact for bsd Signed-off-by: Stephen Gran --- facts/ipaddresses.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/facts/ipaddresses.rb b/facts/ipaddresses.rb index eddbe66d3..01e20123d 100644 --- a/facts/ipaddresses.rb +++ b/facts/ipaddresses.rb @@ -19,6 +19,30 @@ Facter.add("v4ips") do end end +Facter.add("v4ips") do + confine :kernel => %w{FreeBSD} + setcode do + addrs = [] + output = %x{/sbin/ifconfig} + + output.split(/^\S/).each { |str| + if str =~ /inet ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/ + tmp = $1 + unless tmp =~ /127\./ + addrs << tmp + break + end + end + } + + ret = addrs.join(",") + if ret.empty? + ret = 'no' + end + ret + end +end + Facter.add("v6ips") do confine :kernel => :linux addrs = [] -- 2.20.1