#facter/cprt_ipaddresses.rb
Facter.add(:cprt_ipaddresses) do
    confine :kernel => :linux
    setcode do
        ip = []
        output = %x{/sbin/ifconfig}

        output.split(/^\S/).each { |str|
            if str =~ /inet addr:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/
                tmp = $1
                unless tmp =~ /127\./ or tmp == "0.0.0.0"
                    ip << tmp 
                end
            end
        }

        ip.join(',')
    end
end

Facter.add(:cprt_ipaddresses) do
    confine :kernel => %w{FreeBSD OpenBSD SunOS solaris NetBSD darwin}
    setcode do
        ip = []
        output = %x{/sbin/ifconfig -a}

        output.split(/^\S/).each { |str|
            if str =~ /inet ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/
                tmp = $1
                unless tmp =~ /127\./ or tmp == "0.0.0.0"
                    ip << tmp
                end
            end
        }

        ip.join(',')
    end
end

Facter.add(:cprt_ipaddresses) do
    confine :kernel => %w{AIX}
    setcode do
        ip = []
        output = %x{/usr/sbin/ifconfig -a}

        output.split(/^\S/).each { |str|
            if str =~ /inet ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/
                tmp = $1
                unless tmp =~ /127\./ or tmp == "0.0.0.0"
                    ip << tmp
                end
            end
        }

        ip.join(',')
    end
end

Facter.add(:cprt_ipaddresses) do
    confine :kernel => %w{windows}
    setcode do
        ip = []
        output = %x{ipconfig}

        output.split(/^\S/).each { |str|
            if str =~ /IP Address.*: ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/
                tmp = $1
                unless tmp =~ /127\./ or tmp == "0.0.0.0"
                    ip << tmp
                end
            end
        }
        ip.join(',')
    end
end

Add a code snippet to your website: www.paste.org