Re: [Puppet Users] How to inherit a parameterized class ? What is the syntax ?

2011-10-18 Thread Alexandre Fouché
Hi,

The 3rd option is interesting, i should try it to see.

So far i had tried a similar way, with a "realize", but instead of
overriding the content file, i had some conditional blocks with a variable
in the puppet.conf.erb file. And it did not work, because it seems the
variable was never known at the time of the first "realize" call (by the
class puppet). But with a content overide, it should work, i suppose


2011/10/13 Nan Liu 

> On Thu, Oct 13, 2011 at 3:16 AM, Alexandre 
> 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 ?
>
> There's probably three ways to tackle it:
> 1. have the puppet class write a file called puppet.conf.agent, and
> the master class write puppet.conf.master and cat puppet.conf.* >
> puppet.conf.
> 2. use a variable and add some logic to the ERB template.
> 3. use the following syntax (be aware it realize and override):
>
> In class puppet::master:
>
> File <| title=='/etc/puppet/puppet.conf' |> {
>  content => template('puppet/puppetmaster.conf.erb'),
> }
>
> HTH,
>
> Nan
>
> --
> 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.



Re: [Puppet Users] How to inherit a parameterized class ? What is the syntax ?

2011-10-13 Thread Henrik Lindberg
Don't know if I am out on a limb here, but did you try setting class 
defaults?


class puppet::master inherits puppet {
  class { 'puppet': puppetmaster_fqdn => "my wanted value" }
  # ...
}

- henrik

On 10/13/11 12:16 PM, Alexandre 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'




--
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.



Re: [Puppet Users] How to inherit a parameterized class ? What is the syntax ?

2011-10-13 Thread Nan Liu
On Thu, Oct 13, 2011 at 3:16 AM, Alexandre  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 ?

There's probably three ways to tackle it:
1. have the puppet class write a file called puppet.conf.agent, and
the master class write puppet.conf.master and cat puppet.conf.* >
puppet.conf.
2. use a variable and add some logic to the ERB template.
3. use the following syntax (be aware it realize and override):

In class puppet::master:

File <| title=='/etc/puppet/puppet.conf' |> {
  content => template('puppet/puppetmaster.conf.erb'),
}

HTH,

Nan

-- 
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.



[Puppet Users] How to inherit a parameterized class ? What is the syntax ?

2011-10-13 Thread Alexandre
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'

-- 
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.