Actually you don't have to inherit, you can (and should) just have
something like:
class dk_oracle_java::install {
include dk_oracle_java
package { 'oracle-java8-installer':
ensure => $::dk_oracle_java::version,
}
}
The above include is not necessary if you are already incuding the
dk_oracle_java class somewhere else, just be sure that the class is
included before you refer to its variables.
The only currently acceptable reasons to use class inheritance is:
- when using the params patterm (main class of a module inheriting the
params one), which is actully now totally unnecessary and can be replaced
by data in module.
- when for whatever reason you have to change some parameters of a resource
already declared in the inherited class, and also for this case you can
have other workarounds.
Anyway inheritance still works, and so if it works for you it's ok.
On Monday, May 7, 2018 at 12:03:47 AM UTC+2, Joaquin Menchaca wrote:
>
> I spotted it, seems obvious now:
>
> class dk_oracle_java::install inherits dk_oracle_java {
> package { 'oracle-java8-installer':
> ensure => $version,
> }
> }
>
> On Sunday, May 6, 2018 at 2:55:40 PM UTC-7, Joaquin Menchaca wrote:
>>
>> I am sleuthing for this and haven't found anything obvious yet.
>>
>> I have an init.pp that looks like this
>>
>> class dk_oracle_java (
>> $docroot = $::dk_oracle_java::params::docroot,
>> Optional[String] $local_repo = $::dk_oracle_java::params::local_repo,
>> $version = $::dk_oracle_java::params::version,
>> $javas = $::dk_oracle_java::params::javas,
>> ) inherits ::dk_oracle_java::params {
>> include ::dk_oracle_java::install
>> }
>>
>> And I want to access the $version in my install.pp, but I am not sure how
>> to do this.
>>
>> class dk_oracle_java::install {
>> package { 'oracle-java8-installer':
>> ensure => $version,
>> }
>> }
>>
>> How can I get this to work, or what is the best practice. Can the
>> install.pp access parameters from the base class, $::version? Or does this
>> need to be passed downward?
>>
>
--
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/c5fda6c6-0556-48ed-8620-6af0833302ac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.