Ask Your Question

Manage directories recursively

asked 2013-03-27 04:45:36 -0600

Ripzura gravatar image


How can I manage a directory recursively? I want to change the mode and owner of all files and directories under a certain directory recursively.

I have no control over the files or directories under this top dir. They are not managed by puppet.

Something like this does not seems to work:

   file { "/opt/simpana":
           ensure => directory,
           recurse => true,
           owner => "root",
           group => "root",
           mode => 0644,

this only changes the /opt/simpana directory to the correct mode, owner and group but not any of the files below this directory.

Is this possible at all in puppet 2.7.20 or ... (more)

edit retag flag offensive close merge delete


Hmm, this works OK for me on 2.7.12 at least; files under that directory get 0644 and directories get 0755. Can you show us an example of where ...(more)

jonn gravatar imagejonn ( 2013-03-27 12:26:20 -0600 )edit

Found some more info in the log (/Stage[main]/Commvault/File[/opt/simpana]) Failed to generate additional resources using 'eval_generate: Cannot manage files of type socket. Is there any way ...(more)

Ripzura gravatar imageRipzura ( 2013-03-27 16:54:50 -0600 )edit

Ah - yes, I see the same if I create a device file. It appears to still be an open bug ( so @Ancillas' exec idea ...(more)

jonn gravatar imagejonn ( 2013-03-27 17:08:59 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2013-03-27 16:34:22 -0600

Ancillas gravatar image

updated 2013-03-27 16:34:47 -0600

I've always thought directory/filesystem management in Puppet to be a bit odd. I would seriously consider using Exec for performance concerns when managing many files.

find . -type d -exec chmod 0755 {} \; 
find . -type f -exec chmod 0644 {} \;
edit flag offensive delete link more


I have to agree. Just did a puppet run with the two sockets excluded. Applying this resources took a LOT longer using "File" than my previous "Exec" did.

Ripzura gravatar imageRipzura ( 2013-03-27 17:24:59 -0600 )edit

answered 2013-03-27 17:15:42 -0600

Ripzura gravatar image

as per I ignored the two sockets in this directory causing the problem here. A quick google search did not show any other "nice" methods of doing this.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2013-03-27 04:45:36 -0600

Seen: 15,379 times

Last updated: Mar 27 '13