Hi all, Newbie question here... I''m trying to figure out how to execute a command for every file in a directory. For example, I recursively copy a bunch of tar files and then I want to run a command against them My understanding is that the file resource will execute first, copying all of the files. After that the exec resource will occur. Is that right? If so, how do I run an exec for every file? Ideally, I want to do something like this, but to have the exec occur for every individual file: file { "/var/tmp/files": ensure => "directory", recurse => true, purge => true, backup => false, mode => "755", source => "puppet:///files", } exec { "foo": command => "tar xf FILENAME", cwd => "/var/tmp/files", subscribe => File["/var/tmp/files"], } -- 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.
I would try something like: file { "/var/tmp/files": ensure => "directory", ... notify => Exec[ exec { "foo": command => "echo * | xargs tar xf ", cwd => "/var/tmp/files", refreshonly => true, } On Fri, Apr 15, 2011 at 12:29 PM, Prateep <prateep@anicca.net> wrote:> Hi all, > > Newbie question here... > > I''m trying to figure out how to execute a command for every file in a > directory. > > For example, I recursively copy a bunch of tar files and then I want > to run a command against them > > My understanding is that the file resource will execute first, copying > all of the files. After that the exec resource will occur. Is that > right? If so, how do I run an exec for every file? > > Ideally, I want to do something like this, but to have the exec occur > for every individual file: > > file { "/var/tmp/files": > ensure => "directory", > recurse => true, > purge => true, > backup => false, > mode => "755", > source => "puppet:///files", > } > > exec { "foo": > command => "tar xf FILENAME", > cwd => "/var/tmp/files", > subscribe => File["/var/tmp/files"], > > } > > > > -- > 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 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.
Prateep Bandharangshi
2011-Apr-15 20:07 UTC
Re: [Puppet Users] Recursive directory copy and exec
Yes, of course. That would work fine. :-) I was getting carried away trying to map this to puppet resources Thanks Prateep On 15 Apr 2011, at 19:16, Mohamed Lrhazi <lrhazi@gmail.com> wrote:> I would try something like: > > file { "/var/tmp/files": > ensure => "directory", > ... > notify => Exec[ > > exec { "foo": > command => "echo * | xargs tar xf ", > cwd => "/var/tmp/files", > refreshonly => true, > } > On Fri, Apr 15, 2011 at 12:29 PM, Prateep <prateep@anicca.net> wrote: >> Hi all, >> >> Newbie question here... >> >> I''m trying to figure out how to execute a command for every file in a >> directory. >> >> For example, I recursively copy a bunch of tar files and then I want >> to run a command against them >> >> My understanding is that the file resource will execute first, copying >> all of the files. After that the exec resource will occur. Is that >> right? If so, how do I run an exec for every file? >> >> Ideally, I want to do something like this, but to have the exec occur >> for every individual file: >> >> file { "/var/tmp/files": >> ensure => "directory", >> recurse => true, >> purge => true, >> backup => false, >> mode => "755", >> source => "puppet:///files", >> } >> >> exec { "foo": >> command => "tar xf FILENAME", >> cwd => "/var/tmp/files", >> subscribe => File["/var/tmp/files"], >> >> } >> >> >> >> -- >> 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 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 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.