Hierarchy in puppet classes

42 views
Skip to first unread message

AAB !!

unread,
Mar 19, 2014, 4:58:56 AM3/19/14
to puppet...@googlegroups.com
Hi,
 Could someone tell me how can I have hierarchy in puppet classes ?.
I have some classes for services like ntp,ssh and many more. What I want is, these classes should be included for every puppet agent/node. Could I make a parent class and include these classes into in. And then in the node file for agent I can include only this parent class.
 Now in future if I have to include any new basic service like *backup* I dont have to edit the node file for each node to include the backup class, I  will simply  include the backup class in the parent class and all of my nodes will have that backup configuration.



Regards

Martin Alfke

unread,
Mar 19, 2014, 5:07:20 AM3/19/14
to puppet...@googlegroups.com
Hi,

this exactly is the reason why one should make use of roles and profiles
see
http://www.craigdunn.org/2012/05/239/
http://projects.puppetlabs.com/projects/puppet/wiki/Infrastructure_Design_Guidelines
http://docs.puppetlabs.com/pe/latest/puppet_assign_configurations.html#assigning-configuration-data-with-role-and-profile-modules

Personally I prefer a module with the name “role”

e.g.
role/manifests/base.pp

class role::base {
include ntp
include backup
include security
}

And within my node I am using this role:

node ‘foobar’ {
include role::base
...
}


hth,

Martin
> --
> 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...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/6d7dc4aa-f6cb-4e52-8f3e-8e55b585af8e%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Adeel Arif Bhatti

unread,
Mar 19, 2014, 6:03:26 AM3/19/14
to puppet...@googlegroups.com
Bundle of thanks !! But should this be a directory structure i.e.  role/manifests/base ???
and what would be the name of the file class which has 
class role::base {
  include ntp
  include backup
  include security
}
is it base.pp in role/manifests/ directory ???


You received this message because you are subscribed to a topic in the Google Groups "Puppet Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/puppet-users/9bjoSmicfR0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/53E5D619-5BD2-4406-BAAF-D14700C092A2%40gmail.com.

Martin Alfke

unread,
Mar 19, 2014, 7:01:56 AM3/19/14
to puppet...@googlegroups.com

On 19 Mar 2014, at 11:03, Adeel Arif Bhatti <adeelar...@gmail.com> wrote:

> Bundle of thanks !! But should this be a directory structure i.e. role/manifests/base ???

This is the basic concept of puppet modules.
On your master you have configured at least one module path (look into puppet.conf on your master).
Within that directory you build your modules:
<modulepath>/<modulename>/manifests/<classname>.pp


> and what would be the name of the file class which has
> class role::base {
> include ntp
> include backup
> include security
> }

class role::base

role = modulename
base = filename without file ending in <modulepath>/<modulename>/manifests

http://docs.puppetlabs.com/puppet/latest/reference/modules_fundamentals.html

> is it base.pp in role/manifests/ directory ???

yes.
> To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/CALMMbv2AOBDQXpcjy2iWq3cf_J0EDVBRwTpfdm_G63xG%3DG-4Bw%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages