From: Stephen Gran Date: Sun, 7 Mar 2010 08:23:42 +0000 (+0000) Subject: new ipaddress fact X-Git-Url: https://git.adam-barratt.org.uk/?a=commitdiff_plain;h=db39f99389283882dcb87e64bdb78fd9118257e2;p=mirror%2Fdsa-puppet.git new ipaddress fact Signed-off-by: Stephen Gran --- diff --git a/facts/ipaddresses.rb b/facts/ipaddresses.rb new file mode 100644 index 000000000..f1bbd6990 --- /dev/null +++ b/facts/ipaddresses.rb @@ -0,0 +1,28 @@ +Facter.add("v4ips") do + 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\d .*/ + addrs << $1 + end + end + setcode do + addrs.join(",") + end +end + +Facter.add("v6ips") do + 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\d .*/ + addrs << $1 + end + end + setcode do + addrs.join(",") + end +end +