We are trying to override a resource that was created with ''define'' but we are receiving the following error: Only subclasses can override parameters at /etc/puppet/manifests/... Here is a specific example: https://gist.github.com/anonymous/5428129 Is this even possible? If not, how would you work around this? Thanks -- 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.
jcbollinger
2013-Apr-22 15:04 UTC
[Puppet Users] Re: Help me with overriding define resource
On Saturday, April 20, 2013 8:45:24 PM UTC-5, Smashed wrote:> > We are trying to override a resource that was created with ''define'' but we > are receiving the following error: Only subclasses can override parameters > at /etc/puppet/manifests/... > > Here is a specific example: https://gist.github.com/anonymous/5428129 > > Is this even possible? If not, how would you work around this? > >The parameters of resources of defined types can be overridden just the same as parameters of native types. I don''t see anything in your gist that explains the error you describe. It is incomplete, however, in that nothing in it declares the referenced resources Package[''nrpe''] and Service[''nrpe''], and nothing declares class ''foo'', which presumably is supposed to be where the error occurs. If you provide a complete example that genuinely reproduces the error then we can be more helpful. If you provide the full error message that goes with the example you provide then we can be more helpful. 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.
It looks like when you use composition you can''t redefine a class: https://gist.github.com/anonymous/5445418 IE.. you can''t redefine a resource that was included. I feel like the composition method listed above should work as definition is still part of the same node. Seems a bit hacky to create a class just to subclass something you want to override. Thoughts? On Apr 22, 2013, at 8:04 AM, jcbollinger <John.Bollinger@stJude.org> wrote:> > > On Saturday, April 20, 2013 8:45:24 PM UTC-5, Smashed wrote: > We are trying to override a resource that was created with ''define'' but we are receiving the following error: Only subclasses can override parameters at /etc/puppet/manifests/... > > Here is a specific example: https://gist.github.com/anonymous/5428129 > > Is this even possible? If not, how would you work around this? > > > The parameters of resources of defined types can be overridden just the same as parameters of native types. I don''t see anything in your gist that explains the error you describe. It is incomplete, however, in that nothing in it declares the referenced resources Package[''nrpe''] and Service[''nrpe''], and nothing declares class ''foo'', which presumably is supposed to be where the error occurs. > > If you provide a complete example that genuinely reproduces the error then we can be more helpful. If you provide the full error message that goes with the example you provide then we can be more helpful. > > > 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. > >-- 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.
jcbollinger
2013-Apr-24 13:56 UTC
Re: [Puppet Users] Help me with overriding define resource
On Tuesday, April 23, 2013 12:02:49 PM UTC-5, Smashed wrote:> > It looks like when you use composition you can''t redefine a class: > https://gist.github.com/anonymous/5445418 IE.. you can''t redefine a > resource that was included. >That is correct. It is also a different case from the one in your earlier gist.> > I feel like the composition method listed above should work as definition > is still part of the same node. Seems a bit hacky to create a class just to > subclass something you want to override. Thoughts? > >Overriding resource parameters is the primary purpose of class inheritance in Puppet. It''s not hacky to use a tool for its intended purpose. What''s hacky is subclassing without overriding any resource parameters. A class represents some coherent unit of configuration space (or ought to do), so why would it be sensible to allow random declarations in any unrelated place to override the declarations a given class makes? Using a subclass to declare overrides involves at least a pro forma acknowledgement that the purpose and use of the overridden declaration is understood at the point where it is override is declared. Composition does not have the same effect. In particular, being part of the same node is no distinguishing characteristic at all. For any given catalog compilation *all*declarations that are evaluated apply to the same node. 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.
Felix Frank
2013-Apr-29 22:27 UTC
Re: [Puppet Users] Help me with overriding define resource
John, you''re such a tease ;-) While I mostly agree with the points you''re making (as so often), I feel that this thread is incomplete without giving an example of the syntactically correct implementation of the original idea. Note that this approach has a number of issues and should usually be avoided. Use at your own peril. class composition { include base_class // wrong: //Definition[''TestCase''] { // right: Definition<| title == ''TestCase'' |> { var => ''/tmp/bar'', } } On 04/24/2013 03:56 PM, jcbollinger wrote:> A class represents some coherent unit of configuration space (or ought > to do), so why would it be sensible to allow random declarations in any > unrelated place to override the declarations a given class makes? Using > a subclass to declare overrides involves at least a pro forma > acknowledgement that the purpose and use of the overridden declaration > is understood at the point where it is override is declared. > Composition does not have the same effect.HTH, Felix -- 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.