Dear puppetteers,

I am having a philosophical question about parametrized classes.
When building modules, one wants to be as flexible as possible, to try
to target as many puppet flavors as possible. This is our target:
- Foreman users, using foreman as an ENC with smart variables (or
potentially any other ENC, but I would say this is the most widespread one).
- Pure Puppet's site.pp users with Hiera as the only data binding.

But let's say that within mymodule there is a define mymodule::mydefine
that uses variable values from mymodule, let's say mymodule::parameter1.
I need to include mymodule to be able to use it, right? This is the example:

class mymodule (param1 = 'default_value') {
}

define mymodule::mydefine () {
  include mymodule     ## just to make sure it was parsed before
  case (mymodule::param1) {blabla}
}

If you only use Hiera as a data backend, you're good: if you need to
override parameter1, you do it in the hierarchy, and the include does
not disturb you. But if you want to target also an ENC, you are screwed:

classes:
  mymodule:
    param1: 'value'

ENC's way to pass class parameters (if I am not mistaken) is the classic
"class {mymodule: param1 => 'value'}", and when the define does the
include without parameters, an error would come for mixing parametrized
and not parametrized inclusions.

The problem really comes because I need a variable from another class
(in the same module, though)... but:
- Is it possible to force the parsing order so that I don't need to use
the include inside the define?
- Or is it possible to have the ENC push parameters the "Hiera" way
instead of the "Classic" way, so that both includes are equivalent?


Thanks a lot,
Pablo Fernandez


-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/529CC5E7.8010800%40cscs.ch.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to