fix munin 1
[mirror/dsa-puppet.git] / modules / debian-org / lib / facter / lsb-for-bsd.rb
1 {  "LSBRelease"         => %r{^LSB Version:\t(.*)$},
2    "LSBDistId"          => %r{^Distributor ID:\t(.*)$},
3    "LSBDistRelease"     => %r{^Release:\t(.*)$},
4    "LSBDistDescription" => %r{^Description:\t(.*)$},
5    "LSBDistCodeName"    => %r{^Codename:\t(.*)$}
6 }.each do |fact, pattern|
7     Facter.add(fact) do
8         confine :kernel => 'GNU/kFreeBSD'
9         setcode do
10             unless defined?(lsbdata) and defined?(lsbtime) and (Time.now.to_i - lsbtime.to_i < 5)
11                 type = nil
12                 lsbtime = Time.now
13                 lsbdata = Facter::Util::Resolution.exec('lsb_release -a 2>/dev/null')
14             end
15
16             if pattern.match(lsbdata)
17                 $1
18             else
19                 nil
20             end
21         end
22     end
23 end
24