4

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?

2 Answers 2

2

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.

1
-1

Not tested, but this should work:

For the second resource, just name it differently and set an explicit path:

file {"/foo/bar_root": path => "/foo/bar", ensure => directory, mode => 0640, # +x automatically added to directories recurse => false, } 
3
  • 1
    Not quite. The namevar parameter is path, so you can't have 2 file resources with the same path: docs.puppetlabs.com/references/latest/type.html#file Commented Nov 6, 2015 at 8:14
  • sadly cristi is right it still knows its a duplicate :-) Commented Nov 6, 2015 at 15:04
  • Unfortunately yes, but thinking again about this tells me this is not a bad thing, as it would be all too easy to create conflicting resource definitions. Commented Nov 6, 2015 at 22:20

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.