Sha256: 02383b76cde12563f3dbc930b11704a87d9a4600deea4cf3f9a95446f44c3f84

Contents?: true

Size: 1.35 KB

Versions: 1

Compression:

Stored size: 1.35 KB

Contents

# ipmess.rb
# Try to get additional Facts about the machine's network interfaces
#
# Original concept Copyright (C) 2007 psychedelys <psychedelys@gmail.com>
# Update and *BSD support (C) 2007 James Turnbull <james@lovedthanlost.net>
# 

require 'facter/util/ip'

Facter.add(:interfaces) do
    confine :kernel => [ :sunos, :freebsd, :openbsd, :netbsd, :linux ]
    setcode do
        Facter::IPAddress.get_interfaces.join(",")
    end
end

case Facter.value(:kernel) 
 when 'SunOS', 'Linux', 'OpenBSD', 'NetBSD', 'FreeBSD'
  Facter::IPAddress.get_interfaces.each do |interface|
    mi = interface.gsub('/:|\./', '_')

    Facter.add("ipaddress_" + mi) do
        confine :kernel => [ :sunos, :freebsd, :openbsd, :netbsd, :linux ]
        setcode do
            label = 'ipaddress'
            Facter::IPAddress.get_interface_value(interface, label)
        end
    end

    Facter.add("macaddress_" + mi) do
        confine :kernel => [ :sunos, :freebsd, :openbsd, :netbsd, :linux ]
        setcode do
            label = 'macaddress'
            Facter::IPAddress.get_interface_value(interface, label) 
        end
    end

    Facter.add("netmask_" + mi) do
        confine :kernel => [ :sunos, :freebsd, :openbsd, :netbsd, :linux ]
        setcode do
            label = 'netmask'
            Facter::IPAddress.get_interface_value(interface, label)
        end
    end
 end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
facter-1.5.2 lib/facter/ipmess.rb