How to know parent(top) class

asked 2015-02-04 08:30:44 -0600

confiq gravatar image

Lets imagine we have following scenario:


class role::sensu inherits role {
 include profiles::sensu::server




class { 'sensu': server => true}


class { 'sensu': server => false}

Puppet is not supporting parameterized classes therefore this will not work. But the question is, is there a way for me to know in profilessensuclient.pp which class was called by? I assume I can use global variable? Can I use variable as $role::sensu::custom_var: ? Any info is welcomed...

P.S. Yes I know Hiera, I ask for curiosity

edit retag flag offensive close merge delete


Can you explain what you mean when you say "Puppet is not supporting parameterized classes therefore this will not work."?

GregLarkin gravatar imageGregLarkin ( 2015-02-04 10:24:53 -0600 )edit

sure, from > Puppet’s PARSER reads from the top of the file to the bottom of the file, and we have a single-pass parser when it comes to things like setting variables and declaring classes. Keep reading from there...

confiq gravatar imageconfiq ( 2015-02-05 03:18:02 -0600 )edit

Ok, what you mean is that you can't add the same class to the catalog, even if it has different parameters. That is correct. I'm still not exactly sure what your use case is, but are you looking for a special variable with the name of the calling module? If so, please see:

GregLarkin gravatar imageGregLarkin ( 2015-02-05 21:26:49 -0600 )edit