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



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

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 either use or use_when_creating.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.