I'm using the roles&profiles approach for my current puppet project.
The puppet best practices tell me:
- Expose all necessary profile parameters in the main class parameter list.
- Perform hiera lookups to fill in those parameters (having default values in module hiera)
- Do not access variables in the scope of other modules/profiles
- Be DRY (don't repeat yourself)
Now I'm facing the following problem (using puppet 5.5):
I have one basic profile that is included by all nodes (configuring apt, setting timezone, timeservers, etc...). Then I have several application-specific profiles (e.g. one for setting up IIS, one for settings up haproxy, etc...). Now I would like to add a log server to my application profiles. Of course I expect to specficy the log server only once in hiera (be DRY) but use it in all profiles.
My first approach is to add a log server parameter to the parameter list of my basic profile then access it from the application profiles using scoped variable access. But this contradicts the best practices because it adds a hidden interface/dependency between the modules.
Another approach I can come up with is to introduce a common hiera variable that I lookup with a explicit lookup. E.g.:
class profile::haproxy(
Stdlib::Host $log_server = lookup('common::log_server'),
) {}
This also feels fishy to me.
So my question is: how would I share variables between modules/profile without violating the best practices?