# df.rb
require 'facter'
diskvols = Array.new
volumes = String.new
df_output = %x{/bin/df -lP}
result = $?.to_i
if result == 0
df_output.each do |vol|
diskvols.push(vol)
end
diskvols.delete_at(0)
diskvols.each do |vol|
volumes = volumes + ' ' + vol.split(' ')[5]
end
Facter.add("local_volumes") do
setcode do
volumes.strip()
end
end
end
The biggest thing (other than adding tests for it), would be moving all
of the things you're doing outside of the setcode block into a function
called from the setcode block, or into the setcode block itself. See
the recent discussion on puppet-dev about thread-safety in Facter[1] for
some reasons why.
[1] http://groups.google.com/group/puppet-dev/browse_thread/thread/ccd4a7d762651aa5/5bb09a83e981cc6c
--
Jacob Helwig