Biswa
Biswa

Reputation: 97

In puppet how to override a class variable if the class is already declared in a forged module

I am using jenkins puppet module from puppetlabs and want to install a particular java package in my jenkins machine. This jenkins puppet module uses java puppet module for java installation. I want to install a particular java package in my jenkins node. So I think I need to override the java::package variable of forged java module in my puppet module. Something like this -

class {'java':
      package => $my_jdk_package,
    }

But java::init class has already been overridden in jenkins::init.pp. Hence I can not redeclare java class in my puppet module. Any idea how to do this?

Upvotes: 1

Views: 916

Answers (1)

jaxim
jaxim

Reputation: 1115

You can set the install_java parameter to false in the jenkins class:

class { 'jenkins':
  install_java => false,
  require      => Class['java'],
}

The require parameter is to ensure that java is installed before jenkins. By setting the install_java parameter to false the jenkins module will no longer include the java class. This would then allow you to declare the java class in your jenkins node as you see fit:

class { 'java':
  package => $my_jdk_package,
}

If you are using hiera then you can override parameters like this:

---
java::package: 'packageyouwant' 

You would then not need to set install_java to false and not need to define the java class in your jenkins node.

Upvotes: 3

Related Questions