Exposed the Puppet 'package' resource's 'install_options' parameter via a new class parameter names 'package_options*. It takes an array of strings to pass installation options to the package provider of the targer OS (yum, apt-get, ...) Added validation of $package_options array Using stdlib' validate_array function to ensure that $package_options is a valid array (also if just empty). Cleaned array validation line Made $package_options undef by default Class parameter $package_options is now set to undef by default, validation is done in the class to ensure only an array would be passed to it if set. Added case for 'package_options' parameter Will test the use of the 'package_options' parameter being passed the YUM option --downloadonly which will see YUM return 0 but package will not be installed on system. Simplified test of 'package_options' parameter As the test 'select openjdk for Fedora 21 without installing' expects with a successful YUM run but the 'java' package not present, specifying package version is irrelevant. New case for complete installation with YUM option Added new case using 'package_options' with a a YUM option expected to not prevent rpm installation. Also added distribution parameter for test of 'pacakge_options' with yum option expected to prevent package installation. Removed validation of package name Removed validation of package name as it is not meant to be testing by 'select passed value for Fedora 21 with yum option' Removed test with '--downloadonly' The test of 'package_options* with the YUM option '---downloadonly' can't seem to be validate in CI. Other test 'select passed value for Fedora 21 with yum option' covers passing a value to 'package_options* and passes test in CI.
119 lines
3.5 KiB
Puppet
119 lines
3.5 KiB
Puppet
# Class: java
|
|
#
|
|
# This module manages the Java runtime package
|
|
#
|
|
# Parameters:
|
|
#
|
|
# [*distribution*]
|
|
# The java distribution to install. Can be one of "jdk" or "jre",
|
|
# or other platform-specific options where there are multiple
|
|
# implementations available (eg: OpenJDK vs Oracle JDK).
|
|
#
|
|
#
|
|
# [*version*]
|
|
# The version of java to install. By default, this module simply ensures
|
|
# that java is present, and does not require a specific version.
|
|
#
|
|
# [*package*]
|
|
# The name of the java package. This is configurable in case a non-standard
|
|
# java package is desired.
|
|
#
|
|
# [*package_options*]
|
|
# Array of strings to pass installation options to the 'package' Puppet resource.
|
|
# Options available depend on the 'package' provider for the target OS.
|
|
#
|
|
# [*java_alternative*]
|
|
# The name of the java alternative to use on Debian systems.
|
|
# "update-java-alternatives -l" will show which choices are available.
|
|
# If you specify a particular package, you will almost always also
|
|
# want to specify which java_alternative to choose. If you set
|
|
# this, you also need to set the path below.
|
|
#
|
|
# [*java_alternative_path*]
|
|
# The path to the "java" command on Debian systems. Since the
|
|
# alternatives system makes it difficult to verify which
|
|
# alternative is actually enabled, this is required to ensure the
|
|
# correct JVM is enabled.
|
|
#
|
|
# Actions:
|
|
#
|
|
# Requires:
|
|
#
|
|
# Sample Usage:
|
|
#
|
|
class java(
|
|
$distribution = 'jdk',
|
|
$version = 'present',
|
|
$package = undef,
|
|
$package_options = undef,
|
|
$java_alternative = undef,
|
|
$java_alternative_path = undef
|
|
) {
|
|
include java::params
|
|
|
|
validate_re($version, 'present|installed|latest|^[.+_0-9a-zA-Z:-]+$')
|
|
|
|
if $package_options != undef {
|
|
validate_array($package_options)
|
|
}
|
|
|
|
if has_key($java::params::java, $distribution) {
|
|
$default_package_name = $java::params::java[$distribution]['package']
|
|
$default_alternative = $java::params::java[$distribution]['alternative']
|
|
$default_alternative_path = $java::params::java[$distribution]['alternative_path']
|
|
$java_home = $java::params::java[$distribution]['java_home']
|
|
} else {
|
|
fail("Java distribution ${distribution} is not supported.")
|
|
}
|
|
|
|
$use_java_package_name = $package ? {
|
|
undef => $default_package_name,
|
|
default => $package,
|
|
}
|
|
|
|
## If $java_alternative is set, use that.
|
|
## Elsif the DEFAULT package is being used, then use $default_alternative.
|
|
## Else undef
|
|
$use_java_alternative = $java_alternative ? {
|
|
undef => $use_java_package_name ? {
|
|
$default_package_name => $default_alternative,
|
|
default => undef,
|
|
},
|
|
default => $java_alternative,
|
|
}
|
|
|
|
## Same logic as $java_alternative above.
|
|
$use_java_alternative_path = $java_alternative_path ? {
|
|
undef => $use_java_package_name ? {
|
|
$default_package_name => $default_alternative_path,
|
|
default => undef,
|
|
},
|
|
default => $java_alternative_path,
|
|
}
|
|
|
|
$jre_flag = $use_java_package_name ? {
|
|
/headless/ => '--jre-headless',
|
|
default => '--jre'
|
|
}
|
|
|
|
if $::osfamily == 'Debian' {
|
|
# Needed for update-java-alternatives
|
|
package { 'java-common':
|
|
ensure => present,
|
|
before => Class['java::config'],
|
|
}
|
|
}
|
|
|
|
anchor { 'java::begin:': }
|
|
->
|
|
package { 'java':
|
|
ensure => $version,
|
|
install_options => $package_options,
|
|
name => $use_java_package_name,
|
|
}
|
|
->
|
|
class { 'java::config': }
|
|
-> anchor { 'java::end': }
|
|
|
|
}
|