Ask Your Question

Install plugins depending on the inclusion of a specific class?

asked 2013-04-08 11:18:42 -0600

plin gravatar image

updated 2013-04-10 04:30:39 -0600


We are currently using a role/profile/component based approach to manage our puppet nodes.

A node maps to one role. A role maps to several profiles. A profile maps to several components.

Using this approach we defined something like this

class role::virt_host {
  include profile::default
  include profile::users::admin
  include profile::virt::libvirt
  include *profile::munin::client* # <-- the line in question

class profile::virt::libvirt {
  include component::libvirt::packages
  include component::libvirt::munin

Up until here everything is working fine.

The aim is to have the component::libvirt::munin install additional munin plugins if and only if ... (more)

edit retag flag offensive close merge delete


I'm probably misunderstanding, but why not just get profile::munin::client to include a class that installs the additional munin plugins?

jonn gravatar imagejonn ( 2013-04-09 06:31:23 -0600 )edit

Jonn: The reason I did not just add those plugins to the existing profile::munin::client class is that I do not want packages on the system that are not ...(more)

plin gravatar imageplin ( 2013-04-09 07:02:05 -0600 )edit

Are you saying that profile::munin::client is included on all servers, even those which are not going to be a munin client? If so then maybe you need a ...(more)

jonn gravatar imagejonn ( 2013-04-09 09:06:36 -0600 )edit

No, not what I was trying to convey. Let me try again :) I added some example node descriptions to the original question due to comment character limitations

plin gravatar imageplin ( 2013-04-10 04:31:32 -0600 )edit

Thanks :) Which role classes are applied to nodes A, B and C? Does node C include role::virt_host?

jonn gravatar imagejonn ( 2013-04-10 05:33:09 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2013-04-08 12:45:16 -0600

Ancillas gravatar image

You should be able to make this work with dependency chaining and anchors. In role::virt_host, the include profile::virt:libvirt should depend on include profile::munin::client.

You'll need to make sure that all of your include statements are properly contained with anchors so that Puppet handles the dependencies correctly.

I solved a similar problem a little while ago and posted my final code. You might be able to adapt it to your needs.

edit flag offensive delete link more

answered 2013-04-10 08:45:38 -0600

jonn gravatar image

It sounds a lot like you have a role for each of your server types. I guess I'm struggling to understand why you want to make your profile and component classes tightly coupled in this way, with the functionality of class A being dependent on class B. Designing classes that could be simply included into your profiles to provide the functionality that is required in each case seems a cleaner way of doing things. (You don't necessarily need to add lots of new classes to do this - you could use parameterized classes to provide differing functionality where necessary ... (more)

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


Asked: 2013-04-08 11:18:42 -0600

Seen: 70 times

Last updated: Apr 10 '13