问题
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:
- Is setting and passing the variable suitable in puppet for this?
- or should I use tags (as the classes are automatically tagged for this node)?
- Are their further approaches and what are limitations to above ones (e.g. do they work for resource types?)?
回答1:
You can absolutely use puppet this way. Read over the documentation for Parameterized Classes and see if that meets your needs.
来源:https://stackoverflow.com/questions/11229302/how-to-pass-node-specific-information-to-class-in-puppet