Thank you. Will take a look at "Automated data binding".

On Thursday, June 9, 2016 at 6:44:56 PM UTC+5:30, jcbollinger wrote:
>
>
>
> On Wednesday, June 8, 2016 at 11:49:58 PM UTC-5, Harish Kothuri wrote:
>>
>> Hi,
>>
>> I have classA with parameter and i want to include this in another classB 
>> . I expected to consider the default value defined in foreman for classA 
>> but it's not happening. 
>>
>>
>> class classA ($version)
>> {
>>
> [...] 
>
>> }
>>
>>
>> class classB($variable)
>> {
>>
>> *include classA   # throws error in this line "Must pass parameter to 
>> Class [ClassA]*
>> [...]
>> }
>>
>>
>
> The Foreman is providing you an opportunity to define a default for the 
> class parameter *for its own purposes*.  This default applies when you 
> assign a class to a node directly via The Foreman, but it is external to 
> Puppet.  It does not apply when one class assigns another to the node.
>
> You have three main options:
>
>    1. In class B, use resource-like declaration of class A, in which you 
>    explicitly specify a value for class A's parameter.
>    2. Rely on automated data binding (i.e. Hiera) to specify a value for 
>    class A's parameter.
>    3. Specify your default value for the parameter in class A's 
>    definition.
>
> In fact, those options are non-exclusive: you can use any combination.  
> They are listed in priority order; the first one that provides a parameter 
> value wins.  For classes assigned directly via The Foreman, any parameter 
> assignments via The Foreman are roughly equivalent to option (1).  
> Parameter value binding is evaluated on a per-parameter basis, so different 
> parameters' values can be assigned via different options.
>
> HOWEVER, if you have any classes that may be declared more than once then 
> option (1) is largely off the table.  That option can be exercised at most 
> once for any given class, and that must occur in the first-evaluated 
> declaration of the class for a given catalog.  It can be difficult to 
> control the order in which declarations are evaluated, so exercising option 
> (1) safely can be tricky.
>
> Inasmuch as you can have only one default value per parameter built into a 
> class definition, and inasmuch as one prefers to avoid modifying 
> third-party modules, option (3) has somewhat limited utility.  You cannot 
> rely on it (exclusively) where you want a parameter to take different 
> values in different cases, and if you do not like the value you get this 
> way then your only means to change it is to modify the class definition.
>
> That leaves option (2) as the only truly general-purpose approach.  
> Automated data binding was one of the greatest advances in Puppet 3 -- 
> learn it, live it, love it.
>
>
> John
>
>

-- 
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/3962ce2c-83dd-4a0f-9883-b7c13670402c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to