I am using puppet 3.8.4 on debian. I want to recursively set the owner and group on a set directory, but only set permissions on the directory itself ie. I don't want to chmod anything in the dir only chown/chgrp it.
I have tried the following...
file {[
"/foo/bar" ,
] :
ensure => directory,
owner => root,
group => bar,
recurse => true,
require => [
User[root],
Group[bar],
],
}
file {[
"/foo/bar" ,
] :
ensure => directory,
mode => 0640, # +x automatically added to directories
recurse => false,
}
But of course puppet then complains of a Duplicate declaration: File[/foo/bar] if you do that.
Is there a way in puppet to do this without having to do the top level directory and then all the files and folders under it explicitly?
Just to put it as an answer also: you can't.
The namevar parameter is path, so you can't have 2 file resources with the same path.
Check the documentation about file resource.
Not tested, but this should work:
For the second resource, just name it differently and set an explicit path: