On Friday, April 29, 2016 at 11:51:12 AM UTC-5, Omen Wild wrote:
 

> I have a fairly extensive programming and sysadmin background, but am 
> still relatively new to Puppet. I inherited a pretty big setup that 
> started in the 0.x Puppet era and has evolved over time. Let me see if I 
> can parameterized ucdpuppet::kerberos::config: 
>
> class ucdpuppet::kerberos::config ($source = 
> $ucdpuppet::kerberos::params::krb5_source) 
>       inherits ucdpuppet::kerberos::params { 
>
>   file { $ucdpuppet::kerberos::params::krb5_conf_path: source => 
> "puppet:///modules/ucdpuppet/kerberos/$source" } 
> } 
>
>

Yes, that's the standard form for a parameterized class definition with a 
parameter default coming from a params class, a.k.a. the params class 
pattern.

 

> Then in nodes/%{::trusted.certname}.yaml for any host that needs to 
> override the default in ucdpuppet::kerberos::params, I put: 
>
> ucdpuppet::kerberos::params::krb5_source: "krb5.conf.special" 
>
>

No the key should identify the name and class of the parameter with which 
the value is associated, but you have given a name that matches the source 
of that parameter's default value.  Data binding will not change the value 
of the ::params class's variable; rather, it will cause Puppet to use the 
value drawn from Hiera *instead of* the value of the params-class 
variable.  To achieve that with your updated class definition, you want 
this:

ucdpuppet::kerberos::config::source: "krb5.conf.special"

 

> > Note that the code you present appears to be using class inheritance 
> > needlessly, and therefore inappropriately.  There are only two good 
> reasons 
> > for using class inheritance in Puppet: 
> > 
> >    1. To perform resource overrides on resources declared by the parent 
> >    class (or by a more distant ancestor) 
> >    2. To ensure that class variables of the parent class are available 
> for 
> >    use as class parameter defaults in the child class. 
>
> Like I said, inherited code base that started in the 0.x era, but given 
> the way I re-wrote ucdpuppet::kerberos::config above it looks like I fall 
> under 2). 
>


Yes, indeed.  As I said above, your rewrite is in the conventional form for 
params class pattern.  That's in fact orthogonal to automated data binding.

 

>
> Hmmm, looking it over it seems like I could do: 
>
> class ucdpuppet::kerberos::config { 
>    include ucdpuppet::kerberos::params 
>                  
>    file { $ucdpuppet::kerberos::params::krb5_conf_path: source => 
> "puppet:///modules/ucdpuppet/kerberos/${ucdpuppet::kerberos::params::krb5_source}"}
>  
>
> } 
>
>

Yes, if you do not parameterize, then that's how I would recommend doing it.

 

> Will ADB kick in for that one, or does it only apply for class parameters? 
>
>

ADB applies only to class parameters, not to other class variables.  Do be 
mindful, however, of my comments above about which parameter of which class 
is the appropriate target for ADB in this case.


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/ec05076f-5410-4ad8-b06e-2535963a82fc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to