From 20960ddb7f8761c63ef83aaf29482886ba77fe4f Mon Sep 17 00:00:00 2001 From: Jan Vansteenkiste Date: Wed, 1 Feb 2017 08:10:15 +0100 Subject: [PATCH 01/13] MODULES-4368: Add a test case for the issue --- spec/unit/facter/java_default_home_spec.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spec/unit/facter/java_default_home_spec.rb b/spec/unit/facter/java_default_home_spec.rb index b7b7bbe..41be89e 100644 --- a/spec/unit/facter/java_default_home_spec.rb +++ b/spec/unit/facter/java_default_home_spec.rb @@ -29,6 +29,14 @@ describe Facter::Util::Fact do 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 it do From c0227ce82030d3f40069e9182a527051e4dc3f12 Mon Sep 17 00:00:00 2001 From: Jan Vansteenkiste Date: Wed, 1 Feb 2017 08:10:59 +0100 Subject: [PATCH 02/13] MODULES-4368: return nil if java_bin is not found (readlink result is empty) --- lib/facter/java_default_home.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/facter/java_default_home.rb b/lib/facter/java_default_home.rb index 9a70934..330f037 100644 --- a/lib/facter/java_default_home.rb +++ b/lib/facter/java_default_home.rb @@ -15,7 +15,9 @@ Facter.add(:java_default_home) do setcode do if Facter::Util::Resolution.which('readlink') 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))) else java_default_home = File.dirname(File.dirname(java_bin)) From 75939fffc9f408c661b56a87c66f72945da07bba Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Thu, 30 Mar 2017 11:22:14 +0200 Subject: [PATCH 03/13] fix headlines in markdown --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 836e363..8598368 100644 --- a/README.markdown +++ b/README.markdown @@ -1,6 +1,6 @@ # java -#### Table of Contents +## Table of Contents 1. [Overview](#overview) 2. [Module Description - What the module does and why it is useful](#module-description) From 920748cf0a1e16dab66a7ff228a2eda148ed2d1c Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Thu, 30 Mar 2017 11:23:26 +0200 Subject: [PATCH 04/13] purge trailing whitespace --- README.markdown | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/README.markdown b/README.markdown index 8598368..4937a22 100644 --- a/README.markdown +++ b/README.markdown @@ -13,7 +13,7 @@ ## Overview -Installs the correct Java package on various platforms. +Installs the correct Java package on various platforms. ## Module Description @@ -34,7 +34,7 @@ class { 'java': } ~~~ -To install the latest patch version of Java 8 on CentOS +To install the latest patch version of Java 8 on CentOS ~~~ class { 'java' : @@ -88,23 +88,23 @@ java::oracle { 'jdk8' : The following parameters are available in `java`: ##### `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'. ##### `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. -##### `java_alternative_path` -*Required when `java_alternative` is specified.* Defines the path to the `java` command. +##### `java_alternative_path` +*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. ##### `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` -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'. #### Public defined types @@ -153,7 +153,7 @@ The java module includes a few facts to describe the version of Java installed o ## 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. @@ -161,7 +161,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: -OpenJDK is supported on: +OpenJDK is supported on: * Red Hat Enterprise Linux (RHEL) 5, 6, 7 * CentOS 5, 6, 7 @@ -173,7 +173,7 @@ OpenJDK is supported on: * SLES 11 SP1, SP2, SP3, SP4; SLES 12, SP1, SP2 * OpenBSD 5.6, 5.7 -Sun Java is supported on: +Sun Java is supported on: * Debian 6 From 4f7d760f106d209580756e12b6fe90bd24d3dda5 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Thu, 30 Mar 2017 11:25:23 +0200 Subject: [PATCH 05/13] use proper syntax highlighting in markdown --- README.markdown | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.markdown b/README.markdown index 4937a22..6a7f7e7 100644 --- a/README.markdown +++ b/README.markdown @@ -28,23 +28,23 @@ To install the correct Java package on your system, include the `java` class: `i 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': distribution => 'jre', } -~~~ +``` To install the latest patch version of Java 8 on CentOS -~~~ +```puppet class { 'java' : 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. -~~~ +```puppet java::oracle { 'jdk6' : ensure => 'present', version => '6', @@ -56,18 +56,18 @@ java::oracle { 'jdk8' : version => '8', 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: -~~~ +```puppet java::oracle { 'jdk8' : ensure => 'present', version_major => '8u101', version_minor => 'b13', java_se => 'jdk', } -~~~ +``` ## Reference From 585bd5795e15fd8991b66506ee85c1360b9217bd Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Thu, 30 Mar 2017 11:26:32 +0200 Subject: [PATCH 06/13] bump stdlib to recommended puppet4 version --- metadata.json | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/metadata.json b/metadata.json index eeb2b4a..0ece972 100644 --- a/metadata.json +++ b/metadata.json @@ -89,7 +89,13 @@ } ], "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" + } ] } From 66662bf4e9e84d952fb9ae26620a96f82b662471 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Thu, 30 Mar 2017 11:28:59 +0200 Subject: [PATCH 07/13] replace validate_* calls with datatypes --- manifests/init.pp | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 2a8efd6..0c97e4a 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -46,22 +46,16 @@ # Sample Usage: # class java( - $distribution = 'jdk', - $version = 'present', - $package = undef, - $package_options = undef, - $java_alternative = undef, - $java_alternative_path = undef, - $java_home = undef + String $distribution = 'jdk', + Pattern[/present|installed|latest|^[.+_0-9a-zA-Z:~-]+$/] $version = 'present', + $package = undef, + Optional[Array] $package_options = undef, + $java_alternative = undef, + $java_alternative_path = undef, + $java_home = 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'] From 3dacc7abe530aac51dcb6f1520891a2116f35807 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Wed, 7 Jun 2017 19:58:50 +0200 Subject: [PATCH 08/13] fix markdown linter warnings --- README.markdown | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 6a7f7e7..f866e7e 100644 --- a/README.markdown +++ b/README.markdown @@ -1,6 +1,6 @@ # java -## Table of Contents +#### Table of Contents 1. [Overview](#overview) 2. [Module Description - What the module does and why it is useful](#module-description) @@ -22,6 +22,7 @@ The java module can automatically install Java jdk or jre on a wide variety of s ## Setup ### Beginning with the java module + To install the correct Java package on your system, include the `java` class: `include java`. ## Usage @@ -85,25 +86,31 @@ java::oracle { 'jdk8' : #### Parameters + The following parameters are available in `java`: ##### `distribution` + 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'. ##### `java_alternative` + 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. ##### `java_alternative_path` + *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. ##### `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. ##### `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'. @@ -119,24 +126,31 @@ The following parameters are available in `java::oracle`: Version of Java Standard Edition (SE) to install. 6, 7 or 8. ##### `version_major` + Major version of the Java Standard Edition (SE) to install. Must be used together with `version_minor`. For example, '8u101'. ##### `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'. ##### `java_se` + Type of Java SE to install, jdk or jre. ##### `ensure` + Install or remove the package. ##### `oracle_url` + Official Oracle URL to download the binaries from. ##### `proxy_server` + Specify a proxy server, with port number if needed. ie: https://example.com:8080. (passed to archive) ##### `proxy_type` + Proxy server type (none|http|https|ftp). (passed to archive) ### Facts @@ -178,6 +192,7 @@ Sun Java is supported on: * Debian 6 Oracle Java is supported on: + * CentOS 6 ### Known issues From cf1411664164da2263db95a1af65a91ba5319054 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Wed, 7 Jun 2017 23:28:06 +0200 Subject: [PATCH 09/13] add datatypes for all parameters --- manifests/init.pp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 0c97e4a..2a9a7d9 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -48,11 +48,11 @@ class java( String $distribution = 'jdk', Pattern[/present|installed|latest|^[.+_0-9a-zA-Z:~-]+$/] $version = 'present', - $package = undef, + Optional[String] $package = undef, Optional[Array] $package_options = undef, - $java_alternative = undef, - $java_alternative_path = undef, - $java_home = undef + Optional[String] $java_alternative = undef, + Optional[String] $java_alternative_path = undef, + Optional[String] $java_home = undef ) { include java::params From 05b9d1c2baaf30ef4e5db55f9fb7f40457b9a580 Mon Sep 17 00:00:00 2001 From: Stefan Pijnappels Date: Thu, 8 Jun 2017 10:29:58 +0100 Subject: [PATCH 10/13] MODULES-5058 Allow a complete URL to be passed to the java::oracle class This provides a workaround to the issue of Oracle changing it's URL structure which breaks the dynamic URL building in the module. It allows a complete URL to be passed as an alternative to one built by the logic in the module, and allows the rest of the module to function as expected when this situation is encountered. Changes made to manifests/oracle.pp to pass URL in `url` parameter (if defined) to the `source` directive of the archive resource which fetches the installer package. README.markdown has been updated to document the additional parameter, as well as a note added to known issues describing it's operation. A test has been added to spec/defines/oracle_spec.rb to verify the correct package is present in the tmp archive location. The spec tests have passed and the revised workflow has been tested in a lab environment and found to be working. --- README.markdown | 6 ++++++ manifests/oracle.pp | 13 +++++++++++-- spec/defines/oracle_spec.rb | 5 +++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index f866e7e..a100818 100644 --- a/README.markdown +++ b/README.markdown @@ -153,6 +153,10 @@ Specify a proxy server, with port number if needed. ie: https://example.com:8080 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. + ### Facts The java module includes a few facts to describe the version of Java installed on the system: @@ -197,6 +201,8 @@ Oracle Java is supported on: ### 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 packages install Java JRE/JDK in a unique directory structure, not linking diff --git a/manifests/oracle.pp b/manifests/oracle.pp index af9e5f3..76dd102 100644 --- a/manifests/oracle.pp +++ b/manifests/oracle.pp @@ -80,7 +80,8 @@ # # [*url*] # 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 # # ### Author # mike@marseglia.org @@ -94,6 +95,7 @@ define java::oracle ( $oracle_url = 'http://download.oracle.com/otn-pub/java/jdk/', $proxy_server = undef, $proxy_type = undef, + $url = undef, ) { # archive module is used to download the java package @@ -196,6 +198,13 @@ define java::oracle ( } } + # if complete URL is provided, use this value for source in archive resource + if $url { + $source = $url + } else { + $source = "${oracle_url}${release_major}-${release_minor}/${package_name}" + } + # full path to the installer $destination = "${destination_dir}${package_name}" notice ("Destination is ${destination}") @@ -219,7 +228,7 @@ define java::oracle ( 'present' : { archive { $destination : 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', extract_path => '/tmp', cleanup => false, diff --git a/spec/defines/oracle_spec.rb b/spec/defines/oracle_spec.rb index f2f4da3..1e0fb12 100644 --- a/spec/defines/oracle_spec.rb +++ b/spec/defines/oracle_spec.rb @@ -52,6 +52,11 @@ describe 'java::oracle', :type => :define do it { is_expected.to contain_exec('Install Oracle java_se jre 8').that_requires('Archive[/tmp/jre-8u51-linux-x64.rpm]') } 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 context 'On CentOS 32-bit' do From e234375924a68f32bbb58e4a7994c567b7921f06 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Fri, 9 Jun 2017 11:43:03 -0700 Subject: [PATCH 11/13] (maint) Update java_home for redhat systems It appears that redhat 7 and variants no longer have java-1.7.0-openjdk-$arch symlinks. All redhat 6/7's both 32 and 64 bit seem to include a java-1.7.0 symlink though. --- manifests/params.pp | 8 +++++--- spec/classes/java_spec.rb | 10 +++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/manifests/params.pp b/manifests/params.pp index 9e7a30d..6aa558a 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -21,20 +21,22 @@ class java::params { $jre_package = 'java-1.6.0-sun' $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) { $jdk_package = 'java-1.6.0-openjdk-devel' $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) { $jdk_package = 'java-1.7.0-openjdk-devel' $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 { $jdk_package = 'java-1.8.0-openjdk-devel' $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': { diff --git a/spec/classes/java_spec.rb b/spec/classes/java_spec.rb index a4d2e7b..ff56262 100644 --- a/spec/classes/java_spec.rb +++ b/spec/classes/java_spec.rb @@ -5,19 +5,19 @@ describe 'java', :type => :class do context 'select openjdk for Centos 5.8' do 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_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 context 'select openjdk for Centos 6.3' do 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_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 context 'select openjdk for Centos 7.1.1503' do 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_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 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(:params) { { 'distribution' => 'jre' } } 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 context 'select passed value for Scientific Linux CERN (SLC)' do let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'SLC', :operatingsystemrelease => '6.4', :architecture => 'x86_64'} } let(:params) { { 'distribution' => 'jre' } } 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 context 'select default for OpenSUSE 12.3' do From 08423fb17032943511b66d3f1d1e264d560513b2 Mon Sep 17 00:00:00 2001 From: Michael Watters Date: Sun, 22 Jan 2017 22:12:30 -0500 Subject: [PATCH 12/13] MODULES-5047 - Update java::oracle class to work with new download URLs Oracle appears to have changed the JDK URL structure starting with Java 8u121. This update adds a hash to store the values used by Oracle's java download site along with a case statement to lookup the proper key for the java release being installed. --- README.markdown | 4 ++++ manifests/oracle.pp | 40 ++++++++++++++++++++++++++----------- spec/defines/oracle_spec.rb | 24 +++++++++++----------- 3 files changed, 44 insertions(+), 24 deletions(-) diff --git a/README.markdown b/README.markdown index a100818..eec77f6 100644 --- a/README.markdown +++ b/README.markdown @@ -157,6 +157,10 @@ Proxy server type (none|http|https|ftp). (passed to archive) 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 The java module includes a few facts to describe the version of Java installed on the system: diff --git a/manifests/oracle.pp b/manifests/oracle.pp index 76dd102..e3aa912 100644 --- a/manifests/oracle.pp +++ b/manifests/oracle.pp @@ -10,7 +10,7 @@ # the licensing terms. # wget --no-cookies --no-check-certificate --header \ # "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 # [*version*] @@ -83,6 +83,10 @@ # 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 # mike@marseglia.org # @@ -96,6 +100,7 @@ define java::oracle ( $proxy_server = undef, $proxy_type = undef, $url = undef, + $url_hash = undef, ) { # archive module is used to download the java package @@ -110,8 +115,11 @@ define java::oracle ( # determine Oracle Java major and minor version, and installation path if $version_major and $version_minor { + $release_major = $version_major $release_minor = $version_minor + $release_hash = $url_hash + if $release_major =~ /(\d+)u(\d+)/ { $install_path = "${java_se}1.${1}.0_${2}" } else { @@ -124,21 +132,25 @@ define java::oracle ( $release_major = '6u45' $release_minor = 'b06' $install_path = "${java_se}1.6.0_45" + $release_hash = undef } '7' : { $release_major = '7u80' $release_minor = 'b15' $install_path = "${java_se}1.7.0_80" + $release_hash = undef } '8' : { - $release_major = '8u51' - $release_minor = 'b16' - $install_path = "${java_se}1.8.0_51" + $release_major = '8u131' + $release_minor = 'b11' + $install_path = "${java_se}1.8.0_131" + $release_hash = 'd54c1d3a095b4ff2b6607d096fa80163' } default : { - $release_major = '8u51' - $release_minor = 'b16' - $install_path = "${java_se}1.8.0_51" + $release_major = '8u131' + $release_minor = 'b11' + $install_path = "${java_se}1.8.0_131" + $release_hash = 'd54c1d3a095b4ff2b6607d096fa80163' } } } @@ -177,11 +189,11 @@ define java::oracle ( } # 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 - # http://download.oracle.com/otn/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-rpm.bin + # http://download.oracle.com/otn-pub/java/jdk/6u45-b06/jdk-6u45-linux-i586.bin # package name to download from Oracle's website case $package_type { 'bin' : { @@ -201,8 +213,12 @@ define java::oracle ( # if complete URL is provided, use this value for source in archive resource if $url { $source = $url - } else { - $source = "${oracle_url}${release_major}-${release_minor}/${package_name}" + } + 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 diff --git a/spec/defines/oracle_spec.rb b/spec/defines/oracle_spec.rb index 1e0fb12..7115657 100644 --- a/spec/defines/oracle_spec.rb +++ b/spec/defines/oracle_spec.rb @@ -23,9 +23,9 @@ describe 'java::oracle', :type => :define do context 'Oracle Java SE 8 JDK' do let(:params) { {:ensure => 'present', :version => '8', :java_se => 'jdk'} } let :title do 'jdk8' end - it { is_expected.to contain_archive('/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-8u51-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_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-8u131-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 context 'Oracle Java SE 6 JRE' do @@ -47,9 +47,9 @@ describe 'java::oracle', :type => :define do context 'select Oracle Java SE 8 JRE' do let(:params) { {:ensure => 'present', :version => '8', :java_se => 'jre'} } let :title do 'jre8' end - it { is_expected.to contain_archive('/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-8u51-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_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-8u131-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 context 'Pass URL to url parameter' do @@ -81,9 +81,9 @@ describe 'java::oracle', :type => :define do context 'select Oracle Java SE 8 JDK on RedHat family, 32-bit' do let(:params) { {:ensure => 'present', :version => '8', :java_se => 'jdk'} } let :title do 'jdk8' end - it { is_expected.to contain_archive('/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-8u51-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_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-8u131-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 context 'select Oracle Java SE 6 JRE on RedHat family, 32-bit' do @@ -105,9 +105,9 @@ describe 'java::oracle', :type => :define do context 'select Oracle Java SE 8 JRE on RedHat family, 32-bit' do let(:params) { {:ensure => 'present', :version => '8', :java_se => 'jre'} } let :title do 'jdk8' end - it { is_expected.to contain_archive('/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-8u51-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_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-8u131-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 From 2c8b460b98bfb2d1c33fb8a0d0d78dce3857fb04 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Tue, 13 Jun 2017 11:14:20 -0700 Subject: [PATCH 13/13] Release 2.1.0 --- CHANGELOG.md | 14 ++++++++++++++ manifests/oracle.pp | 8 +++----- metadata.json | 2 +- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d3840f..ea08ebd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 ### Summary diff --git a/manifests/oracle.pp b/manifests/oracle.pp index e3aa912..198f105 100644 --- a/manifests/oracle.pp +++ b/manifests/oracle.pp @@ -213,11 +213,9 @@ define java::oracle ( # if complete URL is provided, use this value for source in archive resource if $url { $source = $url - } - elsif $release_hash != undef { + } elsif $release_hash != undef { $source = "${oracle_url}/${release_major}-${release_minor}/${release_hash}/${package_name}" - } - else { + } else { $source = "${oracle_url}/${release_major}-${release_minor}/${package_name}" } @@ -258,7 +256,7 @@ define java::oracle ( path => '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin', command => $install_command, creates => $creates_path, - require => Archive[$destination] + require => Archive[$destination], } } default : { diff --git a/metadata.json b/metadata.json index 0ece972..0e3362c 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppetlabs-java", - "version": "2.0.0", + "version": "2.1.0", "author": "puppetlabs", "summary": "Installs the correct Java package on various platforms.", "license": "Apache-2.0",