From 60c93866b1a6132c2d02ef1b75027fe51a217b5e Mon Sep 17 00:00:00 2001 From: Matthias Baur Date: Mon, 1 Oct 2018 18:07:32 +0200 Subject: [PATCH 01/12] (MODULES-8025) Switch default for Ubuntu 18.04 to 11 This is needed to get the default Java version rollout with Ubuntu 18.04. --- manifests/params.pp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/manifests/params.pp b/manifests/params.pp index e302bcaf..e69a19de 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -155,7 +155,7 @@ }, } } - 'stretch', 'vivid', 'wily', 'xenial', 'yakkety', 'zesty', 'artful', 'bionic': { + 'stretch', 'vivid', 'wily', 'xenial', 'yakkety', 'zesty', 'artful': { $java = { 'jdk' => { 'package' => 'openjdk-8-jdk', @@ -171,6 +171,22 @@ } } } + 'bionic': { + $java = { + 'jdk' => { + 'package' => 'openjdk-11-jdk', + 'alternative' => "java-1.11.0-openjdk-${::architecture}", + 'alternative_path' => "/usr/lib/jvm/java-1.11.0-openjdk-${::architecture}/bin/java", + 'java_home' => "/usr/lib/jvm/java-1.11.0-openjdk-${::architecture}/", + }, + 'jre' => { + 'package' => 'openjdk-11-jre-headless', + 'alternative' => "java-1.11.0-openjdk-${::architecture}", + 'alternative_path' => "/usr/lib/jvm/java-1.11.0-openjdk-${::architecture}/bin/java", + 'java_home' => "/usr/lib/jvm/java-1.11.0-openjdk-${::architecture}/", + } + } + } default: { fail("unsupported release ${::lsbdistcodename}") } } } From dce9420351eb1b48d0bfae1cbcfade665f7da977 Mon Sep 17 00:00:00 2001 From: Dennis Ploeger Date: Mon, 8 Oct 2018 16:45:15 +0200 Subject: [PATCH 02/12] Support for installing JCE. Fixes MODULES-1681 --- manifests/oracle.pp | 130 +++++++++++++++++++++----------- spec/acceptance/install_spec.rb | 92 ++++++++++++++++++++++ spec/defines/oracle_spec.rb | 54 +++++++++++++ 3 files changed, 231 insertions(+), 45 deletions(-) diff --git a/manifests/oracle.pp b/manifests/oracle.pp index 36313b8e..2191419d 100644 --- a/manifests/oracle.pp +++ b/manifests/oracle.pp @@ -87,6 +87,9 @@ # 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. # +# [*jce*] +# Install Oracles Java Cryptographic Extensions into the JRE or JDK +# # ### Author # mike@marseglia.org # @@ -101,6 +104,7 @@ $proxy_type = undef, $url = undef, $url_hash = undef, + $jce = false, ) { # archive module is used to download the java package @@ -111,12 +115,21 @@ fail('Java SE must be either jre or jdk.') } + if $jce { + $jce_download = $version ? { + '8' => 'http://download.oracle.com/otn-pub/java/jce/8/jce_policy-8.zip', + '7' => 'http://download.oracle.com/otn-pub/java/jce/7/UnlimitedJCEPolicyJDK7.zip', + '6' => 'http://download.oracle.com/otn-pub/java/jce_policy/6/jce_policy-6.zip', + default => undef + } + } + # 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 + $release_hash = $url_hash if $release_major =~ /(\d+)u(\d+)/ { # Required for CentOS systems where Java8 update number is >= 171 to ensure @@ -132,38 +145,38 @@ } else { # use default versions if no specific major and minor version parameters are provided case $version { - '6' : { + '6': { $release_major = '6u45' $release_minor = 'b06' $install_path = "${java_se}1.6.0_45" - $release_hash = undef + $release_hash = undef } - '7' : { + '7': { $release_major = '7u80' $release_minor = 'b15' $install_path = "${java_se}1.7.0_80" - $release_hash = undef + $release_hash = undef } - '8' : { + '8': { $release_major = '8u131' $release_minor = 'b11' $install_path = "${java_se}1.8.0_131" - $release_hash = 'd54c1d3a095b4ff2b6607d096fa80163' + $release_hash = 'd54c1d3a095b4ff2b6607d096fa80163' } - default : { + default: { $release_major = '8u131' $release_minor = 'b11' $install_path = "${java_se}1.8.0_131" - $release_hash = 'd54c1d3a095b4ff2b6607d096fa80163' + $release_hash = 'd54c1d3a095b4ff2b6607d096fa80163' } } } # determine package type (exe/tar/rpm), destination directory based on OS case $facts['kernel'] { - 'Linux' : { + 'Linux': { case $facts['os']['family'] { - 'RedHat', 'Amazon' : { + 'RedHat', 'Amazon': { # Oracle Java 6 comes in a special rpmbin format if $version == '6' { $package_type = 'rpmbin' @@ -172,28 +185,33 @@ } $creates_path = "/usr/java/${install_path}" } - 'Debian' : { - $package_type = 'tar.gz' - $creates_path = "/usr/lib/jvm/${install_path}" + 'Debian': { + $package_type = 'tar.gz' + $creates_path = "/usr/lib/jvm/${install_path}" } - default : { - fail ("unsupported platform ${$facts['os']['name']}") } + default: { + fail("unsupported platform ${$facts['os']['name']}") } } $os = 'linux' $destination_dir = '/tmp/' } - default : { - fail ( "unsupported platform ${$facts['kernel']}" ) } + default: { + fail("unsupported platform ${$facts['kernel']}") } + } + + # Install required unzip packages for jce + if $jce { + ensure_resource('package', 'unzip', { 'ensure' => 'present' }) } # set java architecture nomenclature case $facts['os']['architecture'] { - 'i386' : { $arch = 'i586' } - 'x86_64' : { $arch = 'x64' } - 'amd64' : { $arch = 'x64' } - default : { - fail ("unsupported platform ${$facts['os']['architecture']}") + 'i386': { $arch = 'i586' } + 'x86_64': { $arch = 'x64' } + 'amd64': { $arch = 'x64' } + default: { + fail("unsupported platform ${$facts['os']['architecture']}") } } @@ -205,19 +223,19 @@ # 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' : { + 'bin': { $package_name = "${java_se}-${release_major}-${os}-${arch}.bin" } - 'rpmbin' : { + 'rpmbin': { $package_name = "${java_se}-${release_major}-${os}-${arch}-rpm.bin" } - 'rpm' : { + 'rpm': { $package_name = "${java_se}-${release_major}-${os}-${arch}.rpm" } - 'tar.gz' : { + 'tar.gz': { $package_name = "${java_se}-${release_major}-${os}-${arch}.tar.gz" } - default : { + default: { $package_name = "${java_se}-${release_major}-${os}-${arch}.rpm" } } @@ -235,29 +253,29 @@ # full path to the installer $destination = "${destination_dir}${package_name}" - notice ("Destination is ${destination}") + notice("Destination is ${destination}") case $package_type { - 'bin' : { + 'bin': { $install_command = "sh ${destination}" } - 'rpmbin' : { + 'rpmbin': { $install_command = "sh ${destination} -x; rpm --force -iv sun*.rpm; rpm --force -iv ${java_se}*.rpm" } - 'rpm' : { + 'rpm': { $install_command = "rpm --force -iv ${destination}" } - 'tar.gz' : { + 'tar.gz': { $install_command = "tar -zxf ${destination} -C /usr/lib/jvm" } - default : { + default: { $install_command = "rpm -iv ${destination}" } } case $ensure { - 'present' : { - archive { $destination : + 'present': { + archive { $destination: ensure => present, source => $source, cookie => 'gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie', @@ -268,30 +286,52 @@ proxy_type => $proxy_type, } case $facts['kernel'] { - 'Linux' : { - exec { "Install Oracle java_se ${java_se} ${version}" : + 'Linux': { + exec { "Install Oracle java_se ${java_se} ${version}": path => '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin', command => $install_command, creates => $creates_path, require => Archive[$destination] } case $facts['os']['family'] { - 'Debian' : { - file{'/usr/lib/jvm': + 'Debian': { + file { '/usr/lib/jvm': ensure => directory, before => Exec["Install Oracle java_se ${java_se} ${version}"] } } - default : { } + default: {} + } + + if ($jce and $jce_download != undef) { + $jce_path = $java_se ? { + 'jre' => "${creates_path}/lib/security", + 'jdk' => "${creates_path}/jre/lib/security" + } + archive { "/tmp/jce-${version}.zip": + source => $jce_download, + cookie => 'gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie', + extract => true, + extract_path => $jce_path, + extract_flags => '-oj', + creates => "${jce_path}/US_export_policy.jar", + cleanup => false, + proxy_server => $proxy_server, + proxy_type => $proxy_type, + require => [ + Package['unzip'], + Exec["Install Oracle java_se ${java_se} ${version}"] + ] + } } } - default : { - fail ("unsupported platform ${$facts['kernel']}") + default: { + fail("unsupported platform ${$facts['kernel']}") } } } - default : { - notice ("Action ${ensure} not supported.") + default: { + notice("Action ${ensure} not supported.") } } diff --git a/spec/acceptance/install_spec.rb b/spec/acceptance/install_spec.rb index 32fca8b3..b19b3a67 100644 --- a/spec/acceptance/install_spec.rb +++ b/spec/acceptance/install_spec.rb @@ -1,5 +1,7 @@ require 'spec_helper_acceptance' +include Unix::File + # RedHat, CentOS, Scientific, Oracle prior to 5.0 : Sun Java JDK/JRE 1.6 # RedHat, CentOS, Scientific, Oracle 5.0 < x < 6.3 : OpenJDK Java JDK/JRE 1.6 # RedHat, CentOS, Scientific, Oracle after 6.3 : OpenJDK Java JDK/JRE 1.7 @@ -79,6 +81,62 @@ " java_alternative_path => '/whatever',\n"\ '}' +# Oracle installs are disabled by default, because the links to valid oracle installations +# change often. Look the parameters up from the Oracle download URLs at https://java.oracle.com and +# enable the tests: + +oracle_enabled = true +oracle_version_major = "8" +oracle_version_minor = "181" +oracle_version_build = "13" +oracle_hash = "96a7b8442fe848ef90c96a2fad6ed6d1" + +install_oracle_jre = < '#{oracle_version_major}', + version_major => '#{oracle_version_major}u#{oracle_version_minor}', + version_minor => 'b#{oracle_version_build}', + url_hash => '#{oracle_hash}', + java_se => 'jre', + } +EOL + +install_oracle_jdk = < '#{oracle_version_major}', + version_major => '#{oracle_version_major}u#{oracle_version_minor}', + version_minor => 'b#{oracle_version_build}', + url_hash => '#{oracle_hash}', + java_se => 'jdk', + } +EOL + +install_oracle_jre_jce = < '#{oracle_version_major}', + version_major => '#{oracle_version_major}u#{oracle_version_minor}', + version_minor => 'b#{oracle_version_build}', + url_hash => '#{oracle_hash}', + java_se => 'jre', + jce => true, + } +EOL + +install_oracle_jdk_jce = < '#{oracle_version_major}', + version_major => '#{oracle_version_major}u#{oracle_version_minor}', + version_minor => 'b#{oracle_version_build}', + url_hash => '#{oracle_hash}', + java_se => 'jdk', + jce => true, + } +EOL + context 'installing java jre', unless: UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do it 'installs jre' do apply_manifest(java_class_jre, catch_failures: true) @@ -155,3 +213,37 @@ end end end + +# Test oracle java installs +context 'java::oracle', if: oracle_enabled, unless: UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do + install_path = "/usr/lib/jvm" + version_suffix = "" + if fact('osfamily') == 'RedHat' || fact('osfamily') == 'Amazon' then + install_path = "/usr/java" + version_suffix = "-amd64" + end + it 'installs oracle jdk' do + apply_manifest(install_oracle_jdk, catch_failures: true) + apply_manifest(install_oracle_jdk, catch_changes: true) + result = shell("test ! -e #{install_path}/jdk1.#{oracle_version_major}.0_#{oracle_version_minor}#{version_suffix}/jre/lib/security/local_policy.jar") + expect(result.exit_code).to eq(0) + end + it 'installs oracle jre' do + apply_manifest(install_oracle_jre, catch_failures: true) + apply_manifest(install_oracle_jre, catch_changes: true) + result = shell("test ! -e #{install_path}/jre1.#{oracle_version_major}.0_#{oracle_version_minor}#{version_suffix}/lib/security/local_policy.jar") + expect(result.exit_code).to eq(0) + end + it 'installs oracle jdk with jce' do + apply_manifest(install_oracle_jdk_jce, catch_failures: true) + apply_manifest(install_oracle_jdk_jce, catch_changes: true) + result = shell("test -e #{install_path}/jdk1.#{oracle_version_major}.0_#{oracle_version_minor}#{version_suffix}/jre/lib/security/local_policy.jar") + expect(result.exit_code).to eq(0) + end + it 'installs oracle jre with jce' do + apply_manifest(install_oracle_jre_jce, catch_failures: true) + apply_manifest(install_oracle_jre_jce, catch_changes: true) + result = shell("test -e #{install_path}/jre1.#{oracle_version_major}.0_#{oracle_version_minor}#{version_suffix}/lib/security/local_policy.jar") + expect(result.exit_code).to eq(0) + end +end \ No newline at end of file diff --git a/spec/defines/oracle_spec.rb b/spec/defines/oracle_spec.rb index afa85cf1..fa62880d 100644 --- a/spec/defines/oracle_spec.rb +++ b/spec/defines/oracle_spec.rb @@ -93,6 +93,24 @@ it { is_expected.to contain_archive('/tmp/jdk-8u131-linux-x64.rpm').with_source('http://download.oracle.com/otn-pub/java/jdk//8u131-b11/abcdef01234567890/jdk-8u131-linux-x64.rpm') } end + + context 'when installing Oracle Java SE 6 JRE with JCE' do + let(:params) { { ensure: 'present', jce: true, version: '6', version_major: '6u99', version_minor: '99', java_se: 'jre'}} + let(:title) { 'jre6jce'} + it do + is_expected.to contain_archive('/tmp/jce-6.zip').with_source('http://download.oracle.com/otn-pub/java/jce_policy/6/jce_policy-6.zip') + is_expected.to contain_archive('/tmp/jce-6.zip').with_extract_path('/usr/java/jre1.6.0_99-amd64/lib/security') + end + end + + context 'when installing Oracle Java SE 6 JDK with JCE' do + let(:params) { { ensure: 'present', jce: true, version: '6', version_major: '6u99', version_minor: '99', java_se: 'jdk'}} + let(:title) { 'jre6jce'} + it do + is_expected.to contain_archive('/tmp/jce-6.zip').with_source('http://download.oracle.com/otn-pub/java/jce_policy/6/jce_policy-6.zip') + is_expected.to contain_archive('/tmp/jce-6.zip').with_extract_path('/usr/java/jdk1.6.0_99-amd64/jre/lib/security') + end + end end context 'when on CentOS 32-bit' do @@ -151,6 +169,24 @@ 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 + + context 'when installing Oracle Java SE 6 JRE with JCE' do + let(:params) { { ensure: 'present', jce: true, version: '6', version_major: '6u99', version_minor: '99', java_se: 'jre'}} + let(:title) { 'jre6jce'} + it do + is_expected.to contain_archive('/tmp/jce-6.zip').with_source('http://download.oracle.com/otn-pub/java/jce_policy/6/jce_policy-6.zip') + is_expected.to contain_archive('/tmp/jce-6.zip').with_extract_path('/usr/java/jre1.6.0_99-amd64/lib/security') + end + end + + context 'when installing Oracle Java SE 6 JDK with JCE' do + let(:params) { { ensure: 'present', jce: true, version: '6', version_major: '6u99', version_minor: '99', java_se: 'jdk'}} + let(:title) { 'jre6jce'} + it do + is_expected.to contain_archive('/tmp/jce-6.zip').with_source('http://download.oracle.com/otn-pub/java/jce_policy/6/jce_policy-6.zip') + is_expected.to contain_archive('/tmp/jce-6.zip').with_extract_path('/usr/java/jdk1.6.0_99-amd64/jre/lib/security') + end + end end context 'with Ubuntu 64-bit' do @@ -216,6 +252,24 @@ it { is_expected.to contain_archive('/tmp/jdk-8u131-linux-x64.tar.gz') } end + + context 'when installing Oracle Java SE 6 JRE with JCE' do + let(:params) { { ensure: 'present', jce: true, version: '6', version_major: '6u99', version_minor: '99', java_se: 'jre'}} + let(:title) { 'jre6jce'} + it do + is_expected.to contain_archive('/tmp/jce-6.zip').with_source('http://download.oracle.com/otn-pub/java/jce_policy/6/jce_policy-6.zip') + is_expected.to contain_archive('/tmp/jce-6.zip').with_extract_path('/usr/lib/jvm/jre1.6.0_99/lib/security') + end + end + + context 'when installing Oracle Java SE 6 JDK with JCE' do + let(:params) { { ensure: 'present', jce: true, version: '6', version_major: '6u99', version_minor: '99', java_se: 'jdk'}} + let(:title) { 'jre6jce'} + it do + is_expected.to contain_archive('/tmp/jce-6.zip').with_source('http://download.oracle.com/otn-pub/java/jce_policy/6/jce_policy-6.zip') + is_expected.to contain_archive('/tmp/jce-6.zip').with_extract_path('/usr/lib/jvm/jdk1.6.0_99/jre/lib/security') + end + end end describe 'incompatible OSes' do [ From 55104d88c7cce1260859015ec01d68e1ed9a26cf Mon Sep 17 00:00:00 2001 From: Dennis Ploeger Date: Mon, 8 Oct 2018 16:46:55 +0200 Subject: [PATCH 03/12] Disabled oracle tests again. Only to be enabled, if the other configuration options match the current java download URL provided by Oracle. --- spec/acceptance/install_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/acceptance/install_spec.rb b/spec/acceptance/install_spec.rb index b19b3a67..47bde5cb 100644 --- a/spec/acceptance/install_spec.rb +++ b/spec/acceptance/install_spec.rb @@ -85,7 +85,7 @@ # change often. Look the parameters up from the Oracle download URLs at https://java.oracle.com and # enable the tests: -oracle_enabled = true +oracle_enabled = false oracle_version_major = "8" oracle_version_minor = "181" oracle_version_build = "13" From 24eee320bd101a89917e40699f4bff3bce3c205f Mon Sep 17 00:00:00 2001 From: Dennis Ploeger Date: Tue, 9 Oct 2018 07:43:35 +0200 Subject: [PATCH 04/12] Optimized code as recommended by Rubocop --- spec/acceptance/install_spec.rb | 20 ++++++++++---------- spec/defines/oracle_spec.rb | 30 ++++++++++++++++++------------ 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/spec/acceptance/install_spec.rb b/spec/acceptance/install_spec.rb index 47bde5cb..9c8cbc81 100644 --- a/spec/acceptance/install_spec.rb +++ b/spec/acceptance/install_spec.rb @@ -86,10 +86,10 @@ # enable the tests: oracle_enabled = false -oracle_version_major = "8" -oracle_version_minor = "181" -oracle_version_build = "13" -oracle_hash = "96a7b8442fe848ef90c96a2fad6ed6d1" +oracle_version_major = '8' +oracle_version_minor = '181' +oracle_version_build = '13' +oracle_hash = '96a7b8442fe848ef90c96a2fad6ed6d1' install_oracle_jre = < Date: Fri, 12 Oct 2018 07:43:57 +0200 Subject: [PATCH 05/12] Optimized code for making java::oracle atomic. Fixes MODULES-8085 --- manifests/oracle.pp | 22 ++--- spec/defines/oracle_spec.rb | 156 +++++++++++++++++++++++++++--------- 2 files changed, 132 insertions(+), 46 deletions(-) diff --git a/manifests/oracle.pp b/manifests/oracle.pp index 36313b8e..38a9ff6a 100644 --- a/manifests/oracle.pp +++ b/manifests/oracle.pp @@ -269,20 +269,22 @@ } case $facts['kernel'] { 'Linux' : { - exec { "Install Oracle java_se ${java_se} ${version}" : - path => '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin', - command => $install_command, - creates => $creates_path, - require => Archive[$destination] - } case $facts['os']['family'] { 'Debian' : { - file{'/usr/lib/jvm': + ensure_resource('file', '/usr/lib/jvm', { ensure => directory, - before => Exec["Install Oracle java_se ${java_se} ${version}"] - } + }) + $install_requires = [Archive[$destination], File['/usr/lib/jvm']] + } + default : { + $install_requires = [Archive[$destination]] } - default : { } + } + exec { "Install Oracle java_se ${java_se} ${version} ${release_major} ${release_minor}" : + path => '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin', + command => $install_command, + creates => $creates_path, + require => $install_requires } } default : { diff --git a/spec/defines/oracle_spec.rb b/spec/defines/oracle_spec.rb index afa85cf1..3674b767 100644 --- a/spec/defines/oracle_spec.rb +++ b/spec/defines/oracle_spec.rb @@ -11,8 +11,8 @@ let(:title) { 'jdk6' } it { is_expected.to contain_archive('/tmp/jdk-6u45-linux-x64-rpm.bin') } - it { is_expected.to contain_exec('Install Oracle java_se jdk 6').with_command('sh /tmp/jdk-6u45-linux-x64-rpm.bin -x; rpm --force -iv sun*.rpm; rpm --force -iv jdk*.rpm') } - it { is_expected.to contain_exec('Install Oracle java_se jdk 6').that_requires('Archive[/tmp/jdk-6u45-linux-x64-rpm.bin]') } + it { is_expected.to contain_exec('Install Oracle java_se jdk 6 6u45 b06').with_command('sh /tmp/jdk-6u45-linux-x64-rpm.bin -x; rpm --force -iv sun*.rpm; rpm --force -iv jdk*.rpm') } + it { is_expected.to contain_exec('Install Oracle java_se jdk 6 6u45 b06').that_requires('Archive[/tmp/jdk-6u45-linux-x64-rpm.bin]') } end context 'when Oracle Java SE 7 JDK' do @@ -20,8 +20,8 @@ let(:title) { 'jdk7' } it { is_expected.to contain_archive('/tmp/jdk-7u80-linux-x64.rpm') } - it { is_expected.to contain_exec('Install Oracle java_se jdk 7').with_command('rpm --force -iv /tmp/jdk-7u80-linux-x64.rpm') } - it { is_expected.to contain_exec('Install Oracle java_se jdk 7').that_requires('Archive[/tmp/jdk-7u80-linux-x64.rpm]') } + it { is_expected.to contain_exec('Install Oracle java_se jdk 7 7u80 b15').with_command('rpm --force -iv /tmp/jdk-7u80-linux-x64.rpm') } + it { is_expected.to contain_exec('Install Oracle java_se jdk 7 7u80 b15').that_requires('Archive[/tmp/jdk-7u80-linux-x64.rpm]') } end context 'when Oracle Java SE 8 JDK' do @@ -29,8 +29,8 @@ let(:title) { 'jdk8' } 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]') } + it { is_expected.to contain_exec('Install Oracle java_se jdk 8 8u131 b11').with_command('rpm --force -iv /tmp/jdk-8u131-linux-x64.rpm') } + it { is_expected.to contain_exec('Install Oracle java_se jdk 8 8u131 b11').that_requires('Archive[/tmp/jdk-8u131-linux-x64.rpm]') } end context 'when Oracle Java SE 6 JRE' do @@ -38,8 +38,8 @@ let(:title) { 'jre6' } it { is_expected.to contain_archive('/tmp/jre-6u45-linux-x64-rpm.bin') } - it { is_expected.to contain_exec('Install Oracle java_se jre 6').with_command('sh /tmp/jre-6u45-linux-x64-rpm.bin -x; rpm --force -iv sun*.rpm; rpm --force -iv jre*.rpm') } - it { is_expected.to contain_exec('Install Oracle java_se jre 6').that_requires('Archive[/tmp/jre-6u45-linux-x64-rpm.bin]') } + it { is_expected.to contain_exec('Install Oracle java_se jre 6 6u45 b06').with_command('sh /tmp/jre-6u45-linux-x64-rpm.bin -x; rpm --force -iv sun*.rpm; rpm --force -iv jre*.rpm') } + it { is_expected.to contain_exec('Install Oracle java_se jre 6 6u45 b06').that_requires('Archive[/tmp/jre-6u45-linux-x64-rpm.bin]') } end context 'when Oracle Java SE 7 JRE' do @@ -47,8 +47,8 @@ let(:title) { 'jre7' } it { is_expected.to contain_archive('/tmp/jre-7u80-linux-x64.rpm') } - it { is_expected.to contain_exec('Install Oracle java_se jre 7').with_command('rpm --force -iv /tmp/jre-7u80-linux-x64.rpm') } - it { is_expected.to contain_exec('Install Oracle java_se jre 7').that_requires('Archive[/tmp/jre-7u80-linux-x64.rpm]') } + it { is_expected.to contain_exec('Install Oracle java_se jre 7 7u80 b15').with_command('rpm --force -iv /tmp/jre-7u80-linux-x64.rpm') } + it { is_expected.to contain_exec('Install Oracle java_se jre 7 7u80 b15').that_requires('Archive[/tmp/jre-7u80-linux-x64.rpm]') } end context 'when select Oracle Java SE 8 JRE' do @@ -56,8 +56,8 @@ let(:title) { 'jre8' } 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]') } + it { is_expected.to contain_exec('Install Oracle java_se jre 8 8u131 b11').with_command('rpm --force -iv /tmp/jre-8u131-linux-x64.rpm') } + it { is_expected.to contain_exec('Install Oracle java_se jre 8 8u131 b11').that_requires('Archive[/tmp/jre-8u131-linux-x64.rpm]') } end context 'when passing URL to url parameter' do @@ -93,6 +93,34 @@ it { is_expected.to contain_archive('/tmp/jdk-8u131-linux-x64.rpm').with_source('http://download.oracle.com/otn-pub/java/jdk//8u131-b11/abcdef01234567890/jdk-8u131-linux-x64.rpm') } end + + context 'when installing multiple versions' do + let(:params) do + { + ensure: 'present', + version_major: '8u131', + version_minor: 'b11', + java_se: 'jdk', + url_hash: 'abcdef01234567890', + } + end + let(:title) { 'jdk8' } + + let(:pre_condition) do + <<-EOL + java::oracle { + 'jdk8121': + ensure => 'present', + version_major => '8u121', + version_minor => 'b11', + java_se => 'jdk', + url_hash => 'fiewojgfuiowfniweof', + } + EOL + end + + it { is_expected.to compile } + end end context 'when on CentOS 32-bit' do @@ -103,8 +131,8 @@ let(:title) { 'jdk6' } it { is_expected.to contain_archive('/tmp/jdk-6u45-linux-i586-rpm.bin') } - it { is_expected.to contain_exec('Install Oracle java_se jdk 6').with_command('sh /tmp/jdk-6u45-linux-i586-rpm.bin -x; rpm --force -iv sun*.rpm; rpm --force -iv jdk*.rpm') } - it { is_expected.to contain_exec('Install Oracle java_se jdk 6').that_requires('Archive[/tmp/jdk-6u45-linux-i586-rpm.bin]') } + it { is_expected.to contain_exec('Install Oracle java_se jdk 6 6u45 b06').with_command('sh /tmp/jdk-6u45-linux-i586-rpm.bin -x; rpm --force -iv sun*.rpm; rpm --force -iv jdk*.rpm') } + it { is_expected.to contain_exec('Install Oracle java_se jdk 6 6u45 b06').that_requires('Archive[/tmp/jdk-6u45-linux-i586-rpm.bin]') } end context 'when selecting Oracle Java SE 7 JDK on RedHat family, 32-bit' do @@ -112,8 +140,8 @@ let(:title) { 'jdk7' } it { is_expected.to contain_archive('/tmp/jdk-7u80-linux-i586.rpm') } - it { is_expected.to contain_exec('Install Oracle java_se jdk 7').with_command('rpm --force -iv /tmp/jdk-7u80-linux-i586.rpm') } - it { is_expected.to contain_exec('Install Oracle java_se jdk 7').that_requires('Archive[/tmp/jdk-7u80-linux-i586.rpm]') } + it { is_expected.to contain_exec('Install Oracle java_se jdk 7 7u80 b15').with_command('rpm --force -iv /tmp/jdk-7u80-linux-i586.rpm') } + it { is_expected.to contain_exec('Install Oracle java_se jdk 7 7u80 b15').that_requires('Archive[/tmp/jdk-7u80-linux-i586.rpm]') } end context 'when selecting Oracle Java SE 8 JDK on RedHat family, 32-bit' do @@ -121,8 +149,8 @@ let(:title) { 'jdk8' } 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]') } + it { is_expected.to contain_exec('Install Oracle java_se jdk 8 8u131 b11').with_command('rpm --force -iv /tmp/jdk-8u131-linux-i586.rpm') } + it { is_expected.to contain_exec('Install Oracle java_se jdk 8 8u131 b11').that_requires('Archive[/tmp/jdk-8u131-linux-i586.rpm]') } end context 'when selecting Oracle Java SE 6 JRE on RedHat family, 32-bit' do @@ -130,8 +158,8 @@ let(:title) { 'jdk6' } it { is_expected.to contain_archive('/tmp/jre-6u45-linux-i586-rpm.bin') } - it { is_expected.to contain_exec('Install Oracle java_se jre 6').with_command('sh /tmp/jre-6u45-linux-i586-rpm.bin -x; rpm --force -iv sun*.rpm; rpm --force -iv jre*.rpm') } - it { is_expected.to contain_exec('Install Oracle java_se jre 6').that_requires('Archive[/tmp/jre-6u45-linux-i586-rpm.bin]') } + it { is_expected.to contain_exec('Install Oracle java_se jre 6 6u45 b06').with_command('sh /tmp/jre-6u45-linux-i586-rpm.bin -x; rpm --force -iv sun*.rpm; rpm --force -iv jre*.rpm') } + it { is_expected.to contain_exec('Install Oracle java_se jre 6 6u45 b06').that_requires('Archive[/tmp/jre-6u45-linux-i586-rpm.bin]') } end context 'when select Oracle Java SE 7 JRE on RedHat family, 32-bit' do @@ -139,8 +167,8 @@ let(:title) { 'jdk7' } it { is_expected.to contain_archive('/tmp/jre-7u80-linux-i586.rpm') } - it { is_expected.to contain_exec('Install Oracle java_se jre 7').with_command('rpm --force -iv /tmp/jre-7u80-linux-i586.rpm') } - it { is_expected.to contain_exec('Install Oracle java_se jre 7').that_requires('Archive[/tmp/jre-7u80-linux-i586.rpm]') } + it { is_expected.to contain_exec('Install Oracle java_se jre 7 7u80 b15').with_command('rpm --force -iv /tmp/jre-7u80-linux-i586.rpm') } + it { is_expected.to contain_exec('Install Oracle java_se jre 7 7u80 b15').that_requires('Archive[/tmp/jre-7u80-linux-i586.rpm]') } end context 'when select Oracle Java SE 8 JRE on RedHat family, 32-bit' do @@ -148,8 +176,36 @@ let(:title) { 'jdk8' } 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]') } + it { is_expected.to contain_exec('Install Oracle java_se jre 8 8u131 b11').with_command('rpm --force -iv /tmp/jre-8u131-linux-i586.rpm') } + it { is_expected.to contain_exec('Install Oracle java_se jre 8 8u131 b11').that_requires('Archive[/tmp/jre-8u131-linux-i586.rpm]') } + end + + context 'when installing multiple versions' do + let(:params) do + { + ensure: 'present', + version_major: '8u131', + version_minor: 'b11', + java_se: 'jdk', + url_hash: 'abcdef01234567890', + } + end + let(:title) { 'jdk8' } + + let(:pre_condition) do + <<-EOL + java::oracle { + 'jdk8121': + ensure => 'present', + version_major => '8u121', + version_minor => 'b11', + java_se => 'jdk', + url_hash => 'fiewojgfuiowfniweof', + } + EOL + end + + it { is_expected.to compile } end end @@ -161,8 +217,8 @@ let(:title) { 'jdk6' } it { is_expected.to contain_archive('/tmp/jdk-6u45-linux-x64.tar.gz') } - it { is_expected.to contain_exec('Install Oracle java_se jdk 6').with_command('tar -zxf /tmp/jdk-6u45-linux-x64.tar.gz -C /usr/lib/jvm') } - it { is_expected.to contain_exec('Install Oracle java_se jdk 6').that_requires('Archive[/tmp/jdk-6u45-linux-x64.tar.gz]') } + it { is_expected.to contain_exec('Install Oracle java_se jdk 6 6u45 b06').with_command('tar -zxf /tmp/jdk-6u45-linux-x64.tar.gz -C /usr/lib/jvm') } + it { is_expected.to contain_exec('Install Oracle java_se jdk 6 6u45 b06').that_requires('Archive[/tmp/jdk-6u45-linux-x64.tar.gz]') } end context 'with Oracle Java SE 7 JDK' do @@ -170,8 +226,8 @@ let(:title) { 'jdk7' } it { is_expected.to contain_archive('/tmp/jdk-7u80-linux-x64.tar.gz') } - it { is_expected.to contain_exec('Install Oracle java_se jdk 7').with_command('tar -zxf /tmp/jdk-7u80-linux-x64.tar.gz -C /usr/lib/jvm') } - it { is_expected.to contain_exec('Install Oracle java_se jdk 7').that_requires('Archive[/tmp/jdk-7u80-linux-x64.tar.gz]') } + it { is_expected.to contain_exec('Install Oracle java_se jdk 7 7u80 b15').with_command('tar -zxf /tmp/jdk-7u80-linux-x64.tar.gz -C /usr/lib/jvm') } + it { is_expected.to contain_exec('Install Oracle java_se jdk 7 7u80 b15').that_requires('Archive[/tmp/jdk-7u80-linux-x64.tar.gz]') } end context 'with Oracle Java SE 8 JDK' do @@ -179,8 +235,8 @@ let(:title) { 'jdk8' } it { is_expected.to contain_archive('/tmp/jdk-8u131-linux-x64.tar.gz') } - it { is_expected.to contain_exec('Install Oracle java_se jdk 8').with_command('tar -zxf /tmp/jdk-8u131-linux-x64.tar.gz -C /usr/lib/jvm') } - it { is_expected.to contain_exec('Install Oracle java_se jdk 8').that_requires('Archive[/tmp/jdk-8u131-linux-x64.tar.gz]') } + it { is_expected.to contain_exec('Install Oracle java_se jdk 8 8u131 b11').with_command('tar -zxf /tmp/jdk-8u131-linux-x64.tar.gz -C /usr/lib/jvm') } + it { is_expected.to contain_exec('Install Oracle java_se jdk 8 8u131 b11').that_requires('Archive[/tmp/jdk-8u131-linux-x64.tar.gz]') } end context 'with Oracle Java SE 6 JRE' do @@ -188,8 +244,8 @@ let(:title) { 'jre6' } it { is_expected.to contain_archive('/tmp/jre-6u45-linux-x64.tar.gz') } - it { is_expected.to contain_exec('Install Oracle java_se jre 6').with_command('tar -zxf /tmp/jre-6u45-linux-x64.tar.gz -C /usr/lib/jvm') } - it { is_expected.to contain_exec('Install Oracle java_se jre 6').that_requires('Archive[/tmp/jre-6u45-linux-x64.tar.gz]') } + it { is_expected.to contain_exec('Install Oracle java_se jre 6 6u45 b06').with_command('tar -zxf /tmp/jre-6u45-linux-x64.tar.gz -C /usr/lib/jvm') } + it { is_expected.to contain_exec('Install Oracle java_se jre 6 6u45 b06').that_requires('Archive[/tmp/jre-6u45-linux-x64.tar.gz]') } end context 'when Oracle Java SE 7 JRE' do @@ -197,8 +253,8 @@ let(:title) { 'jre7' } it { is_expected.to contain_archive('/tmp/jre-7u80-linux-x64.tar.gz') } - it { is_expected.to contain_exec('Install Oracle java_se jre 7').with_command('tar -zxf /tmp/jre-7u80-linux-x64.tar.gz -C /usr/lib/jvm') } - it { is_expected.to contain_exec('Install Oracle java_se jre 7').that_requires('Archive[/tmp/jre-7u80-linux-x64.tar.gz]') } + it { is_expected.to contain_exec('Install Oracle java_se jre 7 7u80 b15').with_command('tar -zxf /tmp/jre-7u80-linux-x64.tar.gz -C /usr/lib/jvm') } + it { is_expected.to contain_exec('Install Oracle java_se jre 7 7u80 b15').that_requires('Archive[/tmp/jre-7u80-linux-x64.tar.gz]') } end context 'when Oracle Java SE 8 JRE' do @@ -206,8 +262,8 @@ let(:title) { 'jre8' } it { is_expected.to contain_archive('/tmp/jre-8u131-linux-x64.tar.gz') } - it { is_expected.to contain_exec('Install Oracle java_se jre 8').with_command('tar -zxf /tmp/jre-8u131-linux-x64.tar.gz -C /usr/lib/jvm') } - it { is_expected.to contain_exec('Install Oracle java_se jre 8').that_requires('Archive[/tmp/jre-8u131-linux-x64.tar.gz]') } + it { is_expected.to contain_exec('Install Oracle java_se jre 8 8u131 b11').with_command('tar -zxf /tmp/jre-8u131-linux-x64.tar.gz -C /usr/lib/jvm') } + it { is_expected.to contain_exec('Install Oracle java_se jre 8 8u131 b11').that_requires('Archive[/tmp/jre-8u131-linux-x64.tar.gz]') } end context 'when passing URL to url parameter' do @@ -216,6 +272,34 @@ it { is_expected.to contain_archive('/tmp/jdk-8u131-linux-x64.tar.gz') } end + + context 'when installing multiple versions' do + let(:params) do + { + ensure: 'present', + version_major: '8u131', + version_minor: 'b11', + java_se: 'jdk', + url_hash: 'abcdef01234567890', + } + end + let(:title) { 'jdk8' } + + let(:pre_condition) do + <<-EOL + java::oracle { + 'jdk8121': + ensure => 'present', + version_major => '8u121', + version_minor => 'b11', + java_se => 'jdk', + url_hash => 'fiewojgfuiowfniweof', + } + EOL + end + + it { is_expected.to compile } + end end describe 'incompatible OSes' do [ From bf26247f55e681859a70037ef180f9c1943a76e9 Mon Sep 17 00:00:00 2001 From: Dennis Ploeger Date: Fri, 12 Oct 2018 14:27:59 +0200 Subject: [PATCH 06/12] Fixed style violations --- spec/defines/oracle_spec.rb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/spec/defines/oracle_spec.rb b/spec/defines/oracle_spec.rb index 3674b767..0a6a40e3 100644 --- a/spec/defines/oracle_spec.rb +++ b/spec/defines/oracle_spec.rb @@ -183,11 +183,11 @@ context 'when installing multiple versions' do let(:params) do { - ensure: 'present', - version_major: '8u131', - version_minor: 'b11', - java_se: 'jdk', - url_hash: 'abcdef01234567890', + ensure: 'present', + version_major: '8u131', + version_minor: 'b11', + java_se: 'jdk', + url_hash: 'abcdef01234567890', } end let(:title) { 'jdk8' } @@ -276,11 +276,11 @@ context 'when installing multiple versions' do let(:params) do { - ensure: 'present', - version_major: '8u131', - version_minor: 'b11', - java_se: 'jdk', - url_hash: 'abcdef01234567890', + ensure: 'present', + version_major: '8u131', + version_minor: 'b11', + java_se: 'jdk', + url_hash: 'abcdef01234567890', } end let(:title) { 'jdk8' } From 911df2d7b77d764c06a7aadbcc57e9a6d56cb6e8 Mon Sep 17 00:00:00 2001 From: Michael Moll Date: Thu, 11 Oct 2018 18:47:03 +0200 Subject: [PATCH 07/12] Fix OpenJDK paths on Debian based OS with ARM --- manifests/params.pp | 43 ++++++++++++++++++++++----------------- spec/classes/java_spec.rb | 16 +++++++++++++++ 2 files changed, 40 insertions(+), 19 deletions(-) diff --git a/manifests/params.pp b/manifests/params.pp index e69a19de..8da61228 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -74,18 +74,23 @@ 'amd64' => 'x64', default => $::architecture } + $openjdk_architecture = $::architecture ? { + 'aarch64' => 'arm64', + 'armv7l' => 'armhf', + default => $::architecture + } case $::lsbdistcodename { 'lenny', 'squeeze', 'lucid', 'natty': { $java = { 'jdk' => { 'package' => 'openjdk-6-jdk', - 'alternative' => "java-6-openjdk-${::architecture}", + 'alternative' => "java-6-openjdk-${openjdk_architecture}", 'alternative_path' => '/usr/lib/jvm/java-6-openjdk/jre/bin/java', 'java_home' => '/usr/lib/jvm/java-6-openjdk/jre/', }, 'jre' => { 'package' => 'openjdk-6-jre-headless', - 'alternative' => "java-6-openjdk-${::architecture}", + 'alternative' => "java-6-openjdk-${openjdk_architecture}", 'alternative_path' => '/usr/lib/jvm/java-6-openjdk/jre/bin/java', 'java_home' => '/usr/lib/jvm/java-6-openjdk/jre/', }, @@ -107,15 +112,15 @@ $java = { 'jdk' => { 'package' => 'openjdk-7-jdk', - 'alternative' => "java-1.7.0-openjdk-${::architecture}", - 'alternative_path' => "/usr/lib/jvm/java-1.7.0-openjdk-${::architecture}/bin/java", - 'java_home' => "/usr/lib/jvm/java-1.7.0-openjdk-${::architecture}/", + 'alternative' => "java-1.7.0-openjdk-${openjdk_architecture}", + 'alternative_path' => "/usr/lib/jvm/java-1.7.0-openjdk-${openjdk_architecture}/bin/java", + 'java_home' => "/usr/lib/jvm/java-1.7.0-openjdk-${openjdk_architecture}/", }, 'jre' => { 'package' => 'openjdk-7-jre-headless', 'alternative' => "java-1.7.0-openjdk-${::architecture}", - 'alternative_path' => "/usr/lib/jvm/java-1.7.0-openjdk-${::architecture}/bin/java", - 'java_home' => "/usr/lib/jvm/java-1.7.0-openjdk-${::architecture}/", + 'alternative_path' => "/usr/lib/jvm/java-1.7.0-openjdk-${openjdk_architecture}/bin/java", + 'java_home' => "/usr/lib/jvm/java-1.7.0-openjdk-${openjdk_architecture}/", }, 'oracle-jre' => { 'package' => 'oracle-j2re1.7', @@ -159,15 +164,15 @@ $java = { 'jdk' => { 'package' => 'openjdk-8-jdk', - 'alternative' => "java-1.8.0-openjdk-${::architecture}", - 'alternative_path' => "/usr/lib/jvm/java-1.8.0-openjdk-${::architecture}/bin/java", - 'java_home' => "/usr/lib/jvm/java-1.8.0-openjdk-${::architecture}/", + 'alternative' => "java-1.8.0-openjdk-${openjdk_architecture}", + 'alternative_path' => "/usr/lib/jvm/java-1.8.0-openjdk-${openjdk_architecture}/bin/java", + 'java_home' => "/usr/lib/jvm/java-1.8.0-openjdk-${openjdk_architecture}/", }, 'jre' => { 'package' => 'openjdk-8-jre-headless', - 'alternative' => "java-1.8.0-openjdk-${::architecture}", - 'alternative_path' => "/usr/lib/jvm/java-1.8.0-openjdk-${::architecture}/bin/java", - 'java_home' => "/usr/lib/jvm/java-1.8.0-openjdk-${::architecture}/", + 'alternative' => "java-1.8.0-openjdk-${openjdk_architecture}", + 'alternative_path' => "/usr/lib/jvm/java-1.8.0-openjdk-${openjdk_architecture}/bin/java", + 'java_home' => "/usr/lib/jvm/java-1.8.0-openjdk-${openjdk_architecture}/", } } } @@ -175,15 +180,15 @@ $java = { 'jdk' => { 'package' => 'openjdk-11-jdk', - 'alternative' => "java-1.11.0-openjdk-${::architecture}", - 'alternative_path' => "/usr/lib/jvm/java-1.11.0-openjdk-${::architecture}/bin/java", - 'java_home' => "/usr/lib/jvm/java-1.11.0-openjdk-${::architecture}/", + 'alternative' => "java-1.11.0-openjdk-${openjdk_architecture}", + 'alternative_path' => "/usr/lib/jvm/java-1.11.0-openjdk-${openjdk_architecture}/bin/java", + 'java_home' => "/usr/lib/jvm/java-1.11.0-openjdk-${openjdk_architecture}/", }, 'jre' => { 'package' => 'openjdk-11-jre-headless', - 'alternative' => "java-1.11.0-openjdk-${::architecture}", - 'alternative_path' => "/usr/lib/jvm/java-1.11.0-openjdk-${::architecture}/bin/java", - 'java_home' => "/usr/lib/jvm/java-1.11.0-openjdk-${::architecture}/", + 'alternative' => "java-1.11.0-openjdk-${openjdk_architecture}", + 'alternative_path' => "/usr/lib/jvm/java-1.11.0-openjdk-${openjdk_architecture}/bin/java", + 'java_home' => "/usr/lib/jvm/java-1.11.0-openjdk-${openjdk_architecture}/", } } } diff --git a/spec/classes/java_spec.rb b/spec/classes/java_spec.rb index a82850bc..2764b8f8 100644 --- a/spec/classes/java_spec.rb +++ b/spec/classes/java_spec.rb @@ -69,6 +69,22 @@ it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64/') } end + context 'when select jdk for Ubuntu xenial (16.04) on ARM' do + let(:facts) { { osfamily: 'Debian', operatingsystem: 'Ubuntu', lsbdistcodename: 'xenial', operatingsystemrelease: '16.04', architecture: 'armv7l' } } + let(:params) { { 'distribution' => 'jdk' } } + + it { is_expected.to contain_package('java').with_name('openjdk-8-jdk') } + it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-armhf/') } + end + + context 'when select jdk for Ubuntu xenial (16.04) on ARM64' do + let(:facts) { { osfamily: 'Debian', operatingsystem: 'Ubuntu', lsbdistcodename: 'xenial', operatingsystemrelease: '16.04', architecture: 'aarch64' } } + let(:params) { { 'distribution' => 'jdk' } } + + it { is_expected.to contain_package('java').with_name('openjdk-8-jdk') } + it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-arm64/') } + end + context 'when select openjdk for Amazon Linux' do let(:facts) { { osfamily: 'RedHat', operatingsystem: 'Amazon', operatingsystemrelease: '3.4.43-43.43.amzn1.x86_64', architecture: 'x86_64' } } From ceb4b0af66f8e8a5ab6304a647fbf9461f91c907 Mon Sep 17 00:00:00 2001 From: Dennis Ploeger Date: Mon, 8 Oct 2018 16:45:15 +0200 Subject: [PATCH 08/12] Support for installing JCE. Fixes MODULES-1681 --- manifests/oracle.pp | 40 ++++++++++++++ spec/acceptance/install_spec.rb | 92 +++++++++++++++++++++++++++++++++ spec/defines/oracle_spec.rb | 54 +++++++++++++++++++ 3 files changed, 186 insertions(+) diff --git a/manifests/oracle.pp b/manifests/oracle.pp index 38a9ff6a..0325fd1b 100644 --- a/manifests/oracle.pp +++ b/manifests/oracle.pp @@ -87,6 +87,9 @@ # 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. # +# [*jce*] +# Install Oracles Java Cryptographic Extensions into the JRE or JDK +# # ### Author # mike@marseglia.org # @@ -101,6 +104,7 @@ $proxy_type = undef, $url = undef, $url_hash = undef, + $jce = false, ) { # archive module is used to download the java package @@ -111,6 +115,15 @@ fail('Java SE must be either jre or jdk.') } + if $jce { + $jce_download = $version ? { + '8' => 'http://download.oracle.com/otn-pub/java/jce/8/jce_policy-8.zip', + '7' => 'http://download.oracle.com/otn-pub/java/jce/7/UnlimitedJCEPolicyJDK7.zip', + '6' => 'http://download.oracle.com/otn-pub/java/jce_policy/6/jce_policy-6.zip', + default => undef + } + } + # determine Oracle Java major and minor version, and installation path if $version_major and $version_minor { @@ -187,6 +200,11 @@ fail ( "unsupported platform ${$facts['kernel']}" ) } } + # Install required unzip packages for jce + if $jce { + ensure_resource('package', 'unzip', { 'ensure' => 'present' }) + } + # set java architecture nomenclature case $facts['os']['architecture'] { 'i386' : { $arch = 'i586' } @@ -286,6 +304,28 @@ creates => $creates_path, require => $install_requires } + + if ($jce and $jce_download != undef) { + $jce_path = $java_se ? { + 'jre' => "${creates_path}/lib/security", + 'jdk' => "${creates_path}/jre/lib/security" + } + archive { "/tmp/jce-${version}.zip": + source => $jce_download, + cookie => 'gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie', + extract => true, + extract_path => $jce_path, + extract_flags => '-oj', + creates => "${jce_path}/US_export_policy.jar", + cleanup => false, + proxy_server => $proxy_server, + proxy_type => $proxy_type, + require => [ + Package['unzip'], + Exec["Install Oracle java_se ${java_se} ${version}"] + ] + } + } } default : { fail ("unsupported platform ${$facts['kernel']}") diff --git a/spec/acceptance/install_spec.rb b/spec/acceptance/install_spec.rb index 32fca8b3..b19b3a67 100644 --- a/spec/acceptance/install_spec.rb +++ b/spec/acceptance/install_spec.rb @@ -1,5 +1,7 @@ require 'spec_helper_acceptance' +include Unix::File + # RedHat, CentOS, Scientific, Oracle prior to 5.0 : Sun Java JDK/JRE 1.6 # RedHat, CentOS, Scientific, Oracle 5.0 < x < 6.3 : OpenJDK Java JDK/JRE 1.6 # RedHat, CentOS, Scientific, Oracle after 6.3 : OpenJDK Java JDK/JRE 1.7 @@ -79,6 +81,62 @@ " java_alternative_path => '/whatever',\n"\ '}' +# Oracle installs are disabled by default, because the links to valid oracle installations +# change often. Look the parameters up from the Oracle download URLs at https://java.oracle.com and +# enable the tests: + +oracle_enabled = true +oracle_version_major = "8" +oracle_version_minor = "181" +oracle_version_build = "13" +oracle_hash = "96a7b8442fe848ef90c96a2fad6ed6d1" + +install_oracle_jre = < '#{oracle_version_major}', + version_major => '#{oracle_version_major}u#{oracle_version_minor}', + version_minor => 'b#{oracle_version_build}', + url_hash => '#{oracle_hash}', + java_se => 'jre', + } +EOL + +install_oracle_jdk = < '#{oracle_version_major}', + version_major => '#{oracle_version_major}u#{oracle_version_minor}', + version_minor => 'b#{oracle_version_build}', + url_hash => '#{oracle_hash}', + java_se => 'jdk', + } +EOL + +install_oracle_jre_jce = < '#{oracle_version_major}', + version_major => '#{oracle_version_major}u#{oracle_version_minor}', + version_minor => 'b#{oracle_version_build}', + url_hash => '#{oracle_hash}', + java_se => 'jre', + jce => true, + } +EOL + +install_oracle_jdk_jce = < '#{oracle_version_major}', + version_major => '#{oracle_version_major}u#{oracle_version_minor}', + version_minor => 'b#{oracle_version_build}', + url_hash => '#{oracle_hash}', + java_se => 'jdk', + jce => true, + } +EOL + context 'installing java jre', unless: UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do it 'installs jre' do apply_manifest(java_class_jre, catch_failures: true) @@ -155,3 +213,37 @@ end end end + +# Test oracle java installs +context 'java::oracle', if: oracle_enabled, unless: UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do + install_path = "/usr/lib/jvm" + version_suffix = "" + if fact('osfamily') == 'RedHat' || fact('osfamily') == 'Amazon' then + install_path = "/usr/java" + version_suffix = "-amd64" + end + it 'installs oracle jdk' do + apply_manifest(install_oracle_jdk, catch_failures: true) + apply_manifest(install_oracle_jdk, catch_changes: true) + result = shell("test ! -e #{install_path}/jdk1.#{oracle_version_major}.0_#{oracle_version_minor}#{version_suffix}/jre/lib/security/local_policy.jar") + expect(result.exit_code).to eq(0) + end + it 'installs oracle jre' do + apply_manifest(install_oracle_jre, catch_failures: true) + apply_manifest(install_oracle_jre, catch_changes: true) + result = shell("test ! -e #{install_path}/jre1.#{oracle_version_major}.0_#{oracle_version_minor}#{version_suffix}/lib/security/local_policy.jar") + expect(result.exit_code).to eq(0) + end + it 'installs oracle jdk with jce' do + apply_manifest(install_oracle_jdk_jce, catch_failures: true) + apply_manifest(install_oracle_jdk_jce, catch_changes: true) + result = shell("test -e #{install_path}/jdk1.#{oracle_version_major}.0_#{oracle_version_minor}#{version_suffix}/jre/lib/security/local_policy.jar") + expect(result.exit_code).to eq(0) + end + it 'installs oracle jre with jce' do + apply_manifest(install_oracle_jre_jce, catch_failures: true) + apply_manifest(install_oracle_jre_jce, catch_changes: true) + result = shell("test -e #{install_path}/jre1.#{oracle_version_major}.0_#{oracle_version_minor}#{version_suffix}/lib/security/local_policy.jar") + expect(result.exit_code).to eq(0) + end +end \ No newline at end of file diff --git a/spec/defines/oracle_spec.rb b/spec/defines/oracle_spec.rb index 0a6a40e3..888630e7 100644 --- a/spec/defines/oracle_spec.rb +++ b/spec/defines/oracle_spec.rb @@ -121,6 +121,24 @@ it { is_expected.to compile } end + + context 'when installing Oracle Java SE 6 JRE with JCE' do + let(:params) { { ensure: 'present', jce: true, version: '6', version_major: '6u99', version_minor: '99', java_se: 'jre'}} + let(:title) { 'jre6jce'} + it do + is_expected.to contain_archive('/tmp/jce-6.zip').with_source('http://download.oracle.com/otn-pub/java/jce_policy/6/jce_policy-6.zip') + is_expected.to contain_archive('/tmp/jce-6.zip').with_extract_path('/usr/java/jre1.6.0_99-amd64/lib/security') + end + end + + context 'when installing Oracle Java SE 6 JDK with JCE' do + let(:params) { { ensure: 'present', jce: true, version: '6', version_major: '6u99', version_minor: '99', java_se: 'jdk'}} + let(:title) { 'jre6jce'} + it do + is_expected.to contain_archive('/tmp/jce-6.zip').with_source('http://download.oracle.com/otn-pub/java/jce_policy/6/jce_policy-6.zip') + is_expected.to contain_archive('/tmp/jce-6.zip').with_extract_path('/usr/java/jdk1.6.0_99-amd64/jre/lib/security') + end + end end context 'when on CentOS 32-bit' do @@ -207,6 +225,24 @@ it { is_expected.to compile } end + + context 'when installing Oracle Java SE 6 JRE with JCE' do + let(:params) { { ensure: 'present', jce: true, version: '6', version_major: '6u99', version_minor: '99', java_se: 'jre'}} + let(:title) { 'jre6jce'} + it do + is_expected.to contain_archive('/tmp/jce-6.zip').with_source('http://download.oracle.com/otn-pub/java/jce_policy/6/jce_policy-6.zip') + is_expected.to contain_archive('/tmp/jce-6.zip').with_extract_path('/usr/java/jre1.6.0_99-amd64/lib/security') + end + end + + context 'when installing Oracle Java SE 6 JDK with JCE' do + let(:params) { { ensure: 'present', jce: true, version: '6', version_major: '6u99', version_minor: '99', java_se: 'jdk'}} + let(:title) { 'jre6jce'} + it do + is_expected.to contain_archive('/tmp/jce-6.zip').with_source('http://download.oracle.com/otn-pub/java/jce_policy/6/jce_policy-6.zip') + is_expected.to contain_archive('/tmp/jce-6.zip').with_extract_path('/usr/java/jdk1.6.0_99-amd64/jre/lib/security') + end + end end context 'with Ubuntu 64-bit' do @@ -300,6 +336,24 @@ it { is_expected.to compile } end + + context 'when installing Oracle Java SE 6 JRE with JCE' do + let(:params) { { ensure: 'present', jce: true, version: '6', version_major: '6u99', version_minor: '99', java_se: 'jre'}} + let(:title) { 'jre6jce'} + it do + is_expected.to contain_archive('/tmp/jce-6.zip').with_source('http://download.oracle.com/otn-pub/java/jce_policy/6/jce_policy-6.zip') + is_expected.to contain_archive('/tmp/jce-6.zip').with_extract_path('/usr/lib/jvm/jre1.6.0_99/lib/security') + end + end + + context 'when installing Oracle Java SE 6 JDK with JCE' do + let(:params) { { ensure: 'present', jce: true, version: '6', version_major: '6u99', version_minor: '99', java_se: 'jdk'}} + let(:title) { 'jre6jce'} + it do + is_expected.to contain_archive('/tmp/jce-6.zip').with_source('http://download.oracle.com/otn-pub/java/jce_policy/6/jce_policy-6.zip') + is_expected.to contain_archive('/tmp/jce-6.zip').with_extract_path('/usr/lib/jvm/jdk1.6.0_99/jre/lib/security') + end + end end describe 'incompatible OSes' do [ From 859bd59df8fc97a392e55cae2eae8c297ec4c149 Mon Sep 17 00:00:00 2001 From: Dennis Ploeger Date: Mon, 8 Oct 2018 16:46:55 +0200 Subject: [PATCH 09/12] Disabled oracle tests again. Only to be enabled, if the other configuration options match the current java download URL provided by Oracle. --- spec/acceptance/install_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/acceptance/install_spec.rb b/spec/acceptance/install_spec.rb index b19b3a67..47bde5cb 100644 --- a/spec/acceptance/install_spec.rb +++ b/spec/acceptance/install_spec.rb @@ -85,7 +85,7 @@ # change often. Look the parameters up from the Oracle download URLs at https://java.oracle.com and # enable the tests: -oracle_enabled = true +oracle_enabled = false oracle_version_major = "8" oracle_version_minor = "181" oracle_version_build = "13" From 0b0a63375722538c75800c820d34a016a93e47b9 Mon Sep 17 00:00:00 2001 From: Dennis Ploeger Date: Tue, 9 Oct 2018 07:43:35 +0200 Subject: [PATCH 10/12] Optimized code as recommended by Rubocop --- spec/acceptance/install_spec.rb | 20 ++++++++++---------- spec/defines/oracle_spec.rb | 30 ++++++++++++++++++------------ 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/spec/acceptance/install_spec.rb b/spec/acceptance/install_spec.rb index 47bde5cb..9c8cbc81 100644 --- a/spec/acceptance/install_spec.rb +++ b/spec/acceptance/install_spec.rb @@ -86,10 +86,10 @@ # enable the tests: oracle_enabled = false -oracle_version_major = "8" -oracle_version_minor = "181" -oracle_version_build = "13" -oracle_hash = "96a7b8442fe848ef90c96a2fad6ed6d1" +oracle_version_major = '8' +oracle_version_minor = '181' +oracle_version_build = '13' +oracle_hash = '96a7b8442fe848ef90c96a2fad6ed6d1' install_oracle_jre = < Date: Mon, 15 Oct 2018 10:26:01 +0200 Subject: [PATCH 11/12] Missed change while rebasing --- manifests/oracle.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/oracle.pp b/manifests/oracle.pp index 0325fd1b..61415853 100644 --- a/manifests/oracle.pp +++ b/manifests/oracle.pp @@ -322,7 +322,7 @@ proxy_type => $proxy_type, require => [ Package['unzip'], - Exec["Install Oracle java_se ${java_se} ${version}"] + Exec["Install Oracle java_se ${java_se} ${version} ${release_major} ${release_minor}"] ] } } From 7071741f5ebddf52997606eb03b85747df7d6799 Mon Sep 17 00:00:00 2001 From: Dennis Ploeger Date: Mon, 15 Oct 2018 15:39:07 +0200 Subject: [PATCH 12/12] Smaller fixes, possible RedHat fixes --- manifests/oracle.pp | 2 +- spec/acceptance/install_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/manifests/oracle.pp b/manifests/oracle.pp index 61415853..7a6fdc55 100644 --- a/manifests/oracle.pp +++ b/manifests/oracle.pp @@ -134,7 +134,7 @@ if $release_major =~ /(\d+)u(\d+)/ { # Required for CentOS systems where Java8 update number is >= 171 to ensure # the package is visible to Puppet - if $facts['os']['name'] == 'CentOS' and $2 >= '171' { + if $facts['os']['family'] == 'RedHat' and $2 >= '171' { $install_path = "${java_se}1.${1}.0_${2}-amd64" } else { $install_path = "${java_se}1.${1}.0_${2}" diff --git a/spec/acceptance/install_spec.rb b/spec/acceptance/install_spec.rb index 9c8cbc81..88915945 100644 --- a/spec/acceptance/install_spec.rb +++ b/spec/acceptance/install_spec.rb @@ -104,7 +104,7 @@ install_oracle_jdk = < '#{oracle_version_major}', version_major => '#{oracle_version_major}u#{oracle_version_minor}', version_minor => 'b#{oracle_version_build}', @@ -127,7 +127,7 @@ install_oracle_jdk_jce = < '#{oracle_version_major}', version_major => '#{oracle_version_major}u#{oracle_version_minor}', version_minor => 'b#{oracle_version_build}',