Greetings all, In beginning my quest into puppet. I came across a situation I would like for puppet to handle in a specific way, but I''m not sure if the ability currently exists. I''ve read about the various workarounds and limits on the ''file'' element, when using it to create directory structures (in regards to parent dirs). With that said, I was thinking that it might be helpful to do something such as this: class dir_tree { mkdir { "/var/repo/subdir": owner => root } mkdir { "/var/repo/subdir2": owner => root } mkdir { "/mnt/nas/nas01" } mkdir { "/mnt/nas/nas02" } } define mkdir ($owner => root, $group => root) { for each i in (split(''/'', $name) { file { $i: owner => $owner, $group => $group } } } Is this possible in puppet, or does it even make sense to implement something like this in puppet (still new, but loving the ''language'' already) ? Instead, I currently have something like this, which doesn''t look so bad and keeps the manifest simple and easy to read. But I''m wondering if it makes sense to be able to have a little more functionality for string manipulation and iteration in puppet.... class dir_tree { file { [ "/var", "/var/repo", "/var/subdir" ]: owner => root } ... etc ... } ---- Joe Miller GoDaddy.com
On Apr 3, 2007, at 7:35 PM, jmiller@godaddy.com wrote:> Greetings all, > > In beginning my quest into puppet. I came across a situation I would > like for puppet to handle in a specific way, but I''m not sure if the > ability currently exists.The short answer is that you can''t really do what you want. I recently did the groundwork to make it possible to create parent directories, but I have not finished up and actually done the work to do so.> I''ve read about the various workarounds and limits on the ''file'' > element, when using it to create directory structures (in regards to > parent dirs). With that said, I was thinking that it might be helpful > to do something such as this: > > class dir_tree { > mkdir { "/var/repo/subdir": owner => root } > mkdir { "/var/repo/subdir2": owner => root } > mkdir { "/mnt/nas/nas01" } > mkdir { "/mnt/nas/nas02" } > } > > define mkdir ($owner => root, $group => root) { > for each i in (split(''/'', $name) { > file { $i: owner => $owner, $group => $group } > } > } > > Is this possible in puppet, or does it even make sense to implement > something like this in puppet (still new, but loving the ''language'' > already) ?You can''t do anything like this in Puppet right now -- its array support is very primitive.> Instead, I currently have something like this, which doesn''t look > so bad > and keeps the manifest simple and easy to read. But I''m wondering > if it > makes sense to be able to have a little more functionality for string > manipulation and iteration in puppet.... > > class dir_tree { > file { [ "/var", "/var/repo", "/var/subdir" ]: owner => root } > > ... etc ... > }This is the only real way to do what you want in Puppet right now, and the simplicity of this is one reason why I haven''t worked to hard to enable recursively creating parent directories. -- It''s not the voting that''s democracy, it''s the counting. -- Tom Stoppard --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com
--On Tuesday, April 03, 2007 5:35 PM -0700 jmiller@godaddy.com wrote:> Is this possible in puppet, or does it even make sense to implement > something like this in puppet (still new, but loving the ''language'' > already) ?For this specific case, Luke has made changes to the file type. But in the more general sense, IMHO, the correct way to handle this would be to develop a native type in Ruby that does what you want to keep the Puppet language itself free from complex structures.
I''ve manged to get some loopish functionality going with: define do_something() { file { $name: owner => me, group => us, } } $myarray = [ "foo", "bar" ] do_something { $myarray: } Best, Adam Digant C Kasundra wrote:> --On Tuesday, April 03, 2007 5:35 PM -0700 jmiller@godaddy.com wrote: > >> Is this possible in puppet, or does it even make sense to implement >> something like this in puppet (still new, but loving the ''language'' >> already) ? > > For this specific case, Luke has made changes to the file type. But in the > more general sense, IMHO, the correct way to handle this would be to > develop a native type in Ruby that does what you want to keep the Puppet > language itself free from complex structures. > > > _______________________________________________ > Puppet-users mailing list > Puppet-users@madstop.com > https://mail.madstop.com/mailman/listinfo/puppet-users >
Apparently Analagous Threads
- Best practice, dev/test/staging/production environments
- CentOS 7 - Have 2 disks, each with a biosboot partition, can only boot off one of them
- [LLVMdev] Another missed optimization opportunity?
- new comer's question
- How to create a list that grows automatically