Philip Brown
2012-Sep-25 15:57 UTC
[Puppet Users] How to make a module reject invalid parameter
I tried a few google searches on this, and attempted to look through docs.puppetlabs.com, but couldnt find anything... how do you make a module throw an error for an unrecognized parameter? ie: class setitup($machtype) { case $machtype { prod: { blah} dev: {blah} default: { error Unrecognized machtype parameter value } } } -- 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/-/_8zyA3QImNcJ. 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.
windowsrefund
2012-Sep-25 16:14 UTC
[Puppet Users] Re: How to make a module reject invalid parameter
if !$foo { fail ''foo is missing'' } -- 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/-/MikiJcuantMJ. 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.
Justin Stoller
2012-Sep-25 17:15 UTC
Re: [Puppet Users] How to make a module reject invalid parameter
On Tue, Sep 25, 2012 at 8:57 AM, Philip Brown <phil@bolthole.com> wrote:> I tried a few google searches on this, and attempted to look through > docs.puppetlabs.com, but couldnt find anything... > > how do you make a module throw an error for an unrecognized parameter? > > ie: > > class setitup($machtype) { > case $machtype { > prod: { blah} > dev: {blah} > default: { error Unrecognized machtype parameter value } > } > } >I think you''ll have better luck in the standard library: https://github.com/puppetlabs/puppetlabs-stdlib Specifically the validate_*, type, member, and is_* functions are all for helping validate parameters. Documentation is the in the Readme and pretty good. HTH, Justin> > > -- > 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/-/_8zyA3QImNcJ. > 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 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.