How to know parent(top) class

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

confiq gravatar image

Lets imagine we have following scenario:

role_sensu.pp

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

role.pp

profiles::sensu::client

profiles_sensu_server.pp

class { 'sensu': server => true}

profiles_sensu_client.pp

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

Comments

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 http://garylarizza.com/blog/2014/02/17/puppet-workflow-part-2/ > 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
1

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: http://bit.ly/1KwNOv0

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