Puppet Class: java

Defined in:
modules/java/manifests/init.pp

Overview

SPDX-License-Identifier: Apache-2.0

Class java

This class allows to deploy one or more versions of openjdk, choosing the favourite combination of version and variant (jdk, jdk-headless, etc.).

The first Java PackageInfo entry in $java_packages will be set as default via alternatives if more than one Java versions are listed.

Parameters:

  • java_packages (Array[Java::PackageInfo])

    Array of Java::PackageInfo to install

  • hardened_tls (Boolean) (defaults to: false)

    if true install hardened java configueration

  • edg_source

    the entropy daemon source

  • egd_source (Java::Egd_source) (defaults to: '/dev/random')
  • enable_dbg (Boolean) (defaults to: false)


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'modules/java/manifests/init.pp', line 13

class java (
    Array[Java::PackageInfo] $java_packages,
    Boolean                  $hardened_tls = false,
    Java::Egd_source         $egd_source   = '/dev/random',
    Boolean                  $enable_dbg   = false,
) {

    $java_packages.each |$java_package_info| {
        java::package { "openjdk-${java_package_info['variant']}-${java_package_info['version']}":
            package_info => $java_package_info,
            hardened_tls => $hardened_tls,
            egd_source   => $egd_source,
        }

        if $enable_dbg {
            ensure_packages(["openjdk-${java_package_info['version']}-dbg"])
        }
    }

    $default_java_package = $java_packages[0]

    # It will be nice to be able to reference this variable from outside of this class.
    # (secondary java version homes will have to be constructed by users)
    # E.g. in kafka profile we can use this var like
    # class { 'confluent::kafka::common':  java_home => $::java::java_home, ... }
    $java_home = "/usr/lib/jvm/java-${default_java_package['version']}-openjdk-amd64"
    $java_exec = "${java_home}/jre/bin/java"

    # By default set alternatives even if only one jvm is deployed on the host.
    alternatives::java { $default_java_package['version']:
        require => Java::Package["openjdk-${default_java_package['variant']}-${default_java_package['version']}"],
    }
}