Another alternative is to unconditionally copy the file to a staging director (e.g. /var/staging) and then have
exec { "conditional copy to path1": onlyif => "test -d /opt/path1" command => "rsync -a /var/staging/file.txt /opt/path1"; "conditional copy to path2": onlyif => "test -d /opt/path2" command => "rsync -a /var/staging/file.txt /opt/path2"; "conditional copy to path3": onlyif => "test -d /opt/path3" command => "rsync -a /var/staging/file.txt /opt/path3"; } For neatness' sake, you could turn that into a define{} On Thu, Apr 12, 2012 at 7:18 AM, Munna S <19.mu...@gmail.com> wrote: > Hi Gary, > > I created a custom fact path_to_check.rb and placed it under > .../module_name/lib/facter > > below is my init.pp file > > class class_name > if $path_to_check == present{ > file { "/opt/xyz/file.txt": > owner => "jboss", > group => "jboss", > source => > "puppet://$puppetserver/modules/module_name/opt/xyz/file.txt", > } > } > } > But i dont see files are getting pushed > On Sun, Apr 1, 2012 at 11:08 PM, Munna S <19.mu...@gmail.com> wrote: > >> Thank you so much Gary. I will try this >> >> Thanks, >> Jeeva >> >> On Sun, Apr 1, 2012 at 11:05 PM, Gary Larizza <g...@puppetlabs.com>wrote: >> >>> Jeeva, >>> >>> Your custom fact would do something like: >>> File.directory?('/path/to/check') that returns true or false depending on >>> whether the directory existed. Your fact would return a true or false >>> value (so if the custom fact were named 'path_to_x' you would do something >>> like this in your init.pp >>> >>> if $path_to_x == 'true' { >>> # Do something here >>> } else { >>> # Do something else here >>> } >>> >>> Do this for every custom fact (corresponding to the paths you want to >>> check) in your manifest, or combine them into one giant if statement like: >>> >>> if ($path_to_x == 'true') or ($path_to_y == 'true') { >>> # Do something >>> } >>> >>> Does this make sense? >>> >>> >>> On Sun, Apr 1, 2012 at 8:48 PM, Munna S <19.mu...@gmail.com> wrote: >>> >>>> Hi Gary, >>>> >>>> How i can put this in my init.pp file. Actually i am checking for the >>>> path. if path found then copy the file else dont create any file/folder. So >>>> here i need to check for 3 different path on each server. if any of the >>>> below path exist then copy the file. >>>> >>>> Thanks, >>>> Jeeva >>>> >>>> On Sun, Apr 1, 2012 at 10:41 PM, Gary Larizza <g...@puppetlabs.com>wrote: >>>> >>>>> Jeeva, >>>>> >>>>> >>>>> I would make a custom fact ( >>>>> http://docs.puppetlabs.com/guides/custom_facts.html) that checks for >>>>> the presence of these files. Your Puppet manifest would check the >>>>> condition of this fact to ensure the file absent or present (i.e. if >>>>> $custom_fact { file { '/path/to/file': ensure => file } } ). >>>>> >>>>> >>>>> Does that make sense? >>>>> >>>>> >>>>> >>>>> On Sun, Apr 1, 2012 at 8:37 PM, Munna S <19.mu...@gmail.com> wrote: >>>>> >>>>>> Team, >>>>>> >>>>>> Any help >>>>>> >>>>>> Thanks, >>>>>> Jeeva >>>>>> >>>>>> On Fri, Mar 30, 2012 at 12:51 PM, Munna S <19.mu...@gmail.com> wrote: >>>>>> >>>>>>> Team, >>>>>>> >>>>>>> I need a puppet module to copy a file to different location based on >>>>>>> condition check . Below is my requirement >>>>>>> >>>>>>> if /opt/path1 found on the server then copy file1 >>>>>>> if /opt/path2 found on the server then copy file1 >>>>>>> if /opt/path3 found on the server then copy file1 >>>>>>> >>>>>>> if none of the above path found then dont copy file1 >>>>>>> >>>>>>> Thanks, >>>>>>> Jeeva >>>>>>> >>>>>>> >>>>>> >>>>>> -- >>>>>> 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. >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> >>>>> Gary Larizza >>>>> Professional Services Engineer >>>>> Puppet Labs >>>>> >>>>> -- >>>>> 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. >>>>> >>>> >>>> -- >>>> 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. >>>> >>> >>> >>> >>> -- >>> >>> Gary Larizza >>> Professional Services Engineer >>> Puppet Labs >>> >>> -- >>> 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. >>> >> >> > -- > 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. > -- 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.