Guillaume Rousse
2012-Sep-17 14:51 UTC
[Puppet Users] inheritance failure: duplicate declaration error
Hello list. I''ve the following parent class: class munin::client { ... munin::client::plugin { "postfix_mailqueue": name => "postfix_mailqueue", enable => "false" } } And the following inherited class: class munin::client::plugins::postfix inherits munin::client { munin::client::plugin { "postfix_mailqueue": name => "postfix_mailqueue", source => "postfix_mailqueue", enable => "true" } } munin::client::plugin is a custom type, allowing to easily enable/disable munin plugins, according to the following definition: define munin::client::plugin($name, $source, $enable="true") { case $enable { "true": { file { "${name}_link": path => "$destdir/$name", ensure => "link", target => "$sourcedir/$source", } } "false": { file { "${name}_link": path => "$destdir/$name", ensure => "absent", } } } } According to my understanding of how inheritance works, it should allow to easily redefine default behaviour in some specific nodes by just adding munin::client::plugins::postfix class in addition to munin::client, inherited through default node definition. However, it fails with the following error message: err: Could not retrieve catalog from remote server: Error 400 on SERVER: Duplicate declaration: Munin::Client::Plugin[postfix_mailqueue] is already declared in file /var/lib/puppet/devrousse/modules/munin/manifests/client.pp at line 135; cannot redeclare at /var/lib/puppet/devrousse/modules/munin/manifests/client/plugins/postfix.pp:11 on node dev-zimbra.inria.fr I originally tought it was the double inclusion of both the base and the derivated class that was causing the issue, so I attempted to remove the base classe for the default node definition, so as to only include the derivated one: same result :( So, what is the generic design pattern for including default classes in default node definition, while still allowing to override them in specific nodes ? -- BOFH excuse #389: /dev/clue was linked to /dev/null -- 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.
Stephen Gran
2012-Sep-17 15:08 UTC
Re: [Puppet Users] inheritance failure: duplicate declaration error
Hi, On Mon, 2012-09-17 at 16:51 +0200, Guillaume Rousse wrote:> Hello list. > > I''ve the following parent class: > > class munin::client { > > ... > > munin::client::plugin { "postfix_mailqueue": > name => "postfix_mailqueue", > enable => "false" > } > } > > And the following inherited class: > > class munin::client::plugins::postfix inherits munin::client { > > munin::client::plugin { "postfix_mailqueue": > name => "postfix_mailqueue", > source => "postfix_mailqueue", > enable => "true" > } > > }It looks like you''re attempting to redeclare, rather than override, the plugin definition, as the error tells you. Try: Munin::Client::Plugin[postfix_mailqueue] { enable => "true" } Cheers, -- Stephen Gran Senior Systems Integrator - guardian.co.uk Please consider the environment before printing this email. ------------------------------------------------------------------ Visit guardian.co.uk - newspaper of the year www.guardian.co.uk www.observer.co.uk www.guardiannews.com On your mobile, visit m.guardian.co.uk or download the Guardian iPhone app www.guardian.co.uk/iphone and iPad edition www.guardian.co.uk/iPad Save up to 37% by subscribing to the Guardian and Observer - choose the papers you want and get full digital access. Visit guardian.co.uk/subscribe --------------------------------------------------------------------- This e-mail and all attachments are confidential and may also be privileged. If you are not the named recipient, please notify the sender and delete the e-mail and all attachments immediately. Do not disclose the contents to another person. You may not use the information for any purpose, or store, or copy, it in any way. Guardian News & Media Limited is not liable for any computer viruses or other material transmitted with or as part of this e-mail. You should employ virus checking software. Guardian News & Media Limited A member of Guardian Media Group plc Registered Office PO Box 68164 Kings Place 90 York Way London N1P 2AP Registered in England Number 908396 -- 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.
Guillaume Rousse
2012-Sep-17 15:36 UTC
Re: [Puppet Users] inheritance failure: duplicate declaration error
Le 17/09/2012 17:08, Stephen Gran a écrit :> It looks like you''re attempting to redeclare, rather than override, the > plugin definition, as the error tells you. > > Try: > > Munin::Client::Plugin[postfix_mailqueue] { enable => "true" }Good catch... Thanks for your help. -- BOFH excuse #286: Telecommunications is downgrading. -- 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.