I need to create a user account and a lot of files for that user with Puppet.
Works fine with the most straightforward approach, but on every file
resource I have to specify owner => 'theuser'
, which seems horribly redundant (if I don't they end up root-owned).
Is there a way to have a scoped default for the owner? Or something like sudo where puppet runs under that user for a certain set of resources?
So if everything is in a single location you can use the
recurse
option for fileThen just have all your files in like
modules/ModuleName/path/in/files/
Puppet will put all the files in that module path into /path/to/files on the system owned by that user/group.
To cut down on e.g. the
owner
attribute you can add some defaults.Documentation on resource defaults: https://puppet.com/docs/puppet/latest/lang_defaults.html