Merge pull request #237 from hunner/release_2.1.0

Release 2.1.0
This commit is contained in:
Eric Putnam
2017-06-13 16:31:32 -07:00
committed by GitHub
10 changed files with 149 additions and 70 deletions

View File

@@ -1,3 +1,17 @@
## Supported Release 2.1.0
### Summary
This release adds fixes to restore the ability to install Oracle Java. It also
fixes the paths for the latest RHEL 7 1.7.0 and 1.8.0 OpenJDKs.
### Added
- java::oracle parameter `url`
- java::oracle parameter `url_hash`
### Fixed
- Let `java_default_home` fact work when /usr/bin/java doesn't exist
- Add puppet 4 parameter types
- Use `/usr/lib/jvm/java-1.x.0` symlinks for `java_home` defaults.
## Supported Release 2.0.0 ## Supported Release 2.0.0
### Summary ### Summary

View File

@@ -13,7 +13,7 @@
## Overview ## Overview
Installs the correct Java package on various platforms. Installs the correct Java package on various platforms.
## Module Description ## Module Description
@@ -22,29 +22,30 @@ The java module can automatically install Java jdk or jre on a wide variety of s
## Setup ## Setup
### Beginning with the java module ### Beginning with the java module
To install the correct Java package on your system, include the `java` class: `include java`. To install the correct Java package on your system, include the `java` class: `include java`.
## Usage ## Usage
The java module installs the correct jdk or jre package on a wide variety of systems. By default, the module installs the jdk package, but you can set different installation parameters as needed. For example, to install jre instead of jdk, you would set the distribution parameter: The java module installs the correct jdk or jre package on a wide variety of systems. By default, the module installs the jdk package, but you can set different installation parameters as needed. For example, to install jre instead of jdk, you would set the distribution parameter:
~~~ ```puppet
class { 'java': class { 'java':
distribution => 'jre', distribution => 'jre',
} }
~~~ ```
To install the latest patch version of Java 8 on CentOS To install the latest patch version of Java 8 on CentOS
~~~ ```puppet
class { 'java' : class { 'java' :
package => 'java-1.8.0-openjdk-devel', package => 'java-1.8.0-openjdk-devel',
} }
~~~ ```
The defined type `java::oracle` installs one or more versions of Oracle Java SE. `java::oracle` depends on [puppet/archive](https://github.com/voxpupuli/puppet-archive). By using `java::oracle` you agree to Oracle's licensing terms for Java SE. The defined type `java::oracle` installs one or more versions of Oracle Java SE. `java::oracle` depends on [puppet/archive](https://github.com/voxpupuli/puppet-archive). By using `java::oracle` you agree to Oracle's licensing terms for Java SE.
~~~ ```puppet
java::oracle { 'jdk6' : java::oracle { 'jdk6' :
ensure => 'present', ensure => 'present',
version => '6', version => '6',
@@ -56,18 +57,18 @@ java::oracle { 'jdk8' :
version => '8', version => '8',
java_se => 'jdk', java_se => 'jdk',
} }
~~~ ```
To install a specific release of a Java version, e.g. 8u101-b13, provide both parameters `version_major` and `version_minor` as follows: To install a specific release of a Java version, e.g. 8u101-b13, provide both parameters `version_major` and `version_minor` as follows:
~~~ ```puppet
java::oracle { 'jdk8' : java::oracle { 'jdk8' :
ensure => 'present', ensure => 'present',
version_major => '8u101', version_major => '8u101',
version_minor => 'b13', version_minor => 'b13',
java_se => 'jdk', java_se => 'jdk',
} }
~~~ ```
## Reference ## Reference
@@ -85,26 +86,32 @@ java::oracle { 'jdk8' :
#### Parameters #### Parameters
The following parameters are available in `java`: The following parameters are available in `java`:
##### `distribution` ##### `distribution`
Specifies the Java distribution to install.
Specifies the Java distribution to install.
Valid options: 'jdk', 'jre', or, where the platform supports alternative packages, 'sun-jdk', 'sun-jre', 'oracle-jdk', 'oracle-jre'. Default: 'jdk'. Valid options: 'jdk', 'jre', or, where the platform supports alternative packages, 'sun-jdk', 'sun-jre', 'oracle-jdk', 'oracle-jre'. Default: 'jdk'.
##### `java_alternative` ##### `java_alternative`
Specifies the name of the Java alternative to use. If you set this parameter, *you must also set the `java_alternative_path`.*
Specifies the name of the Java alternative to use. If you set this parameter, *you must also set the `java_alternative_path`.*
Valid options: Run command `update-java-alternatives -l` for a list of available choices. Default: OS and distribution dependent defaults on *deb systems, undef on others. Valid options: Run command `update-java-alternatives -l` for a list of available choices. Default: OS and distribution dependent defaults on *deb systems, undef on others.
##### `java_alternative_path` ##### `java_alternative_path`
*Required when `java_alternative` is specified.* Defines the path to the `java` command.
*Required when `java_alternative` is specified.* Defines the path to the `java` command.
Valid option: String. Default: OS and distribution dependent defaults on *deb systems, undef on others. Valid option: String. Default: OS and distribution dependent defaults on *deb systems, undef on others.
##### `package` ##### `package`
Specifies the name of the Java package. This is configurable in case you want to install a non-standard Java package. If not set, the module installs the appropriate package for the `distribution` parameter and target platform. If you set `package`, the `distribution` parameter does nothing.
Valid option: String. Default: undef. Specifies the name of the Java package. This is configurable in case you want to install a non-standard Java package. If not set, the module installs the appropriate package for the `distribution` parameter and target platform. If you set `package`, the `distribution` parameter does nothing.
Valid option: String. Default: undef.
##### `version` ##### `version`
Sets the version of Java to install, if you want to ensure a particular version.
Sets the version of Java to install, if you want to ensure a particular version.
Valid options: 'present', 'installed', 'latest', or a string matching `/^[.+_0-9a-zA-Z:-]+$/`. Default: 'present'. Valid options: 'present', 'installed', 'latest', or a string matching `/^[.+_0-9a-zA-Z:-]+$/`. Default: 'present'.
#### Public defined types #### Public defined types
@@ -119,26 +126,41 @@ The following parameters are available in `java::oracle`:
Version of Java Standard Edition (SE) to install. 6, 7 or 8. Version of Java Standard Edition (SE) to install. 6, 7 or 8.
##### `version_major` ##### `version_major`
Major version of the Java Standard Edition (SE) to install. Must be used together with `version_minor`. For example, '8u101'. Major version of the Java Standard Edition (SE) to install. Must be used together with `version_minor`. For example, '8u101'.
##### `version_minor` ##### `version_minor`
Minor version (or build version) of the Java Standard Edition (SE) to install. Must be used together with `version_major`. For example, 'b13'. Minor version (or build version) of the Java Standard Edition (SE) to install. Must be used together with `version_major`. For example, 'b13'.
##### `java_se` ##### `java_se`
Type of Java SE to install, jdk or jre. Type of Java SE to install, jdk or jre.
##### `ensure` ##### `ensure`
Install or remove the package. Install or remove the package.
##### `oracle_url` ##### `oracle_url`
Official Oracle URL to download the binaries from. Official Oracle URL to download the binaries from.
##### `proxy_server` ##### `proxy_server`
Specify a proxy server, with port number if needed. ie: https://example.com:8080. (passed to archive) Specify a proxy server, with port number if needed. ie: https://example.com:8080. (passed to archive)
##### `proxy_type` ##### `proxy_type`
Proxy server type (none|http|https|ftp). (passed to archive) Proxy server type (none|http|https|ftp). (passed to archive)
##### `url`
Pass an entire URL to download the installer from rather than building the complete URL from other parameters. This will allow the module to be used even if the URLs are changed by Oracle. If this parameter is used, matching `version_major` and `version_minor` parameters must also be passed to the class.
##### `url_hash`
Directory hash used by the download.oracle.com site. This value is a 32 character string which is part of the file URL returned by the JDK download site.
### Facts ### Facts
The java module includes a few facts to describe the version of Java installed on the system: The java module includes a few facts to describe the version of Java installed on the system:
@@ -153,7 +175,7 @@ The java module includes a few facts to describe the version of Java installed o
## Limitations ## Limitations
This module cannot guarantee installation of Java versions that are not available on platform repositories. This module cannot guarantee installation of Java versions that are not available on platform repositories.
This module only manages a singular installation of Java, meaning it is not possible to manage e.g. OpenJDK 7, Oracle Java 7 and Oracle Java 8 in parallel on the same system. This module only manages a singular installation of Java, meaning it is not possible to manage e.g. OpenJDK 7, Oracle Java 7 and Oracle Java 8 in parallel on the same system.
@@ -161,7 +183,7 @@ Oracle Java packages are not included in Debian 7 and Ubuntu 12.04/14.04 reposit
This module is officially [supported](https://forge.puppetlabs.com/supported) for the following Java versions and platforms: This module is officially [supported](https://forge.puppetlabs.com/supported) for the following Java versions and platforms:
OpenJDK is supported on: OpenJDK is supported on:
* Red Hat Enterprise Linux (RHEL) 5, 6, 7 * Red Hat Enterprise Linux (RHEL) 5, 6, 7
* CentOS 5, 6, 7 * CentOS 5, 6, 7
@@ -173,15 +195,18 @@ OpenJDK is supported on:
* SLES 11 SP1, SP2, SP3, SP4; SLES 12, SP1, SP2 * SLES 11 SP1, SP2, SP3, SP4; SLES 12, SP1, SP2
* OpenBSD 5.6, 5.7 * OpenBSD 5.6, 5.7
Sun Java is supported on: Sun Java is supported on:
* Debian 6 * Debian 6
Oracle Java is supported on: Oracle Java is supported on:
* CentOS 6 * CentOS 6
### Known issues ### Known issues
Where Oracle change the format of the URLs to different installer packages, the curl to fetch the package may fail with a HTTP/404 error. In this case, passing a full known good URL using the `url` parameter will allow the module to still be able to install specific versions of the JRE/JDK. Note the `version_major` and `version_minor` parameters must be passed and must match the version downloaded using the known URL in the `url` parameter.
#### OpenBSD #### OpenBSD
OpenBSD packages install Java JRE/JDK in a unique directory structure, not linking OpenBSD packages install Java JRE/JDK in a unique directory structure, not linking

View File

@@ -15,7 +15,9 @@ Facter.add(:java_default_home) do
setcode do setcode do
if Facter::Util::Resolution.which('readlink') if Facter::Util::Resolution.which('readlink')
java_bin = Facter::Util::Resolution.exec('readlink -e /usr/bin/java').strip java_bin = Facter::Util::Resolution.exec('readlink -e /usr/bin/java').strip
if java_bin =~ %r(/jre/) if java_bin.empty?
nil
elsif java_bin =~ %r(/jre/)
java_default_home = File.dirname(File.dirname(File.dirname(java_bin))) java_default_home = File.dirname(File.dirname(File.dirname(java_bin)))
else else
java_default_home = File.dirname(File.dirname(java_bin)) java_default_home = File.dirname(File.dirname(java_bin))

View File

@@ -46,22 +46,16 @@
# Sample Usage: # Sample Usage:
# #
class java( class java(
$distribution = 'jdk', String $distribution = 'jdk',
$version = 'present', Pattern[/present|installed|latest|^[.+_0-9a-zA-Z:~-]+$/] $version = 'present',
$package = undef, Optional[String] $package = undef,
$package_options = undef, Optional[Array] $package_options = undef,
$java_alternative = undef, Optional[String] $java_alternative = undef,
$java_alternative_path = undef, Optional[String] $java_alternative_path = undef,
$java_home = undef Optional[String] $java_home = undef
) { ) {
include java::params 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) { if has_key($java::params::java, $distribution) {
$default_package_name = $java::params::java[$distribution]['package'] $default_package_name = $java::params::java[$distribution]['package']
$default_alternative = $java::params::java[$distribution]['alternative'] $default_alternative = $java::params::java[$distribution]['alternative']

View File

@@ -10,7 +10,7 @@
# the licensing terms. # the licensing terms.
# wget --no-cookies --no-check-certificate --header \ # wget --no-cookies --no-check-certificate --header \
# "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" \ # "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" \
# "http://download.oracle.com/otn-pub/java/jdk/8u25-b17/jre-8u25-linux-x64.tar.gz" # "http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz"
# #
# Parameters # Parameters
# [*version*] # [*version*]
@@ -80,7 +80,12 @@
# #
# [*url*] # [*url*]
# Full URL, including oracle_url, release_major, release_minor and package_name, to # Full URL, including oracle_url, release_major, release_minor and package_name, to
# download the Oracle java_se installer. # download the Oracle java_se installer. Originally present but not used, activated
# to workaround MODULES-5058
#
# [*url_hash*]
# Directory hash used by the download.oracle.com site. This value is a 32 character string
# which is part of the file URL returned by the JDK download site.
# #
# ### Author # ### Author
# mike@marseglia.org # mike@marseglia.org
@@ -94,6 +99,8 @@ define java::oracle (
$oracle_url = 'http://download.oracle.com/otn-pub/java/jdk/', $oracle_url = 'http://download.oracle.com/otn-pub/java/jdk/',
$proxy_server = undef, $proxy_server = undef,
$proxy_type = undef, $proxy_type = undef,
$url = undef,
$url_hash = undef,
) { ) {
# archive module is used to download the java package # archive module is used to download the java package
@@ -108,8 +115,11 @@ define java::oracle (
# determine Oracle Java major and minor version, and installation path # determine Oracle Java major and minor version, and installation path
if $version_major and $version_minor { if $version_major and $version_minor {
$release_major = $version_major $release_major = $version_major
$release_minor = $version_minor $release_minor = $version_minor
$release_hash = $url_hash
if $release_major =~ /(\d+)u(\d+)/ { if $release_major =~ /(\d+)u(\d+)/ {
$install_path = "${java_se}1.${1}.0_${2}" $install_path = "${java_se}1.${1}.0_${2}"
} else { } else {
@@ -122,21 +132,25 @@ define java::oracle (
$release_major = '6u45' $release_major = '6u45'
$release_minor = 'b06' $release_minor = 'b06'
$install_path = "${java_se}1.6.0_45" $install_path = "${java_se}1.6.0_45"
$release_hash = undef
} }
'7' : { '7' : {
$release_major = '7u80' $release_major = '7u80'
$release_minor = 'b15' $release_minor = 'b15'
$install_path = "${java_se}1.7.0_80" $install_path = "${java_se}1.7.0_80"
$release_hash = undef
} }
'8' : { '8' : {
$release_major = '8u51' $release_major = '8u131'
$release_minor = 'b16' $release_minor = 'b11'
$install_path = "${java_se}1.8.0_51" $install_path = "${java_se}1.8.0_131"
$release_hash = 'd54c1d3a095b4ff2b6607d096fa80163'
} }
default : { default : {
$release_major = '8u51' $release_major = '8u131'
$release_minor = 'b16' $release_minor = 'b11'
$install_path = "${java_se}1.8.0_51" $install_path = "${java_se}1.8.0_131"
$release_hash = 'd54c1d3a095b4ff2b6607d096fa80163'
} }
} }
} }
@@ -175,11 +189,11 @@ define java::oracle (
} }
# following are based on this example: # following are based on this example:
# http://download.oracle.com/otn/java/jdk/7u80-b15/jre-7u80-linux-i586.rpm # http://download.oracle.com/otn-pub/java/jdk/7u80-b15/jre-7u80-linux-i586.rpm
# #
# JaveSE 6 distributed in .bin format # JaveSE 6 distributed in .bin format
# http://download.oracle.com/otn/java/jdk/6u45-b06/jdk-6u45-linux-i586-rpm.bin # http://download.oracle.com/otn-pub/java/jdk/6u45-b06/jdk-6u45-linux-i586-rpm.bin
# http://download.oracle.com/otn/java/jdk/6u45-b06/jdk-6u45-linux-i586.bin # http://download.oracle.com/otn-pub/java/jdk/6u45-b06/jdk-6u45-linux-i586.bin
# package name to download from Oracle's website # package name to download from Oracle's website
case $package_type { case $package_type {
'bin' : { 'bin' : {
@@ -196,6 +210,15 @@ define java::oracle (
} }
} }
# if complete URL is provided, use this value for source in archive resource
if $url {
$source = $url
} elsif $release_hash != undef {
$source = "${oracle_url}/${release_major}-${release_minor}/${release_hash}/${package_name}"
} else {
$source = "${oracle_url}/${release_major}-${release_minor}/${package_name}"
}
# full path to the installer # full path to the installer
$destination = "${destination_dir}${package_name}" $destination = "${destination_dir}${package_name}"
notice ("Destination is ${destination}") notice ("Destination is ${destination}")
@@ -219,7 +242,7 @@ define java::oracle (
'present' : { 'present' : {
archive { $destination : archive { $destination :
ensure => present, ensure => present,
source => "${oracle_url}${release_major}-${release_minor}/${package_name}", source => $source,
cookie => 'gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie', cookie => 'gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie',
extract_path => '/tmp', extract_path => '/tmp',
cleanup => false, cleanup => false,
@@ -233,7 +256,7 @@ define java::oracle (
path => '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin', path => '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin',
command => $install_command, command => $install_command,
creates => $creates_path, creates => $creates_path,
require => Archive[$destination] require => Archive[$destination],
} }
} }
default : { default : {

View File

@@ -21,20 +21,22 @@ class java::params {
$jre_package = 'java-1.6.0-sun' $jre_package = 'java-1.6.0-sun'
$java_home = '/usr/lib/jvm/java-1.6.0-sun/jre/' $java_home = '/usr/lib/jvm/java-1.6.0-sun/jre/'
} }
# See cde7046 for why >= 5.0 < 6.3
elsif (versioncmp($::operatingsystemrelease, '6.3') < 0) { elsif (versioncmp($::operatingsystemrelease, '6.3') < 0) {
$jdk_package = 'java-1.6.0-openjdk-devel' $jdk_package = 'java-1.6.0-openjdk-devel'
$jre_package = 'java-1.6.0-openjdk' $jre_package = 'java-1.6.0-openjdk'
$java_home = "/usr/lib/jvm/java-1.6.0-openjdk-${::architecture}/" $java_home = '/usr/lib/jvm/java-1.6.0/'
} }
# See PR#160 / c8e46b5 for why >= 6.3 < 7.1
elsif (versioncmp($::operatingsystemrelease, '7.1') < 0) { elsif (versioncmp($::operatingsystemrelease, '7.1') < 0) {
$jdk_package = 'java-1.7.0-openjdk-devel' $jdk_package = 'java-1.7.0-openjdk-devel'
$jre_package = 'java-1.7.0-openjdk' $jre_package = 'java-1.7.0-openjdk'
$java_home = "/usr/lib/jvm/java-1.7.0-openjdk-${::architecture}/" $java_home = '/usr/lib/jvm/java-1.7.0/'
} }
else { else {
$jdk_package = 'java-1.8.0-openjdk-devel' $jdk_package = 'java-1.8.0-openjdk-devel'
$jre_package = 'java-1.8.0-openjdk' $jre_package = 'java-1.8.0-openjdk'
$java_home = "/usr/lib/jvm/java-1.8.0-openjdk-${::architecture}/" $java_home = '/usr/lib/jvm/java-1.8.0/'
} }
} }
'Fedora': { 'Fedora': {

View File

@@ -1,6 +1,6 @@
{ {
"name": "puppetlabs-java", "name": "puppetlabs-java",
"version": "2.0.0", "version": "2.1.0",
"author": "puppetlabs", "author": "puppetlabs",
"summary": "Installs the correct Java package on various platforms.", "summary": "Installs the correct Java package on various platforms.",
"license": "Apache-2.0", "license": "Apache-2.0",
@@ -89,7 +89,13 @@
} }
], ],
"dependencies": [ "dependencies": [
{"name":"puppetlabs/stdlib","version_requirement":">= 2.4.0 < 5.0.0"}, {
{"name":"puppet/archive","version_requirement":">= 1.1.0 < 2.0.0"} "name":"puppetlabs/stdlib",
"version_requirement": ">= 4.13.1 < 5.0.0"
},
{
"name":"puppet/archive",
"version_requirement": ">= 1.1.0 < 2.0.0"
}
] ]
} }

View File

@@ -5,19 +5,19 @@ describe 'java', :type => :class do
context 'select openjdk for Centos 5.8' do context 'select openjdk for Centos 5.8' do
let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Centos', :operatingsystemrelease => '5.8', :architecture => 'x86_64'} } let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Centos', :operatingsystemrelease => '5.8', :architecture => 'x86_64'} }
it { is_expected.to contain_package('java').with_name('java-1.6.0-openjdk-devel') } it { is_expected.to contain_package('java').with_name('java-1.6.0-openjdk-devel') }
it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk-x86_64/') } it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.6.0/') }
end end
context 'select openjdk for Centos 6.3' do context 'select openjdk for Centos 6.3' do
let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Centos', :operatingsystemrelease => '6.3', :architecture => 'x86_64'} } let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Centos', :operatingsystemrelease => '6.3', :architecture => 'x86_64'} }
it { is_expected.to contain_package('java').with_name('java-1.7.0-openjdk-devel') } it { is_expected.to contain_package('java').with_name('java-1.7.0-openjdk-devel') }
it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-x86_64/') } it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.7.0/') }
end end
context 'select openjdk for Centos 7.1.1503' do context 'select openjdk for Centos 7.1.1503' do
let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Centos', :operatingsystemrelease => '7.1.1503', :architecture => 'x86_64'} } let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Centos', :operatingsystemrelease => '7.1.1503', :architecture => 'x86_64'} }
it { is_expected.to contain_package('java').with_name('java-1.8.0-openjdk-devel') } it { is_expected.to contain_package('java').with_name('java-1.8.0-openjdk-devel') }
it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-x86_64/') } it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.8.0/') }
end end
context 'select openjdk for Centos 6.2' do context 'select openjdk for Centos 6.2' do
@@ -193,14 +193,14 @@ describe 'java', :type => :class do
let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Scientific', :operatingsystemrelease => '6.4', :architecture => 'x86_64'} } let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Scientific', :operatingsystemrelease => '6.4', :architecture => 'x86_64'} }
let(:params) { { 'distribution' => 'jre' } } let(:params) { { 'distribution' => 'jre' } }
it { is_expected.to contain_package('java').with_name('java-1.7.0-openjdk') } it { is_expected.to contain_package('java').with_name('java-1.7.0-openjdk') }
it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-x86_64/') } it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.7.0/') }
end end
context 'select passed value for Scientific Linux CERN (SLC)' do context 'select passed value for Scientific Linux CERN (SLC)' do
let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'SLC', :operatingsystemrelease => '6.4', :architecture => 'x86_64'} } let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'SLC', :operatingsystemrelease => '6.4', :architecture => 'x86_64'} }
let(:params) { { 'distribution' => 'jre' } } let(:params) { { 'distribution' => 'jre' } }
it { is_expected.to contain_package('java').with_name('java-1.7.0-openjdk') } it { is_expected.to contain_package('java').with_name('java-1.7.0-openjdk') }
it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-x86_64/') } it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.7.0/') }
end end
context 'select default for OpenSUSE 12.3' do context 'select default for OpenSUSE 12.3' do

