As Brian suggested, using define{} is the better way of doing it; you
can even copy different files to different directories, if required.
Something like this:
# /etc/puppet/modules/<ur_module>/manifests/staging.pp
------------------------------------------------------
class ur_module::staging {
define opt_dir($file, $path) {
exec { "copy_${dir}":
path => [ '/bin', '/usr/bin' ],
command => "rsync -a /var/staging/${file} /opt/${path}",
onlyif => "test -d /opt/${path}",
}
}
-------------------------------------------------------
and, then in the init.pp:
# /etc/puppet/modules/<ur_module>/manifests/init.pp
---------------------------------------------------
class file_copy {
include ur_module::staging
ur_module::staging::opt_dir {
'path_1':
file => 'file.txt',
path => 'path1';
'path_2':
file => 'another_file.txt',
path => 'path2';
.....
... keep carrying on ...
}
}
---------------------------------------------------
That should do that job. Cheers!!
On Apr 12, 3:24 pm, Brian Gallew <[email protected]> wrote:
> 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{}
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.