Hi all, I''d like to add a several directories and I can''t seem to do it with a single "file" directive. Say /home/jeff exists and I want to add /home/jeff/src/my/dir/path I tried: file { "/home/jeff/src/my/dir/path": path => "/home/jeff/src/my/dir/path", mode => 0755, owner => jeff, group => jeff, ensure => directory, recurse => true, } But puppet complains the parent directory doesn''t exist. How can I do the equivalent of mkdir -p /home/jeff/src/my/dir/path TIA, Jeff --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
You pretty much have to use exec { "mkdir -p /path" }, sorry! On Wed, Oct 8, 2008 at 1:30 PM, Jeff <joesiege@gmail.com> wrote:> > Hi all, > > I''d like to add a several directories and I can''t seem to do it with a > single "file" directive. > > Say /home/jeff exists and I want to add /home/jeff/src/my/dir/path > > I tried: > > file { "/home/jeff/src/my/dir/path": > path => "/home/jeff/src/my/dir/path", > mode => 0755, > owner => jeff, > group => jeff, > ensure => directory, > recurse => true, > } > > But puppet complains the parent directory doesn''t exist. How can I do > the equivalent of > > mkdir -p /home/jeff/src/my/dir/path > > TIA, > Jeff > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi> file { "/home/jeff/src/my/dir/path": > path => "/home/jeff/src/my/dir/path", > mode => 0755, > owner => jeff, > group => jeff, > ensure => directory, > recurse => true, > } > > But puppet complains the parent directory doesn''t exist. How can I do > the equivalent of > > mkdir -p /home/jeff/src/my/dir/pathwith the file resource only with: file { [ ''/home/jeff/src/'', ''/home/jeff/src/my/'', ''/home/jeff/src/my/dir'', "/home/jeff/src/my/dir/path" : [...] } this is due to various reasons. the main reason for that is imho as puppet has to now about the things its manages. so to which point it should go back? and what then? recurse is only true from the managing point on deeper into the filesystem. (usefull for purging or source synching) another thing would be: exec{''mkdir -p /home/jeff/src/my/dir/path'': unless => ''test -d /home/jeff/src/my/dir/path'', } which is indeed ugly, but quick. greets 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 -~----------~----~----~----~------~----~------~--~---
Hey Jeff, Jeff wrote:> Hi all, > > I''d like to add a several directories and I can''t seem to do it with a > single "file" directive. > >You can do this with syntax, but puppet will still be explicitly managing each directory as a separate resource: $base = "/home/jeff" file {["$basedir", "$basedir/src", "$basedir/src/my", "$basedir/src/my/dir", "$basedir/src/my/dir/path" ]: #Just pass the file resource an array of files. mode => 0755, owner => jeff, group => jeff, ensure => directory, recurse => true }> Say /home/jeff exists and I want to add /home/jeff/src/my/dir/path > > I tried: > > file { "/home/jeff/src/my/dir/path": > path => "/home/jeff/src/my/dir/path", > mode => 0755, > owner => jeff, > group => jeff, > ensure => directory, > recurse => true, > } > > But puppet complains the parent directory doesn''t exist. How can I do > the equivalent of > > mkdir -p /home/jeff/src/my/dir/path >Puppet will implicitly order the creation of the directories, so it will behave like mkdir -p. A little more typing, still explicitly managed.> TIA, > Jeff > > >-- --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks all. One question: How do I reference the last directory in the array in a require statement? If I do this: file {["$basedir", "$basedir/src", "$basedir/src/my", "$basedir/src/my/dir", "$basedir/src/my/dir/path" ]: Can I do this: require => File["$basedir/src/my/dir/path"] TIA, Jeff --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jeff wrote:> Thanks all. > > One question: How do I reference the last directory in the array in a > require statement? > > If I do this: > > file {["$basedir", "$basedir/src", "$basedir/src/my", > "$basedir/src/my/dir", "$basedir/src/my/dir/path" ]: > > Can I do this: > > require => File["$basedir/src/my/dir/path"] >Yup, like I said the array stuff is just syntax. You are still managing individual file resources.> TIA, > Jeff > > >-- What is now proved was once only imagin''d. -- William Blake Teyo Tyree ::: http://reductivelabs.com ::: +1.615.275.5066 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
You also could do this by having your directory structure on your fileserver, of src/path/my Then file { "/home/jeff/src": mode => 0755, owner => jeff, group => jeff, ensure => directory, recurse => true; } If that directory structure is to be common across multiple users, it can save you some typing in the long run, if you set up a custom definition so that you can substitute $name everywhere there is a jeff... just a thought... On Oct 8, 1:47 pm, Teyo Tyree <t...@reductivelabs.com> wrote:> Hey Jeff, > > Jeff wrote: > > Hi all, > > > I''d like to add a several directories and I can''t seem to do it with a > > single "file" directive. > > You can do this with syntax, but puppet will still be explicitly > managing each directory as a separate resource: > > $base = "/home/jeff" > > file {["$basedir", "$basedir/src", "$basedir/src/my", > "$basedir/src/my/dir", "$basedir/src/my/dir/path" ]: #Just pass the > file resource an array of files. > mode => 0755, > owner => jeff, > group => jeff, > ensure => directory, > recurse => true > > } > > Say /home/jeff exists and I want to add /home/jeff/src/my/dir/path > > > I tried: > > > file { "/home/jeff/src/my/dir/path": > > path => "/home/jeff/src/my/dir/path", > > mode => 0755, > > owner => jeff, > > group => jeff, > > ensure => directory, > > recurse => true, > > } > > > But puppet complains the parent directory doesn''t exist. How can I do > > the equivalent of > > > mkdir -p /home/jeff/src/my/dir/path > > Puppet will implicitly order the creation of the directories, so it will > behave like mkdir -p. A little more typing, still explicitly managed. > > > TIA, > > Jeff > > ----~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Francois Deppierraz
2008-Oct-11 13:56 UTC
[Puppet Users] Re: The puppet equivalent of mkdir -p
Teyo Tyree wrote:> file {["$basedir", "$basedir/src", "$basedir/src/my", > "$basedir/src/my/dir", "$basedir/src/my/dir/path" ]: #Just pass the > file resource an array of files. > mode => 0755, > owner => jeff, > group => jeff, > ensure => directory, > recurse => true > }Because resources do not have implicit ordering, you might run into dependency problems with this example. If you''re not lucky enough, Puppet might try to create "$basedir/src/my/dir/path" before "$basedir". --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi>> file {["$basedir", "$basedir/src", "$basedir/src/my", >> "$basedir/src/my/dir", "$basedir/src/my/dir/path" ]: #Just pass the >> file resource an array of files. >> mode => 0755, >> owner => jeff, >> group => jeff, >> ensure => directory, >> recurse => true >> } > > Because resources do not have implicit ordering, you might run into > dependency problems with this example. > > If you''re not lucky enough, Puppet might try to create > "$basedir/src/my/dir/path" before "$basedir".no. afair puppet manages ordering within fileresources automagically. greets 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 -~----------~----~----~----~------~----~------~--~---
That''s correct - if you have parent directories in your manifest, puppet will have child files/folders autorequire the parent(s). The file { [ ''/foo'', ''/foo/bar'' ]: } syntax is currently the best way to achieve this, although with a Parser function you could split a full path into an array of resources to be managed, to cut down on typing/repetition. I recall Paul Lathrop was working on upwards recursion a while back.. There''s a ticket open with some details in Redmine. Regards, AJ On 12/10/2008, at 4:47 AM, Peter Meier <peter.meier@immerda.ch> wrote:> > Hi > >>> file {["$basedir", "$basedir/src", "$basedir/src/my", >>> "$basedir/src/my/dir", "$basedir/src/my/dir/path" ]: #Just pass the >>> file resource an array of files. >>> mode => 0755, >>> owner => jeff, >>> group => jeff, >>> ensure => directory, >>> recurse => true >>> } >> >> Because resources do not have implicit ordering, you might run into >> dependency problems with this example. >> >> If you''re not lucky enough, Puppet might try to create >> "$basedir/src/my/dir/path" before "$basedir". > > > no. afair puppet manages ordering within fileresources automagically. > > greets 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 -~----------~----~----~----~------~----~------~--~---
On Oct 8, 2008, at 1:00 PM, Jeff wrote:> > Thanks all. > > One question: How do I reference the last directory in the array in a > require statement? > > If I do this: > > file {["$basedir", "$basedir/src", "$basedir/src/my", > "$basedir/src/my/dir", "$basedir/src/my/dir/path" ]: > > Can I do this: > > require => File["$basedir/src/my/dir/path"]Files will automatically require their parent directories, if you''re managing them, so you don''t need to worry about setting up these relationships. -- I can''t understand why a person will take a year to write a novel when he can easily buy one for a few dollars. -- Fred Allen --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---