View File

@@ -23,9 +23,9 @@ describe 'java::oracle', :type => :define do
context 'Oracle Java SE 8 JDK' do context 'Oracle Java SE 8 JDK' do
let(:params) { {:ensure => 'present', :version => '8', :java_se => 'jdk'} } let(:params) { {:ensure => 'present', :version => '8', :java_se => 'jdk'} }
let :title do 'jdk8' end let :title do 'jdk8' end
it { is_expected.to contain_archive('/tmp/jdk-8u51-linux-x64.rpm')} it { is_expected.to contain_archive('/tmp/jdk-8u131-linux-x64.rpm')}
it { is_expected.to contain_exec('Install Oracle java_se jdk 8').with_command('rpm --force -iv /tmp/jdk-8u51-linux-x64.rpm') } it { is_expected.to contain_exec('Install Oracle java_se jdk 8').with_command('rpm --force -iv /tmp/jdk-8u131-linux-x64.rpm') }
it { is_expected.to contain_exec('Install Oracle java_se jdk 8').that_requires('Archive[/tmp/jdk-8u51-linux-x64.rpm]') } it { is_expected.to contain_exec('Install Oracle java_se jdk 8').that_requires('Archive[/tmp/jdk-8u131-linux-x64.rpm]') }
end end
context 'Oracle Java SE 6 JRE' do context 'Oracle Java SE 6 JRE' do
@@ -47,11 +47,16 @@ describe 'java::oracle', :type => :define do
context 'select Oracle Java SE 8 JRE' do context 'select Oracle Java SE 8 JRE' do
let(:params) { {:ensure => 'present', :version => '8', :java_se => 'jre'} } let(:params) { {:ensure => 'present', :version => '8', :java_se => 'jre'} }
let :title do 'jre8' end let :title do 'jre8' end
it { is_expected.to contain_archive('/tmp/jre-8u51-linux-x64.rpm')} it { is_expected.to contain_archive('/tmp/jre-8u131-linux-x64.rpm')}
it { is_expected.to contain_exec('Install Oracle java_se jre 8').with_command('rpm --force -iv /tmp/jre-8u51-linux-x64.rpm') } it { is_expected.to contain_exec('Install Oracle java_se jre 8').with_command('rpm --force -iv /tmp/jre-8u131-linux-x64.rpm') }
it { is_expected.to contain_exec('Install Oracle java_se jre 8').that_requires('Archive[/tmp/jre-8u51-linux-x64.rpm]') } it { is_expected.to contain_exec('Install Oracle java_se jre 8').that_requires('Archive[/tmp/jre-8u131-linux-x64.rpm]') }
end end
context 'Pass URL to url parameter' do
let(:params) { {:ensure => 'present', :version_major => '8u131', :version_minor => 'b11', :java_se => 'jdk', :url => 'http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.rpm'} }
let :title do 'jdk8' end
it { is_expected.to contain_archive('/tmp/jdk-8u131-linux-x64.rpm')}
end
end end
context 'On CentOS 32-bit' do context 'On CentOS 32-bit' do
@@ -76,9 +81,9 @@ describe 'java::oracle', :type => :define do
context 'select Oracle Java SE 8 JDK on RedHat family, 32-bit' do context 'select Oracle Java SE 8 JDK on RedHat family, 32-bit' do
let(:params) { {:ensure => 'present', :version => '8', :java_se => 'jdk'} } let(:params) { {:ensure => 'present', :version => '8', :java_se => 'jdk'} }
let :title do 'jdk8' end let :title do 'jdk8' end
it { is_expected.to contain_archive('/tmp/jdk-8u51-linux-i586.rpm')} it { is_expected.to contain_archive('/tmp/jdk-8u131-linux-i586.rpm')}
it { is_expected.to contain_exec('Install Oracle java_se jdk 8').with_command('rpm --force -iv /tmp/jdk-8u51-linux-i586.rpm') } it { is_expected.to contain_exec('Install Oracle java_se jdk 8').with_command('rpm --force -iv /tmp/jdk-8u131-linux-i586.rpm') }
it { is_expected.to contain_exec('Install Oracle java_se jdk 8').that_requires('Archive[/tmp/jdk-8u51-linux-i586.rpm]') } it { is_expected.to contain_exec('Install Oracle java_se jdk 8').that_requires('Archive[/tmp/jdk-8u131-linux-i586.rpm]') }
end end
context 'select Oracle Java SE 6 JRE on RedHat family, 32-bit' do context 'select Oracle Java SE 6 JRE on RedHat family, 32-bit' do
@@ -100,9 +105,9 @@ describe 'java::oracle', :type => :define do
context 'select Oracle Java SE 8 JRE on RedHat family, 32-bit' do context 'select Oracle Java SE 8 JRE on RedHat family, 32-bit' do
let(:params) { {:ensure => 'present', :version => '8', :java_se => 'jre'} } let(:params) { {:ensure => 'present', :version => '8', :java_se => 'jre'} }
let :title do 'jdk8' end let :title do 'jdk8' end
it { is_expected.to contain_archive('/tmp/jre-8u51-linux-i586.rpm')} it { is_expected.to contain_archive('/tmp/jre-8u131-linux-i586.rpm')}
it { is_expected.to contain_exec('Install Oracle java_se jre 8').with_command('rpm --force -iv /tmp/jre-8u51-linux-i586.rpm') } it { is_expected.to contain_exec('Install Oracle java_se jre 8').with_command('rpm --force -iv /tmp/jre-8u131-linux-i586.rpm') }
it { is_expected.to contain_exec('Install Oracle java_se jre 8').that_requires('Archive[/tmp/jre-8u51-linux-i586.rpm]') } it { is_expected.to contain_exec('Install Oracle java_se jre 8').that_requires('Archive[/tmp/jre-8u131-linux-i586.rpm]') }
end end
end end

View File

@@ -29,6 +29,14 @@ describe Facter::Util::Fact do
end end
end end
end end
context 'returns nil when readlink is present but java is not' do
it do
java_path_output = ""
Facter::Util::Resolution.expects(:which).with("readlink").returns(true)
Facter::Util::Resolution.expects(:exec).with("readlink -e /usr/bin/java").returns(java_path_output)
expect(Facter.value(:java_default_home)).to be_nil
end
end
context 'returns nil when readlink not present' do context 'returns nil when readlink not present' do
it do it do