On Feb 4, 2009, at 8:26 AM, Ben Hughes wrote:
>
> Hi all.
>
> I've got this fact, trying to use it with the munin module from DavidS
> to work out which drives to graph. Fairly run of the mill, but when
> ever
> I add this in to my facter folder. Puppet barfs with a Timeout::Error
>
> [r...@foo-vm:~]# invoke-rc.d puppet start
> Starting puppet configuration management tool
> info: Loading fact whatraid
> info: Loading fact localdisks
> /usr/lib/ruby/1.8/timeout.rb:60: execution expired (Timeout::Error)
> from /var/lib/puppet/lib/facter/localdisks.rb:20:in `open'
> from /var/lib/puppet/lib/facter/localdisks.rb:20
> from /usr/lib/ruby/1.8/facter/util/fact.rb:38:in `instance_eval'
> from /usr/lib/ruby/1.8/facter/util/fact.rb:38:in `add'
>
>
> The fact (yeah it's ugly...):
>
> Facter.add("localdisks") do
>
> disks = [ ]
> File.open( "/proc/mounts" , "r" ) do |f|
> f.each do |line|
> foo = line.chomp!.split("\s")
> matchey = foo[0].match(/^\/dev\/([a-z0-9\/]+)[0-9]/)
> disks.push(matchey[1]) unless matchey.nil?
> end
> end
>
> setcode do
> disks.uniq.join(',')
> end
> end
>
> However, from the command line with facter, it works:
> [r...@foo-vm:~]# FACTERLIB=/var/lib/puppet/lib/facter/ facter
> localdisks
> sda
>
>
> So I'm a little confused. What have I done painfully wrong? ):
Maybe something about a difference in environment making /proc/mounts
not work?
The code certainly looks right to me, although I'll note that your
fact value won't update in the same process -- I'd put all of that
code inside the setcode block.
--
Love is a snowmobile racing across the tundra and then suddenly it
flips over, pinning you underneath. At night, the ice weasels come.
--Matt Groening
---------------------------------------------------------------------
Luke Kanies | http://reductivelabs.com | http://madstop.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en
-~----------~----~----~----~------~----~------~--~---