Added possibility to pass options to package

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.
This commit is contained in:
Benjamin Merot
2015-12-09 12:01:15 +01:00
committed by Benjamin Merot
parent 5b6470acf6
commit 3842d6f657
2 changed files with 19 additions and 2 deletions

View File

@@ -18,6 +18,10 @@
# 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.
@@ -41,12 +45,17 @@ 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']
@@ -98,8 +107,9 @@ class java(
anchor { 'java::begin:': }
->
package { 'java':
ensure => $version,
name => $use_java_package_name,
ensure => $version,
install_options => $package_options,
name => $use_java_package_name,
}
->
class { 'java::config': }