So, general puppet design question. I have a definition called create_vg that creates an lvm volume group. An input to this is obviously the list of physical disks. In a normal programming language, I''d put the identification of the physical disks into one function, and pass the result of that to create_vg(). However, since a define in puppet can''t return a value (can it?), you don''t have many options unless you want to set it as a fact with fact-add, which bothers me, because your effectively than accumulating a list of global variables that may not need to be variable. So, your effectively left with putting the logic that determines the physical disks _inside_ create_vg(). No? Seems so... non functional! Doug -- 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 12 August 2012 08:30, Douglas Garstang <doug.garstang@gmail.com> wrote:> So, general puppet design question. I have a definition called > create_vg that creates an lvm volume group. An input to this is > obviously the list of physical disks. In a normal programming > language, I''d put the identification of the physical disks into one > function, and pass the result of that to create_vg(). > > However, since a define in puppet can''t return a value (can it?), you > don''t have many options unless you want to set it as a fact with > fact-add, which bothers me, because your effectively than accumulating > a list of global variables that may not need to be variable. > > So, your effectively left with putting the logic that determines the > physical disks _inside_ create_vg(). No? Seems so... non functional! >Defines are pretty much equivalent to defining new resource types, they don''t define a function. If you want to create a function that calculates something and returns a value, have a look at creating custom functions in ruby: http://docs.puppetlabs.com/guides/custom_functions.html -- Erik Dalén -- 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 Sunday, August 12, 2012 6:51:37 AM UTC-5, Erik Dalén wrote:> > On 12 August 2012 08:30, Douglas Garstang <doug.g...@gmail.com<javascript:>> > wrote: > > So, general puppet design question. I have a definition called > > create_vg that creates an lvm volume group. An input to this is > > obviously the list of physical disks. In a normal programming > > language, I''d put the identification of the physical disks into one > > function, and pass the result of that to create_vg(). > > > > However, since a define in puppet can''t return a value (can it?), you > > don''t have many options unless you want to set it as a fact with > > fact-add, which bothers me, because your effectively than accumulating > > a list of global variables that may not need to be variable. > > > > So, your effectively left with putting the logic that determines the > > physical disks _inside_ create_vg(). No? Seems so... non functional! > > > > Defines are pretty much equivalent to defining new resource types, > they don''t define a function. > If you want to create a function that calculates something and returns > a value, have a look at creating custom functions in ruby: > > http://docs.puppetlabs.com/guides/custom_functions.html > > Exactly. Or for small one-offs, prototyping, and/or quick-and-dirty jobsyou can use an inline template in place of a custom function. John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/Fxta1cFrKEcJ. 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.