]> git.donarmstrong.com Git - dsa-puppet.git/commitdiff
Port the v4ips & v6ips Facter functions to Ruby 1.9 from Debian wheezy/jessie
authorPaul Wise <pabs@debian.org>
Wed, 3 Dec 2014 23:19:25 +0000 (07:19 +0800)
committerPaul Wise <pabs@debian.org>
Wed, 3 Dec 2014 23:19:25 +0000 (07:19 +0800)
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 #<String:0x0001000707f410>
Unable to add resolve nil for fact v6ips: undefined method `each' for #<String:0x0001000707e808>

Thanks-to: zeha & gwolf on the #debian-ruby channel
modules/debian-org/lib/facter/ipaddresses.rb

index 0832063d0d8c626565a9e4be3ba134efe3deb00d..41f44e3a1a742a5b363d3c675e8b255aaa634462 100644 (file)
@@ -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} .*/