Hello, I''m trying write a function who''s able to determine if a file is a directory or not. Here''s my function : module Puppet::Parser::Functions newfunction(:is_dir, :type => :rvalue) do |args| File.directory?(args[0]) end end And how I use it : if is_dir("/usr/local/etc") { file {....} } else { file{....} } But it seems not work. It always do the first case. Any ideas ? Thanks. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Perhaps not the exact answer that you''re looking for, but what are you trying to do here and why are you using a function to do this? Functions are evaluated on the server, not the client. If you''re trying to change how a clients resources are managed based on local filesmanage client resources differently depending on the presence of local files, then this approach will not work. You may be better off using an exec resource instead. James Bellenger nOX wrote:> Hello, > > I''m trying write a function who''s able to determine if a file is a > directory or not. > > Here''s my function : > module Puppet::Parser::Functions > newfunction(:is_dir, :type => :rvalue) do |args| > File.directory?(args[0]) > end > end > > And how I use it : > if is_dir("/usr/local/etc") { > file {....} > } else { file{....} } > > But it seems not work. It always do the first case. > > Any ideas ? > > Thanks. > > > >-----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.7 (GNU/Linux) iD8DBQFJCJt28TYLVDRcCYURAlROAJ4728eA2kWrOTsLFOIb+9A2HJeQxgCfTady q1DWkQYTBGvS8+vHsO1j2O8=ciw1 -----END PGP SIGNATURE----- --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
You right, this will not work like this. But I found a part of my problem. Actually, in ruby the function File.directory(MyPath) return true if "MyPath" is a symlink on a directory. Thanks. On 29 oct, 18:20, James Bellenger <ja...@forwardcamegrendel.org> wrote:> -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Perhaps not the exact answer that you''re looking for, but what are you > trying to do here and why are you using a function to do this? Functions > are evaluated on the server, not the client. If you''re trying to change > how a clients resources are managed based on local filesmanage client > resources differently depending on the presence of local files, then > this approach will not work. You may be better off using an exec > resource instead. > > James Bellenger > > > > nOX wrote: > > Hello, > > > I''m trying write a function who''s able to determine if a file is a > > directory or not. > > > Here''s my function : > > module Puppet::Parser::Functions > > newfunction(:is_dir, :type => :rvalue) do |args| > > File.directory?(args[0]) > > end > > end > > > And how I use it : > > if is_dir("/usr/local/etc") { > > file {....} > > } else { file{....} } > > > But it seems not work. It always do the first case. > > > Any ideas ? > > > Thanks. > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v2.0.7 (GNU/Linux) > > iD8DBQFJCJt28TYLVDRcCYURAlROAJ4728eA2kWrOTsLFOIb+9A2HJeQxgCfTady > q1DWkQYTBGvS8+vHsO1j2O8> =ciw1 > -----END PGP SIGNATURE-------~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---