]> git.donarmstrong.com Git - dsa-puppet.git/commitdiff
I don't know why confine doesn't work, but let's try to work around it
authorStephen Gran <steve@lobefin.net>
Sun, 4 Apr 2010 12:35:38 +0000 (13:35 +0100)
committerStephen Gran <steve@lobefin.net>
Sun, 4 Apr 2010 12:35:38 +0000 (13:35 +0100)
Signed-off-by: Stephen Gran <steve@lobefin.net>
facts/ipaddresses.rb

index d03bbbc4ead3583fd90d311f02b83d6255a91039..eddbe66d3ab670aeaf0b047e43225a92ce493395 100644 (file)
@@ -1,26 +1,34 @@
 Facter.add("v4ips") do
         confine :kernel => :linux
         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{1,2} .*/
-                        addrs << $1
+        if FileTest.exist?("/bin/ip")
+                %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{1,2} .*/
+                                addrs << $1
+                        end
                 end
         end
+        ret = addrs.join(",")
+        if ret.empty?
+          ret = 'no'
+        end
         setcode do
-                addrs.join(",")
+          ret
         end
 end
 
 Facter.add("v6ips") do
         confine :kernel => :linux
         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{1,3} .*/
-                        addrs << $1
+        if FileTest.exist?("/bin/ip")
+                %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{1,3} .*/
+                                addrs << $1
+                        end
                 end
         end
         ret = addrs.join(",")