Exclude or disable a class in Hiera (yaml backend)

1,801 views
Skip to first unread message

Vaidas Jablonskis

unread,
Oct 24, 2012, 12:19:43 PM10/24/12
to puppet...@googlegroups.com
Hi People,

Let's imagine a scenario where I have multiple nodes, a very simple hierarchy:

 - nodes/%{fqdn}
 - roles/%{role}
 - common

So what I am trying to achieve is for instance a class 'foo' is always included in 'common.yaml' and all the nodes will have that class included by default, but I want a specific node to have that class excluded or disabled. How do I do that?

I use hiera to include classes, for example my common.yaml looks like:

---
classes:
 - foo


I was told on #puppet IRC channel that there is a metaparameter called 'noop' which can be passed to already created class, but what hiera does is just a simple alternative to 'include foo', so I cannot really pass any metaparameters to my classes when including them with hiera.

What other alternatives do I have?

Thanks,
Vaidas

jcbollinger

unread,
Oct 24, 2012, 4:28:05 PM10/24/12
to puppet...@googlegroups.com

There are three main alternatives:
  1. The old-school way would be to create a subclass of the class you want to disable, and in it override properties of the base class's resources appropriately to (more or less) cancel the main class.  Include the subclass on the nodes that need it.
  2. You could also lift the troublesome class out of the "common" level of your data hierarchy (which would make sense because it's not really common).  You could move it to the role or even the node level, perhaps splitting your roles into role_with_special_class and role_without_special_class if it does not automatically fall out that way.  Or you could create a new hierarchy level between "common" and "role/*" where you would draw the distinction.  Or you could take it all the way out of hiera and use node blocks or top-level conditional statements in site.pp to direct which nodes get the class.
  3. Or you could modify your class to have some kind of override variable, read separately from hiera or computed by the class.  By setting some special value of that datum in per-node data, you could trigger a conditional statement in your class body that skips all the other declarations in the class.

John

Reply all
Reply to author
Forward
0 new messages