Bertolt
Bertolt

Reputation: 1045

How to pass node specific information to class in puppet?

I want to pass node specific information to a class, which then could evaluate it for specific purposes. Actually this question consists of three parts.

Say, I have the following node:

node 'devbox' {
    $serverType = 'something'

    include someClass

    someOtherClass { 'someOtherClass': 
        par1 => 'value',     
    }

    targetClass { 'nodeInformationShouldGoHere': }
}

Inside targetClass, I want to evaluate if serverType, someClass or someOtherClass is set (e.g. with if-else). My questions now are:

  1. Is setting and passing the variable suitable in puppet for this?
  2. or should I use tags (as the classes are automatically tagged for this node)?
  3. Are their further approaches and what are limitations to above ones (e.g. do they work for resource types?)?

Upvotes: 1

Views: 286

Answers (1)

joshcody
joshcody

Reputation: 105

You can absolutely use puppet this way. Read over the documentation for Parameterized Classes and see if that meets your needs.

Upvotes: 2

Related Questions