With puppet I realize I can copy folders recursively and set permissions on individual files recursively. But I have a source folder with (many, many) files each with carefully configured permissions. How do I do the puppet equivalent of:
cp -a $source $dest
?
This:
file { '/some/dest':
ensure => directory,
source => "/some/src",
recurse => true,
}
Does not preserve mode.
Also, Best Practices: Recursive File Resources says to only use recursive files:
When the total number of recursive files to manage is small (such as ten or fewer)
Ok, so for the sake of argument, lets say /some/src
has 1000s of files with complicated modes.
According to that link, my other options are
- recursive_file_permissions defined type. Here I can only set all files to the same permissions, not set them to have the same permissions as the source == won't work for us.
- puppet/archive module
- build a package for the files, and use a Package resource to manage it.
Both of the two last approaches seem to involve an awful lot of work to achieve cp -a $source $dest
. Unless puppet has primitives to create an archive or debian package from $source
- I'm thinking not...
So: Is it really not possible to cp -a $source $dest
using puppet?
There is a
source_permissions
attribute that controls what happens when copy files without explicitly setting the mode which might do what you want. You should set it to eitheruse
oruse_when_creating
.