booleans, again
authorStephen Gran <steve@lobefin.net>
Sun, 18 Mar 2012 20:24:46 +0000 (20:24 +0000)
committerStephen Gran <steve@lobefin.net>
Sun, 18 Mar 2012 20:24:46 +0000 (20:24 +0000)
Signed-off-by: Stephen Gran <steve@lobefin.net>
modules/debian-org/lib/facter/hosts.rb
modules/debian-org/lib/facter/ipaddresses.rb
modules/debian-org/lib/facter/mta.rb
modules/debian-org/lib/facter/portforwarder.rb
modules/debian-org/lib/facter/raidarray.rb
modules/debian-org/lib/facter/servertype.rb
modules/debian-org/lib/facter/services.rb
modules/debian-org/lib/facter/software.rb

index 2a6b692..63c04cb 100644 (file)
@@ -11,7 +11,11 @@ Facter.add("brokenhosts") do
                end
        end
        setcode do
-               brokenhosts
+               if brokenhosts
+                       true
+               else
+                       ''
+               end
        end
 end
 
index 05e3e90..80b59bd 100644 (file)
@@ -1,22 +1,22 @@
 Facter.add("v4ips") do
-        confine :kernel => :linux
-        addrs = []
-        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
-          ret
-        end
+       confine :kernel => :linux
+       addrs = []
+       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
+               ret
+       end
 end
 
 Facter.add("v4ips") do
@@ -44,23 +44,23 @@ Facter.add("v4ips") do
 end
 
 Facter.add("v6ips") do
-        confine :kernel => :linux
-        addrs = []
-        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(",")
-        if ret.empty?
-          ret = 'no'
-        end
-        setcode do
-          ret
-        end
+       confine :kernel => :linux
+       addrs = []
+       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(",")
+       if ret.empty?
+               ret = 'no'
+       end
+       setcode do
+               ret
+       end
 end
 
index 98ed433..9b61260 100644 (file)
@@ -9,11 +9,16 @@ Facter.add("mta") do
 end
 
 Facter.add("exim_ssl_certs") do
-       setcode do
-               FileTest.exist?("/etc/exim4/ssl/") &&
+       certs = FileTest.exist?("/etc/exim4/ssl/") &&
                FileTest.exist?("/etc/exim4/ssl/ca.crl") &&
                FileTest.exist?("/etc/exim4/ssl/thishost.crt") &&
                FileTest.exist?("/etc/exim4/ssl/ca.crt") &&
                FileTest.exist?("/etc/exim4/ssl/thishost.key")
+       setcode do
+               if certs
+                       true
+               else
+                       ''
+               end
        end
 end
index fe3cebd..67888aa 100644 (file)
@@ -14,7 +14,7 @@ begin
 
     Facter.add("portforwarder_user_exists") do
         setcode do
-            result = false
+            result = ''
             begin
                 if Etc.getpwnam('portforwarder')
                     result = true
index d773532..d0d1309 100644 (file)
@@ -1,14 +1,18 @@
 Facter.add("smartarraycontroller") do
        confine :kernel => :linux
        setcode do
-               FileTest.exist?("/dev/cciss/")
+               if FileTest.exist?("/dev/cciss/")
+                       true
+               else
+                       ''
+               end
        end
 end
 
 Facter.add("ThreeWarecontroller") do
        confine :kernel => :linux
        setcode do
