From 61407897bd9a47068a19a41fa9550f4139dd25bd Mon Sep 17 00:00:00 2001 From: Paul Wise Date: Thu, 4 Dec 2014 07:19:25 +0800 Subject: [PATCH] Port the v4ips & v6ips Facter functions to Ruby 1.9 from Debian wheezy/jessie This fixes these warnings from new hosts and fixes puppet IP address discovery: Unable to add resolve nil for fact v4ips: undefined method `each' for # Unable to add resolve nil for fact v6ips: undefined method `each' for # Thanks-to: zeha & gwolf on the #debian-ruby channel --- modules/debian-org/lib/facter/ipaddresses.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/debian-org/lib/facter/ipaddresses.rb b/modules/debian-org/lib/facter/ipaddresses.rb index 0832063d0..41f44e3a1 100644 --- a/modules/debian-org/lib/facter/ipaddresses.rb +++ b/modules/debian-org/lib/facter/ipaddresses.rb @@ -2,7 +2,7 @@ Facter.add("v4ips") do confine :kernel => :linux addrs = [] if FileTest.exist?("/bin/ip") - %x{ip addr list}.each do |line| + %x{ip addr list}.each_line do |line| next unless line =~ /\s+inet/ next if line =~ /scope (link|host)/ if line =~ /\s+inet\s+(\S+)\/\d{1,2} .*/ @@ -47,7 +47,7 @@ Facter.add("v6ips") do confine :kernel => :linux addrs = [] if FileTest.exist?("/bin/ip") - %x{ip addr list}.each do |line| + %x{ip addr list}.each_line do |line| next unless line =~ /\s+inet/ next if line =~ /scope (link|host)/ if line =~ /\s+inet6\s+(\S+)\/\d{1,3} .*/ -- 2.20.1