From: Paul Wise Date: Wed, 3 Dec 2014 23:19:25 +0000 (+0800) Subject: Port the v4ips & v6ips Facter functions to Ruby 1.9 from Debian wheezy/jessie X-Git-Url: https://git.adam-barratt.org.uk/?a=commitdiff_plain;h=61407897bd9a47068a19a41fa9550f4139dd25bd;p=mirror%2Fdsa-puppet.git 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 --- 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} .*/