-               is3w = false
+               is3w = ''
                if FileTest.exist?("/proc/scsi/scsi")
                        IO.foreach("/proc/scsi/scsi") { |x|
                                is3w = true if x =~ /Vendor: 3ware/
@@ -21,28 +25,40 @@ end
 Facter.add("megaraid") do
        confine :kernel => :linux
        setcode do
-               FileTest.exist?("/dev/megadev0")
+               if FileTest.exist?("/dev/megadev0")
+                       true
+               else
+                       ''
+               end
        end
 end
 
 Facter.add("mptraid") do
        confine :kernel => :linux
        setcode do
-               FileTest.exist?("/dev/mptctl") or FileTest.exist?("/dev/mpt0") or FileTest.exist?("/proc/mpt/summary")
+               if FileTest.exist?("/dev/mptctl") or FileTest.exist?("/dev/mpt0") or FileTest.exist?("/proc/mpt/summary")
+                       true
+               else
+                       ''
+               end
        end
 end
 
 Facter.add("aacraid") do
        confine :kernel => :linux
        setcode do
-               FileTest.exist?("/dev/aac0")
+               if FileTest.exist?("/dev/aac0")
+                       true
+               else
+                       ''
+               end
        end
 end
 
 Facter.add("swraid") do
        confine :kernel => :linux
        setcode do
-                swraid = false
+                swraid = ''
                if FileTest.exist?("/proc/mdstat") && FileTest.exist?("/sbin/mdadm")
                         IO.foreach("/proc/mdstat") { |x|
                                 swraid = true if x =~ /md[0-9]+ : active/
index e261e70..85970c1 100644 (file)
@@ -1,9 +1,8 @@
 Facter.add("kvmdomain") do
        setcode do
+               result = ''
                if File.new('/proc/cpuinfo').read().index('QEMU Virtual CPU')
                        result = true
-               else
-                       result = false
                end
                result
        end
index 8ad2847..0971162 100644 (file)
@@ -2,7 +2,7 @@
        Facter.add(service + "_host") do
                 confine :kernel => :linux
                service_name = "#{service}." + Facter.domain
-               active = false
+               active = ''
 
                setcode do
                        if FileTest.exist?("/usr/bin/dig")
index 598d7a1..5c60dd4 100644 (file)
@@ -1,46 +1,82 @@
 Facter.add("apache2") do
        setcode do
-               FileTest.exist?("/usr/sbin/apache2")
+               if FileTest.exist?("/usr/sbin/apache2")
+                       true
+               else
+                       ''
+               end
        end
 end
 Facter.add("clamd") do
        setcode do
-               FileTest.exist?("/usr/sbin/clamd")
+               if FileTest.exist?("/usr/sbin/clamd")
+                       true
+               else
+                       ''
+               end
        end
 end
 Facter.add("exim4") do
        setcode do
-               FileTest.exist?("/usr/sbin/exim4")
+               if FileTest.exist?("/usr/sbin/exim4")
+                       true
+               else
+                       ''
+               end
        end
 end
 Facter.add("postfix") do
        setcode do
-               FileTest.exist?("/usr/sbin/postfix")
+               if FileTest.exist?("/usr/sbin/postfix")
+                       true
+               else
+                       ''
+               end
        end
 end
 Facter.add("postgres81") do
        setcode do
-               FileTest.exist?("/usr/lib/postgresql/8.1/bin/postgres")
+               if FileTest.exist?("/usr/lib/postgresql/8.1/bin/postgres")
+                       true
+               else
+                       ''
+               end
        end
 end
 Facter.add("postgres83") do
        setcode do
-               FileTest.exist?("/usr/lib/postgresql/8.3/bin/postgres")
+               if FileTest.exist?("/usr/lib/postgresql/8.3/bin/postgres")
+                       true
+               else
+                       ''
+               end
        end
 end
 Facter.add("postgres84") do
        setcode do
-               FileTest.exist?("/usr/lib/postgresql/8.4/bin/postgres")
+               if FileTest.exist?("/usr/lib/postgresql/8.4/bin/postgres")
+                       true
+               else
+                       ''
+               end
        end
 end
 Facter.add("postgres90") do
        setcode do
-               FileTest.exist?("/usr/lib/postgresql/9.0/bin/postgres")
+               if FileTest.exist?("/usr/lib/postgresql/9.0/bin/postgres")
+                       true
+               else
+                       ''
+               end
        end
 end
 Facter.add("postgrey") do
        setcode do
-               FileTest.exist?("/usr/sbin/postgrey")
+               if FileTest.exist?("/usr/sbin/postgrey")
+                       true
+               else
+                       ''
+               end
        end
 end
 Facter.add("greylistd") do
@@ -50,31 +86,53 @@ Facter.add("greylistd") do
 end
 Facter.add("policydweight") do
        setcode do
-               FileTest.exist?("/usr/sbin/policyd-weight")
+               if FileTest.exist?("/usr/sbin/policyd-weight")
+                       true
+               else
+                       ''
+               end
        end
 end
 Facter.add("vsftpd") do
        setcode do
-               FileTest.exist?("/usr/sbin/vsftpd")
+               if FileTest.exist?("/usr/sbin/vsftpd")
+                       true
+               else
+                       ''
+               end
        end
 end
 Facter.add("spamd") do
        setcode do
-               FileTest.exist?("/usr/sbin/spamd")
+               if FileTest.exist?("/usr/sbin/spamd")
+                       true
+               else
+                       ''
+               end
        end
 end
 Facter.add("php5") do
-       setcode do
-               FileTest.exist?("/usr/lib/apache2/modules/libphp5.so") or
+       php =   FileTest.exist?("/usr/lib/apache2/modules/libphp5.so") or
                FileTest.exist?("/usr/bin/php5") or
                FileTest.exist?("/usr/bin/php5-cgi") or
                FileTest.exist?("/usr/lib/cgi-bin/php5")
+       setcode do
+               if php
+                       true
+               else
+                       ''
+               end
        end
 end
 Facter.add("php5suhosin") do
-       setcode do
-               FileTest.exist?("/usr/lib/php5/20060613/suhosin.so") or
+       suhosin=FileTest.exist?("/usr/lib/php5/20060613/suhosin.so") or
                FileTest.exist?("/usr/lib/php5/20060613+lfs/suhosin.so")
+       setcode do
+               if suhosin
+                       true
+               else
+                       ''
+               end
        end
 end
 Facter.add("syslogversion") do
@@ -84,12 +142,21 @@ Facter.add("syslogversion") do
 end
 Facter.add("rsyncd") do
        setcode do
-               FileTest.exist?("/etc/rsyncd.conf")
+               if FileTest.exist?("/etc/rsyncd.conf")
+                       true
+               else
+                       ''
+               end
        end
 end
 Facter.add("unbound") do
-       setcode do
-               FileTest.exist?("/usr/sbin/unbound") and
+       unbound=FileTest.exist?("/usr/sbin/unbound") and
                FileTest.exist?("/var/lib/unbound/root.key")
+       setcode do
+               if unbound
+                       true
+               else
+                       ''
+               end
        end
 end