Ask Your Question

using profile parameters (with hiera) in multiple class files.

asked 2014-12-10 23:51:05 -0500

mlanghor gravatar image

So I'm still struggling a bit with what's the "proper" design pattern, and what blocks to break off into files separated from init.pp. The puppetlabs apache module uses the params.pp, yet puppet-lint complains about inheriting from a params file.

I want to use a profile class and hiera lookups to get the proper values, but how to properly reuse the same variable in separate class files? Inherit, or define the variable multiple times? For example in an install.pp using a variable for the package name, then in the config.pp needing to: require => Package[$package_name]

Thanks for any help provided.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-12-17 22:43:18 -0500

GregLarkin gravatar image

You can define variables in one class and refer to them in other classes as long as you use the fully-scoped name. This entire page and the specific section that this link jumps to have a lot of information about variable scoping:

Here are some additional articles that may help you with your design:

Please post followup questions here if you have some. Also don't worry about that puppet-lint noise. As long as you're using newer versions of Puppet, you can ignore it, and we use the params pattern in our training courses. You can turn off the check with the --no-class_inherits_from_params_class-check command line argument.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2014-12-10 23:51:05 -0500

Seen: 324 times

Last updated: Dec 17 '14