Adriana
2010-Nov-30 08:39 UTC
[Puppet Users] How to apply recursion to user, group and mode?
Hello, I would like to know it is possible to translate for example the command chmod -R 0777 /local. As far as I know, I can write: file { "/local": mode => 0777, recurse => true, -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Adriana
2010-Nov-30 08:41 UTC
[Puppet Users] How to apply recursion to user, group and mode?
Hello, I would like to know it is possible to translate for example the command chmod -R 0777 /local. As far as I know, I can write: file { "/local": mode => 0777, recurse => true, ensure => directory; } but it does not apply the mode to all the /local subdirectories. Is there a way to do that? In addition, how is it possible to do mkdir -P /local/dir1/dir2 . if I write: file { "/local/dir1/dir2": recurse => true, ensure => directory; } it complains if /local/dir1 doesn''t exist. I hope someone can help me. Cheers, Adriana -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Peter Meier
2010-Nov-30 10:37 UTC
Re: [Puppet Users] How to apply recursion to user, group and mode?
On 11/30/2010 09:41 AM, Adriana wrote:> Hello, I would like to know it is possible to translate for example > the command > chmod -R 0777 /local. > As far as I know, I can write: > file { "/local": > mode => 0777, > recurse => true, > ensure => directory; > } > > but it does not apply the mode to all the /local subdirectories. > Is there a way to do that?Well this isn''t an exact "translation" of the command. Remember: in puppet you don''t apply commands or run scripts. You define the state of resources on your system and puppet will look that these resources are in sync with your manifests. This is an important differentiation. However in general your idea "should" work: $ cd /tmp/ $ mkdir a a/b a/b/c $ touch a/aa a/b/bb $ cat foo.pp file{''/tmp/a'': mode => 0777, recurse => true, ensure => directory, } $ puppet foo.pp notice: /Stage[main]//File[/tmp/a]/mode: mode changed ''775'' to ''777'' notice: /File[/tmp/a/aa]/mode: mode changed ''664'' to ''777'' notice: /File[/tmp/a/b]/mode: mode changed ''775'' to ''777'' notice: /File[/tmp/a/b/bb]/mode: mode changed ''664'' to ''777'' notice: /File[/tmp/a/b/c]/mode: mode changed ''775'' to ''777'' $ ls -l /tmp/a/aa -rwxrwxrwx. 1 foo foo 0 Nov 30 11:31 /tmp/a/aa BUT: Is it possible that you manage these subdirectories somewhere else? This would mean that you would have to manage the parameters of these resources where you define them. File[''/local''] can''t overwrite the parameters of these resources, which would be a very bad idea.> In addition, how is it possible to do > mkdir -P /local/dir1/dir2 . > > if I write: > > file { "/local/dir1/dir2": > recurse => true, > ensure => directory; > } > > it complains if /local/dir1 doesn''t exist.You need to specify the whole directory tree you want to manage as with puppet you describe for each directory the exact it should be in: http://projects.puppetlabs.com/issues/86 You can also shorten this to: file{[''/local'',''/local/dir1'', ''/local/dir1/dir2'' ]: ensure => directory, } oh, and there are also functions around that help you to "auto"-create that array. But personally I think this is the wrong approach. ~pete -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Felix Frank
2010-Dec-07 15:24 UTC
Re: [Puppet Users] How to apply recursion to user, group and mode?
On 11/30/2010 09:39 AM, Adriana wrote:> Hello, I would like to know it is possible to translate for example > the command > chmod -R 0777 /local. > As far as I know, I can write: > file { "/local": > mode => 0777, > recurse => true, >Yes. Be cautious of gratuitous md5summing that may occur. I''ve seen it happen with clients up to 0.25.5, and it cannot be circumvented on those. Even though no content is being modified, puppet may compute md5sums for each and every file in the tree you are recursing. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.