Hi!
I am trying to create a custom fact that returns the list of subdirectories within a subdirectory, if the subdirectory exists.
For example, if the computer has `/data/files`, I need to obtain all the subdirectories inside it (`/data/files/one, /data/files/two, /data/files/three`), without the prefix path (so just (`one two three`).
I tried to write a custom fact but I am failing woefully,
Facter.add(:datasubdirs) do
result = ''
setcode do
if File.directory? '/data/files' do |str|
Facter::Util::Resolution.exec('/bin/ls /data/files/')
result += str
end
end
end
end
Please what am I doing wrong and how can I make it better?
↧