Hi all, thanks for your answers,

After some though and to keep it simple, i think the simplest way is to
simply merge the two classes as you proposed, and decide the behaviour with
a parameter.
As stupid as it is, i admit i did not even though about it, i was seeing my
current puppet class organisation and tried to go from there, but i should
have seen from a bit higher and rethink how to solve the problems from my
requirements and not from what i already had coded !

2011/10/14 jcbollinger <john.bollin...@stjude.org>

>
>
> On Oct 13, 5:16 am, Alexandre <alexandre.fou...@gmail.com> wrote:
> > Hi,
> >
> > I am trying to manage the puppet.conf file, but both my classes
> > 'puppet' and 'puppet::master' need to manage it. Basically, the class
> > 'puppet::master' should be able to override the resource, which could
> > be done by inheritance.
> > My problem is that my class 'puppet' is a parameterized class:
> >
> >     class puppet ( $puppetmaster_fqdn ) {
> >         file { '/etc/puppet/puppet.conf':
> >             content => template('puppet/puppet.conf.erb'),
> >         }
> >         # (...)
> >     }
> >
> > and so, i don't find any syntax to inherit from it:
> >
> >     class puppet::master ( $with_dashboard          = 'yes',
> >                            $with_cloud_provisioner  = 'no'
> >                          ) inherits puppet {
> >         # (...)
> >     }
> >
> > fails with
> >
> >     err: Could not retrieve catalog from remote server: Error 400 on
> > SERVER: Must pass puppetmaster_fqdn to Class[Puppet] at /etc/puppet/
> > modules/puppet/manifests/puppet.pp:1 on node (...)
> >
> > I tried different ways to declare my class 'puppet::master', but i do
> > not find the right syntax, it always fails
> >
> >     class puppet::master ( $puppetmaster_fqdn       = 'something',
> >                            $with_dashboard          = 'yes',
> >                            $with_cloud_provisioner  = 'no'
> >                          ) inherits puppet {
> >         # (...)
> >     }
> >
> >     class puppet::master ( $with_dashboard          = 'yes',
> >                            $with_cloud_provisioner  = 'no'
> >                          ) inherits puppet( puppetmaster_fqdn =>
> > 'something' ) {
> >         # (...)
> >     }
> >
> > What is the good syntax for that ?
> >
> > Note also that i tried to work around the problem by using a virtual
> > resource for my File['/etc/puppet.conf'], and realize it in both
> > classes (without inheritance) but it did not end up as i wished. It
> > worked, but the templated file missed the content which should have
> > been triggered by the variables $with_dashboard from class
> > 'puppet::master'
>
>
> To the best of my knowledge, you cannot inherit from a parameterized
> class.  It is one of the lesser of the several reasons I don't like
> them.
>
> There are a few of ways you can approach the problem:
>
> 1) Merge everything into one class.  Use variables / external data /
> parameters to determine whether to include the puppetmaster parts.
> This is more or less Nan's #2.
>
> 2) Remove your class parameterization, at least of the class
> puppet::puppet, so that class puppet::master can inherit from it.
> Class puppet::puppet can obtain an needed data from global variables
> or from an external source (i.e. via extlookup() or hiera).
>
> 3) Model separate sections of puppet.conf as separate resources,
> using, for instance, the Puppet-concat module.  This is similar to
> Nan's #1, but managed at a higher level.
>
> I do not recommend Nan's #3 (overriding a resource parameter when you
> realize File['/etc/puppet/puppet.conf']) because it's a maintenance
> problem waiting to bite you.  With that said, however, it probably
> does perform the job you want.
>
>
> John
>
> --
> 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+unsubscr...@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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to