Setting a fact based on an included role (class)

21 views
Skip to first unread message

Rabbie Zalaf

unread,
Nov 25, 2014, 11:59:49 PM11/25/14
to puppet...@googlegroups.com
Hi All,

I am building a cluster of nodes in a master-less configuration.

I wanted to ask for some assistance in setting a fact based on an included role, early on in the configuration so that this fact is available for all profiles further down the deployment track.

I have the necessary configuration to reference the fact once it's been set but can't figure out how to set the fact early enough.

Rabbie

Felix Frank

unread,
Nov 28, 2014, 12:05:59 PM11/28/14
to puppet...@googlegroups.com
Hi,

that's a classic problem. It boils down to the ability to do this at
some point in your manifest:

if this_node_includes(class_X) {
# do stuff only for the <x> nodes
}

Puppet cannot compile this sort of manifest in a safe manner. It's
usually better to steer clear of such constructs.

Instead, implement some external logic that tells nodes whether they
should include class_X in the first place. This can be a flag that is
stored as a Hiera value, or a setting in your ENC.

You end up with very simple manifest constructs then.

# in site.pp perhaps
if $should_include_class_X {
include class_X
}

and everywhere else, instead of asking this_node_includes(class_X), you
cann just rely on the $should_include_class_X value.

HTH,
Felix
Reply all
Reply to author
Forward
0 new messages