Puppet right now requires every element of a path to have an individual file definition. This makes it had to take an arbitrary path as a parameter. You are forced to require your client to make the entire path structure for you or instead you use an exec resource and call mkdir -p. Using an exec resource does not generate an File resources so autorequire does not work. I didn''t like this, I wanted to be able to once specify a path and have puppet do that autorequire as needed. Something like: path {"/blah/blah/blah/and/blah": } In order to make this happen I would have to manually define each file: file {"/blah/": ensure => directory, } file {"/blah/blah/": ensure => directory, } file {"/blah/blah/blah/": ensure => directory, } file {"/blah/blah/blah/and/": ensure => directory, } file {"/blah/blah/blah/and/blah/": ensure => directory, } Of course there is a short hand for this: file {["/blah/", "/blah/blah/", "/blah/blah/blah/", "/blah/blah/blah/and/","/blah/blah/blah/and/blah/"]: ensure => directory, } Then it occurred to me I could parse the path and produce the array of elements needed. Something like: $path = "/blah/blah/blah/and/blah" $file_list = split($path, $file_separator) $paths = inline_template(''<% parent = nil %><%=@file_list.collect{ |file| parent.nil? ? parent = "#{@file_separator}":parent = "#{parent}#{file}#{@file_separator}"}.join(@path_separator) %>'') $path_list = split($paths, $path_separator) file{$path_list: ensure => directory, } This works great.... once. Then you get errors like: Error: Duplicate declaration: File[/] If there anyway to trim down the produced array by removing the resources that already exist? -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Actually I found if I created a resource between path and file called element, I could give it a unique name. Then inside the body I could check to see if the File is declared, if not I could declare it. On Thursday, April 4, 2013 9:23:54 AM UTC-7, Mike Power wrote:> > Puppet right now requires every element of a path to have an individual > file definition. This makes it had to take an arbitrary path as a > parameter. You are forced to require your client to make the entire path > structure for you or instead you use an exec resource and call mkdir -p. > Using an exec resource does not generate an File resources so autorequire > does not work. > > I didn''t like this, I wanted to be able to once specify a path and have > puppet do that autorequire as needed. > > Something like: > path {"/blah/blah/blah/and/blah": > } > > > In order to make this happen I would have to manually define each file: > file {"/blah/": > ensure => directory, > } > > file {"/blah/blah/": > ensure => directory, > } > > file {"/blah/blah/blah/": > ensure => directory, > } > > file {"/blah/blah/blah/and/": > ensure => directory, > } > > file {"/blah/blah/blah/and/blah/": > ensure => directory, > } > > Of course there is a short hand for this: > file {["/blah/", "/blah/blah/", "/blah/blah/blah/", > "/blah/blah/blah/and/","/blah/blah/blah/and/blah/"]: > ensure => directory, > } > > Then it occurred to me I could parse the path and produce the array of > elements needed. Something like: > $path = "/blah/blah/blah/and/blah" > $file_list = split($path, $file_separator) > $paths = inline_template(''<% parent = nil %><%=@file_list.collect{ > |file| parent.nil? ? parent = "#{@file_separator}":parent = > "#{parent}#{file}#{@file_separator}"}.join(@path_separator) %>'') > $path_list = split($paths, $path_separator) > file{$path_list: > ensure => directory, > } > > This works great.... once. Then you get errors like: > Error: Duplicate declaration: File[/] > > If there anyway to trim down the produced array by removing the resources > that already exist? > > > > > > > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Can you post a complete example please? Thanks Luca 2013/4/4 Mike Power <dodtsair@gmail.com>> Actually I found if I created a resource between path and file called > element, I could give it a unique name. Then inside the body I could check > to see if the File is declared, if not I could declare it. > > On Thursday, April 4, 2013 9:23:54 AM UTC-7, Mike Power wrote: >> >> Puppet right now requires every element of a path to have an individual >> file definition. This makes it had to take an arbitrary path as a >> parameter. You are forced to require your client to make the entire path >> structure for you or instead you use an exec resource and call mkdir -p. >> Using an exec resource does not generate an File resources so autorequire >> does not work. >> >> I didn''t like this, I wanted to be able to once specify a path and have >> puppet do that autorequire as needed. >> >> Something like: >> path {"/blah/blah/blah/and/blah": >> } >> >> >> In order to make this happen I would have to manually define each file: >> file {"/blah/": >> ensure => directory, >> } >> >> file {"/blah/blah/": >> ensure => directory, >> } >> >> file {"/blah/blah/blah/": >> ensure => directory, >> } >> >> file {"/blah/blah/blah/and/": >> ensure => directory, >> } >> >> file {"/blah/blah/blah/and/blah/": >> ensure => directory, >> } >> >> Of course there is a short hand for this: >> file {["/blah/", "/blah/blah/", "/blah/blah/blah/", >> "/blah/blah/blah/and/","/blah/**blah/blah/and/blah/"]: >> ensure => directory, >> } >> >> Then it occurred to me I could parse the path and produce the array of >> elements needed. Something like: >> $path = "/blah/blah/blah/and/blah" >> $file_list = split($path, $file_separator) >> $paths = inline_template(''<% parent = nil %><%=@file_list.collect{ >> |file| parent.nil? ? parent = "#{@file_separator}":parent >> "#{parent}#{file}#{@file_**separator}"}.join(@path_**separator) %>'') >> $path_list = split($paths, $path_separator) >> file{$path_list: >> ensure => directory, >> } >> >> This works great.... once. Then you get errors like: >> Error: Duplicate declaration: File[/] >> >> If there anyway to trim down the produced array by removing the resources >> that already exist? >> >> >> >> >> >> >> >> -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to puppet-users+unsubscribe@googlegroups.com. > To post to this group, send email to puppet-users@googlegroups.com. > Visit this group at http://groups.google.com/group/puppet-users?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
I have the same issue, I basically create an array, that way it cuts it down to one FILE, and not the same thing over and over again. file { ["/blah", "/blah/blah", "/blah/blah/blah", "/blah/blah/blah/blah", "/blah/blah/blah/blah/blah"]: ensure => directory, owner => "blah", group => "blah", mode => 0700, } On Monday, April 8, 2013 1:27:11 PM UTC-7, Luca Gioppo wrote:> > Can you post a complete example please? > Thanks > Luca > > > 2013/4/4 Mike Power <dodt...@gmail.com <javascript:>> > >> Actually I found if I created a resource between path and file called >> element, I could give it a unique name. Then inside the body I could check >> to see if the File is declared, if not I could declare it. >> >> On Thursday, April 4, 2013 9:23:54 AM UTC-7, Mike Power wrote: >>> >>> Puppet right now requires every element of a path to have an individual >>> file definition. This makes it had to take an arbitrary path as a >>> parameter. You are forced to require your client to make the entire path >>> structure for you or instead you use an exec resource and call mkdir -p. >>> Using an exec resource does not generate an File resources so autorequire >>> does not work. >>> >>> I didn''t like this, I wanted to be able to once specify a path and have >>> puppet do that autorequire as needed. >>> >>> Something like: >>> path {"/blah/blah/blah/and/blah": >>> } >>> >>> >>> In order to make this happen I would have to manually define each file: >>> file {"/blah/": >>> ensure => directory, >>> } >>> >>> file {"/blah/blah/": >>> ensure => directory, >>> } >>> >>> file {"/blah/blah/blah/": >>> ensure => directory, >>> } >>> >>> file {"/blah/blah/blah/and/": >>> ensure => directory, >>> } >>> >>> file {"/blah/blah/blah/and/blah/": >>> ensure => directory, >>> } >>> >>> Of course there is a short hand for this: >>> file {["/blah/", "/blah/blah/", "/blah/blah/blah/", >>> "/blah/blah/blah/and/","/blah/**blah/blah/and/blah/"]: >>> ensure => directory, >>> } >>> >>> Then it occurred to me I could parse the path and produce the array of >>> elements needed. Something like: >>> $path = "/blah/blah/blah/and/blah" >>> $file_list = split($path, $file_separator) >>> $paths = inline_template(''<% parent = nil %><%=@file_list.collect{ >>> |file| parent.nil? ? parent = "#{@file_separator}":parent = >>> "#{parent}#{file}#{@file_**separator}"}.join(@path_**separator) %>'') >>> $path_list = split($paths, $path_separator) >>> file{$path_list: >>> ensure => directory, >>> } >>> >>> This works great.... once. Then you get errors like: >>> Error: Duplicate declaration: File[/] >>> >>> If there anyway to trim down the produced array by removing the >>> resources that already exist? >>> >>> >>> >>> >>> >>> >>> >>> -- >> You received this message because you are subscribed to the Google Groups >> "Puppet Users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to puppet-users...@googlegroups.com <javascript:>. >> To post to this group, send email to puppet...@googlegroups.com<javascript:> >> . >> Visit this group at http://groups.google.com/group/puppet-users?hl=en. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
On 5 April 2013 03:23, Mike Power <dodtsair@gmail.com> wrote:> Puppet right now requires every element of a path to have an individual > file definition. This makes it had to take an arbitrary path as a > parameter. You are forced to require your client to make the entire path > structure for you or instead you use an exec resource and call mkdir -p. > Using an exec resource does not generate an File resources so autorequire > does not work. > > I didn''t like this, I wanted to be able to once specify a path and have > puppet do that autorequire as needed. > > People have been requesting this feature for over 7 years (http://projects.puppetlabs.com/issues/86). It won''t be accepted as there is not enough consensus as how to implement it. Read the very long arguments in the ticket notes for the intricacies John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
I''ll see if I can open source the component I wrote and upload it to puppet forge. In this way the open source community can continue the debate about what is the best way to do this, while at the same time those who want can use some solution other than mkdir -p -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
pls. post if you upload it to the forge or somewhere else.. would definetely be interested in getting rid of mkdir -p :) Den tirsdag den 9. april 2013 18.56.33 UTC+2 skrev Mike Power:> > I''ll see if I can open source the component I wrote and upload it to > puppet forge. In this way the open source community can continue the > debate about what is the best way to do this, while at the same time those > who want can use some solution other than mkdir -p >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Apparently Analagous Threads
- Managing /etc/fstab with puppet
- inline_template private method `gets' called for false:FalseClass
- Ubuntu 8.04 Hardy Heron bridged networking xen connectivity loss
- I can't seem to create mountpoint and change permissions after mounting in 2.7.3
- Error: Could not find class <class> for <host> on node <host>