Ask Your Question

Apply common modules to all nodes and few modules to specific nodes

asked 2014-11-12 20:30:59 -0500

umairch gravatar image

updated 2014-11-12 20:31:43 -0500

I have 3 modules, i.e A, B and C. i want to apply "A" module to all nodes connected to master, and apply module "B" and "C" to selective nodes, Whats the proper way of doing it?


node default{ include ssh }

node '' { include users }

node '' { include ntp }

I am trying to do it this way but "ssh" module doesn't get applied to all nodes, Please suggest simple work around.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2014-11-12 22:57:22 -0500

llowder gravatar image

The default node is used when no other definition matches.

Your best option would be to use hiera. Create a key,typically classes and it holds a list of classes to apply

Scatter this key throughout your hierarchy as needed and then put common classes, such as your ssh class, into the key that is located in the bottom of your hierarchy - typically common or global.

Then use hiera_include('classes') in site.p, in the default node def OR outside all node defs.

This will make puppet find all the keys named classes and then combine them and apply those classes to the node.

You can find the full docs on this here

edit flag offensive delete link more


You can also use hiera to provide class parameters and values, so that all nodes can receive the ssh class but some nodes may provide different values for different parameters. Ramindk wrote up a great example at

rnelson0 gravatar imagernelson0 ( 2014-11-13 06:29:46 -0500 )edit

answered 2014-11-13 18:42:25 -0500

inhumantsar gravatar image

Option 1

Hiera, as llowder suggested.

Option 2

If you're not big on using Hiera, you can also create a 'base' node definition that includes all of the things common to all systems then inherit that in other node definitions. It's not the best solution, the Hiera setup is almost certainly better, but if you've got a small setup or you don't want to deal with have class includes scattered around then it might be worth considering.


node base { include ssh } 
node inherits base { include users } 
node inherits base { include ntp }

Option 3

Write a role that includes all of the common configurations and include that everywhere. This is getting into the roles/profiles paradigm that's become so popular with Puppet admins lately. I much prefer this method personally as it's simple, readable, modular and fits in nicely with environments.



class role_base { include ssh }


node { 
  include role_base
  include users

node {
  include role_base
  include ntp
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2014-11-12 20:30:59 -0500

Seen: 1,255 times

Last updated: Nov 13 '14