From: Stephen Gran Date: Tue, 21 Sep 2010 20:30:45 +0000 (+0100) Subject: first stab at a v4ips fact for bsd X-Git-Url: https://git.adam-barratt.org.uk/?a=commitdiff_plain;h=acc7e3f2e93c5c62f75623be077467f020eb899c;p=mirror%2Fdsa-puppet.git first stab at a v4ips fact for bsd Signed-off-by: Stephen Gran --- 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 = []