Forrie
2011-Dec-13 22:25 UTC
[Puppet Users] Using an array to manage a string of directories that need to be managed
I''ve read previous posts about iterating over arrays, hashes, etc. I have a series of directories that need to be created (and maintained, with appropriate permissions) that serve as NFS mount points on a series of systems. Sometimes, when they are no longer needed, they will be removed (another issue). I thought I could just create a simple array and then use a file {} statement to ensure they are created. Seems simple enough. Some don''t feel that''s the most efficient way. Since I''m going to be using autofs to ensure the mounts exist, I suppose I could craft a template which could make use of this array and then ship out the autofs configuration to each system, as a dependency. Might someone offer advice on how to best handle this one. Thanks! -- 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
2011-Dec-14 12:35 UTC
Re: [Puppet Users] Using an array to manage a string of directories that need to be managed
Hi, On 12/13/2011 11:25 PM, Forrie wrote:> I thought I could just create a simple array and then use a file {} > statement to ensure they are created. Seems simple enough. Some > don''t feel that''s the most efficient way. > > Since I''m going to be using autofs to ensure the mounts exist, I > suppose I could craft a template which could make use of this array > and then ship out the autofs configuration to each system, as a > dependency.this sounds pretty good to me. Cheers, Felix -- 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
2011-Dec-16 08:31 UTC
[Puppet Users] Re: Using an array to manage a string of directories that need to be managed
On 12/16/2011 08:07 AM, Alexandre wrote:> Hi, > If you find out how to do some kind of foreach() to iterate over a > Puppet array, that''s something i would to knowHi, there''s not really a foreach. Instead you define a type and make an instance of that for each array element. $users = [ "john", "joe", "horst" ] define user_with_repo() { user { $name: ... } vcsrepo { "repo-for-$name": ... } } # this is the "foreach": users_with_repo { $users: } Of course, this is harder if you need to supply individual data for each user, e.g. an SSH key. You would probably build a hash like $users = { name => key, ... }, and to create resources from that you need the create_resources function, see http://docs.puppetlabs.com/references/stable/function.html#createresources HTH, Felix> On 14 déc, 13:35, Felix Frank <felix.fr...@alumni.tu-berlin.de> wrote: >> Hi, >> >> On 12/13/2011 11:25 PM, Forrie wrote: >> >>> I thought I could just create a simple array and then use a file {} >>> statement to ensure they are created. Seems simple enough. Some >>> don''t feel that''s the most efficient way. >> >>> Since I''m going to be using autofs to ensure the mounts exist, I >>> suppose I could craft a template which could make use of this array >>> and then ship out the autofs configuration to each system, as a >>> dependency. >> >> this sounds pretty good to me. >> >> Cheers, >> Felix-- 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.