On Sep 28, 2011, at 9:37 AM, Sans wrote: > Dear all, > > I have a module like this: > > class mom_priv_config{ > file { > 'config': > owner => 'root', group => 'root', mode => '0644', > name => '/var/torque/mom_priv/config', > content => template('w_nodes/mom_priv-config.tpl'), > #notify => Service['pbs_mom'] > } > } > > which is working great by its own. But all I want is to carry on with > this *ONLY IF* "/var/torque/mom_priv" directory exists on the client. > If there is no such directory presents, just ignore. How can I do > this? I looked in the net but nothing came out as a solution to me. > Any one can help me with please? Cheers!! > > -- > 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+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. >
I'd create a custom fact that checks for the existence of the mom_priv directory -- something like this: # mom_priv_test.rb if FileTest.directory?("/var/torque/mom_priv") Facter.add("mom_priv_test") do setcode { true } end end # Now you can use this fact to wrap your file resource in an if statement: class mom_priv_config { if $mom_priv_test == 'true' { file { '/var/torque/mom_priv/config': ensure => present, owner => 'root', group => 'root', mode => '0644', content => template('w_nodes/mom_priv-config.tpl'), #notify => Service['pbs_mom'], } } } -- Peter M. Bukowinski Sr. Systems Engineer Janelia Farm Research Campus, HHMI -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.