On 11/21/2012 06:46 PM, AnOnJoe wrote:
> Hello,
> 
> I would like to know what are the best pratices in node declaration.
> 
> I tried to play with inheritance with failures :
> Here my*puppet/manifest/site.pp*
> 
>     node basenode {
>             class { 'ssh': }
>             class { 'ntp': }
>             class { 'users': }
>             class { 'sudo': }
>     }


First of all, don't instant classes like resources... Use include
instead. So this would look like:

node basenode {
  include ssh
  include ntp
  include users
  include sudo
}


> 
>     node default inherits basenode {
>     }
> 
>     ################################################################
>     # serv1
>     ################################################################
>     node "serv1" inherits basenode {
>             class { 'sudo' :
>                     sudoers => "sudoers_serv1"
>             }
>             class { 'debug': }
>     }

When you instance classes like resources, then you cannot instance it
twice. You can only do it once, and you already did it in the basenode.
This is like defining the same resource twice. Your main problem is in
the basenode.


> As you can see i have to manage 2 sudoers file :
> One in almost all server, and an other one in my "serv1" server
> 
> here is my *sudo class*
> 
>     class sudo ($sudoers="sudoers") {
>             package { 'sudo':
>                     ensure => installed,
>             }
>             file { '/etc/sudoers':
>                     source  =>
>     "puppet://puppetmaster.foo.com/sudo/$sudoers",
>                     ensure => file,
>                     mode   => 440,
>                     owner   => 'root',
>                     group           => 'root',
>                     require => Package['sudo'],
>             }

You can use Hiera for this purpose. In the hiera yaml manifests you can
just then define something like:

sudo::sudoers: sudoers_serv1

and your class would get the data from hiera. That way it would be
enough to include it into basenode, and you would have opportunity to
set up each node differently without redefining the classes. I really
urge you to invest some time into learning hiera.

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