Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

You are supposing that these will be modeled as class parameters in the first place. Certainly they are data that characterize the configuration to be deployed, and it is possible to model them as class parameters, but that is not the only – and maybe not the best – alternative available to you. Class parametrization is a protocol for declaring and documenting that data on which a class relies, and it enables mechanisms for obtaining that data that non-parametrized classes cannot use, but the same configuration objectives can be accomplished without them.

How to solve a 'macro substitution of the puppet code' issue (or whether we need to solve it at all)

Current Bigtop code uses quite a bit of dynamic lookups to solve a problem of multiple classes creating a pretty rich state in class-local variables and then calling onto a common piece of code to instantiate configuration files based on that information. Here's an example:

Code Block

class one_of_many {
    if ($::this == 'that') { 
       $var1 = 'something' 
    } else { 
        ....  
   } 

   include common_code
}

With older Puppets common_code class would have access to all the $varN variables simply by the virtue of doing dynamic scope lookups. With newer puppets the only alternative seems to be explicit ennumeration of all the variables that are required for common_code to perform its task. E.g.

Code Block

class common_code($var1, ... $varN) {
}
....
   class { "common_code": 
       var1 => $var1,
       ....
       varN => $var1
   }