puppetfacter

Facter - How to check if directory exists


I'm trying to check if direcotory exists. I created subdir 'lib/facter' in my module directory and put file 'mycheck.rb' in it.

Facter.add(:mycheck) do
 setcode do
  if Dir.exist? ('/mydir1')
   'one'
  elseif Dir.exist? ('/mydir2')
   'two'
  else
   'default'
  end
 end
end

Even if both directories 'mydir1' and 'mydir2' exists I always got 'default' value. What am I doing wrong?


Solution

  • I got answer. It should be 'elsif' not 'elseif'. Now it works great.