On Wed, Nov 16, 2016 at 10:51 AM, Craig Dunn <[email protected]> wrote:

>
>
> On Wed, Nov 16, 2016 at 10:42 AM, Albert Shih <[email protected]>
> wrote:
>
>>  Le 16/11/2016 à 10:34:36+0100, Craig Dunn a écrit
>>
>> > # Tomcat class has an attribute called "catalina_home" which is looked
>> up from
>> > hiera data binding....
>> > include ::tomcat
>> >
>> > class { "my_application":
>> >   tomcat_root => $::tomcat::catalina_home
>> > }
>>
>> SUPER nice.....
>>
>> I didn't think about that....
>>
>> Don't know why but I always thought that was « bad practice » to access
>> some attribute from outside the module.
>>
>
> Not at all - especially not when done from the profiles.
>
>
Going off topic, but I should clarify my view on that - I don't consider it
bad practice to access an *attribute*, if the module is following semver
standards the attribute should be considered part of the public API and I
should expect that not to break until a major version release... however
this rule doesn't apply to *all* variables, consider this example

class tomcat (
  $catalina_home = $::tomcat::params::catalina_home,
  ...
) {

  $bindir = "${catalina_home}/bin"
  ...
}

In this example, I would consider $::tomcat::catalina_home to be part of
the API and perfectly acceptable to call this from your profiles, I would
urge caution using $::tomcat::bindir though because this is a variable used
in the internals of the class and not exposed as a documented attribute, I
would consider this to be 'private' and expect that even a patch version
release could break this.

Craig


-- 
Enviatics     |      Automation and Configuration Management
Puppet Labs Service Delivery Partner & Certified Consultant
http://www.enviatics.com | @Enviatics | [email protected]

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CACxdKhHg579vePd%2B%3DQ3M4_MXVQdiShtQNpVy-%3DOU-VSAW5tHfw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to