diff options
author | root <root@absinthe.lovedthanlost.net> | 2007-09-13 08:51:11 +1000 |
---|---|---|
committer | root <root@absinthe.lovedthanlost.net> | 2007-09-13 08:51:11 +1000 |
commit | 611337521e72c4bce4d52bea110abaaa348ff034 (patch) | |
tree | ca265557451ab4c9283af7dd2ccf60ee881656da /lib/facter.rb | |
parent | 8426aaf4e385aa7e221a966524db1a4fd89482cb (diff) | |
download | facter-611337521e72c4bce4d52bea110abaaa348ff034.tar.gz facter-611337521e72c4bce4d52bea110abaaa348ff034.tar.xz facter-611337521e72c4bce4d52bea110abaaa348ff034.zip |
Added macaddress fact support for FreeBSD and OpenBSD - closes #37
Added hardwareisa support for *BSD platforms - closed #38
Facter now detects the Mandriva distribution - closes #39
Facter now correctly detects ipaddress on NetBSD - closes #42
Diffstat (limited to 'lib/facter.rb')
-rw-r--r-- | lib/facter.rb | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/lib/facter.rb b/lib/facter.rb index 8a52a6a..e9fe58d 100644 --- a/lib/facter.rb +++ b/lib/facter.rb @@ -654,6 +654,8 @@ class Facter "Gentoo" elsif FileTest.exists?("/etc/fedora-release") "Fedora" + elsif FileTest.exists?("/etc/mandriva-release") + "Mandriva" elsif FileTest.exists?("/etc/redhat-release") txt = File.read("/etc/redhat-release") if txt =~ /centos/i @@ -917,7 +919,7 @@ class Facter Facter.add(:hardwareisa) do setcode 'uname -p', '/bin/sh' - confine :operatingsystem => %w{Solaris Linux Fedora RedHat CentOS SuSE Debian Gentoo} + confine :operatingsystem => %w{Solaris Linux Fedora RedHat CentOS SuSE Debian Gentoo FreeBSD OpenBSD NetBSD} end Facter.add(:macaddress) do @@ -933,6 +935,20 @@ class Facter end Facter.add(:macaddress) do + confine :operatingsystem => %w{FreeBSD OpenBSD} + setcode do + ether = [] + output = %x{/sbin/ifconfig} + output.each {|s| + if s =~ /(?:ether|lladdr)\s+(\w\w:\w\w:\w\w:\w\w:\w\w:\w\w)/ + ether.push($1) + end + } + ether[0] + end + end + + Facter.add(:macaddress) do confine :kernel => :darwin setcode do ether = nil @@ -969,7 +985,7 @@ class Facter end end Facter.add(:ipaddress) do - confine :kernel => %w{FreeBSD NetBSD OpenBSD solaris} + confine :kernel => %w{FreeBSD OpenBSD solaris} setcode do ip = nil output = %x{/sbin/ifconfig} @@ -988,6 +1004,25 @@ class Facter end end Facter.add(:ipaddress) do + confine :kernel => :NetBSD + setcode do + ip = nil + 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\./ + ip = tmp + break + end + end + } + + ip + end + end + Facter.add(:ipaddress) do confine :kernel => %w{darwin} setcode do ip = nil |