Merge pull request #372 from carabasdaniel/master

[FM-8320] Remove Oracle download
This commit is contained in:
TP Honey
2019-07-29 11:02:29 +01:00
committed by GitHub
5 changed files with 145 additions and 563 deletions

View File

@@ -14,6 +14,7 @@ AllCops:
- "**/Rakefile"
- pkg/**/*
- spec/fixtures/**/*
- spec/**/*
- vendor/**/*
- "**/Puppetfile"
- "**/Vagrantfile"

View File

@@ -43,52 +43,14 @@ class { 'java' :
}
```
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::download` installs one or more versions of Java SE from a remote url. `java::download` depends on [puppet/archive](https://github.com/voxpupuli/puppet-archive).
To install Java to a non-default basedir (defaults: /usr/lib/jvm for Debian; /usr/java for RedHat):
```puppet
java::oracle { 'jdk6' :
java::download { 'jdk8' :
ensure => 'present',
version => '6',
java_se => 'jdk',
}
java::oracle { 'jdk8' :
ensure => 'present',
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',
}
```
To install Oracle Java to a non-default basedir (defaults: /usr/lib/jvm for Debian; /usr/java for RedHat):
```puppet
java::oracle { 'jdk8' :
ensure => 'present',
version_major => '8u101',
version_minor => 'b13',
java_se => 'jdk',
basedir => '/custom/java',
}
```
To ensure that a custom basedir is a directory before Oracle Java is installed (note: manage separately for custom ownership or perms):
```puppet
java::oracle { 'jdk8' :
ensure => 'present',
version_major => '8u101',
version_minor => 'b13',
java_se => 'jdk',
manage_basedir => true,
url => 'http://myjava.repository/java.tgz",
basedir => '/custom/java',
}
```

View File

@@ -1,18 +1,8 @@
# Defined Type java::oracle
# Defined Type java::download
#
# @summary
# Installs Oracle Java. By using this module you agree to the Oracle licensing
# agreement.
# Installs Java from a url location.
#
# Install one or more versions of Oracle Java.
#
# Uses the following to download the package and automatically accept
# 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/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz"
#```
#
# @param ensure
# Install or remove the package.
@@ -29,9 +19,6 @@
# @param java_se
# Type of Java Standard Edition to install, jdk or jre.
#
# @param oracle_url
# Official Oracle URL to download binaries from.
#
# @param proxy_server
# Specify a proxy server, with port number if needed. ie: https://example.com:8080. (passed to archive)
#
@@ -39,13 +26,7 @@
# Proxy server type (none|http|https|ftp). (passed to archive)
#
# @param url
# Full URL, including oracle_url, release_major, release_minor and package_name, to
# download the Oracle java_se installer. Originally present but not used, activated
# to workaround MODULES-5058.
#
# @param 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.
# Full URL
#
# @param jce
# Install Oracles Java Cryptographic Extensions into the JRE or JDK
@@ -72,17 +53,15 @@
# @param symlink_name
# The name for the optional symlink in the installation directory.
#
define java::oracle (
define java::download(
$ensure = 'present',
$version = '8',
$version_major = undef,
$version_minor = undef,
$java_se = 'jdk',
$oracle_url = 'http://download.oracle.com/otn-pub/java/jdk/',
$proxy_server = undef,
$proxy_type = undef,
$url = undef,
$url_hash = undef,
$jce = false,
$jce_url = undef,
$basedir = undef,
@@ -103,25 +82,17 @@ define java::oracle (
if $jce {
if $jce_url {
$jce_download = $jce_url
$cookie = undef
} else {
$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
}
$cookie = 'gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie'
fail('JCE URL must be specified')
}
}
# determine Oracle Java major and minor version, and installation path
# determine Java major and minor version, and installation path
if $version_major and $version_minor {
$label = $version_major
$release_major = $version_major
$release_minor = $version_minor
$release_hash = $url_hash
if $release_major =~ /(\d+)u(\d+)/ {
# Required for CentOS systems where Java8 update number is >= 171 to ensure
@@ -143,25 +114,21 @@ 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 = '8u201'
$release_minor = 'b09'
$install_path = "${java_se}1.8.0_201"
$release_hash = '42970487e3af4f5aa5bca3f542482c60'
}
default : {
$release_major = '8u201'
$release_minor = 'b09'
$install_path = "${java_se}1.8.0_201"
$release_hash = '42970487e3af4f5aa5bca3f542482c60'
}
}
}
@@ -235,7 +202,7 @@ define java::oracle (
# JaveSE 6 distributed in .bin format
# 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
# package name to use in destination directory for the installer
case $_package_type {
'bin' : {
$package_name = "${java_se}-${release_major}-${os}-${arch}.bin"
@@ -258,11 +225,8 @@ define java::oracle (
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}"
fail('Url must be specified')
}
# full path to the installer
@@ -292,7 +256,6 @@ define java::oracle (
archive { $destination :
ensure => present,
source => $source,
cookie => 'gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie',
extract_path => '/tmp',
cleanup => false,
creates => $creates_path,
@@ -339,7 +302,6 @@ define java::oracle (
}
archive { "/tmp/jce-${version}.zip":
source => $jce_download,
cookie => $cookie,
extract => true,
extract_path => $jce_path,
extract_flags => '-oj',
@@ -363,4 +325,4 @@ define java::oracle (
notice ("Action ${ensure} not supported.")
}
}
}
}

View File

@@ -0,0 +1,131 @@
require 'spec_helper'
url = 'http://download.oracle.com/otn-pub/java/jdk/8u201-b09/42970487e3af4f5aa5bca3f542482c60/jdk-8u201-linux-x64.tar.gz'
describe 'java::download', type: :define do
context 'with CentOS 64-bit' do
let(:facts) { { kernel: 'Linux', os: { family: 'RedHat', architecture: 'x86_64', name: 'CentOS', release: { full: '6.0' } } } }
context 'when passing URL to url parameter' do
let(:params) do
{
ensure: 'present',
version_major: '8u201',
version_minor: 'b09',
java_se: 'jdk',
url: $url,
}
end
let(:title) { 'jdk8' }
it {
is_expected.to contain_archive('/tmp/jdk-8u201-linux-x64.rpm')
}
end
context 'when no url provided' do
let(:params) do
{
ensure: 'present',
version_major: '8u201',
version_minor: 'b09',
java_se: 'jdk',
}
end
let(:title) { 'jdk8' }
it {
is_expected.to raise_error Puppet::Error
}
end
context 'when manage_symlink is set to true' do
let(:params) do
{
ensure: 'present',
version: '6',
java_se: 'jdk',
basedir: '/usr/java',
manage_symlink: true,
symlink_name: 'java_home',
url: $url,
}
end
let(:title) { 'jdk6' }
it { is_expected.to contain_file('/usr/java/java_home') }
end
end
context 'with Ubuntu 64-bit' do
let(:facts) { { kernel: 'Linux', os: { family: 'Debian', architecture: 'amd64', name: 'Ubuntu', release: { full: '16.04' } } } }
context 'when passing URL to url parameter' do
let(:params) { { ensure: 'present', version_major: '8u201', version_minor: 'b09', java_se: 'jdk', url: $url } }
let(:title) { 'jdk8' }
it { is_expected.to contain_archive('/tmp/jdk-8u201-linux-x64.tar.gz') }
end
end
describe 'incompatible OSes' do
[
{
kernel: 'Windows',
os: {
family: 'Windows',
name: 'Windows',
release: {
full: '8.1',
},
},
},
{
kernel: 'Darwin',
os: {
family: 'Darwin',
name: 'Darwin',
release: {
full: '13.3.0',
},
},
},
{
kernel: 'AIX',
os: {
family: 'AIX',
name: 'AIX',
release: {
full: '7100-02-00-000',
},
},
},
{
kernel: 'AIX',
os: {
family: 'AIX',
name: 'AIX',
release: {
full: '6100-07-04-1216',
},
},
},
{
kernel: 'AIX',
os: {
family: 'AIX',
name: 'AIX',
release: {
full: '5300-12-01-1016',
},
},
},
].each do |facts|
let(:facts) { facts }
let(:title) { 'jdk' }
it "is_expected.to fail on #{facts[:os][:name]} #{facts[:os][:release][:full]}" do
expect { catalogue }.to raise_error Puppet::Error, %r{unsupported platform}
end
end
end
end

View File

@@ -1,474 +0,0 @@
require 'spec_helper'
oracle_url = 'http://download.oracle.com/otn-pub/java/jdk/8u201-b09/42970487e3af4f5aa5bca3f542482c60/jdk-8u201-linux-x64.tar.gz'
describe 'java::oracle', type: :define do
context 'with CentOS 64-bit' do
let(:facts) { { kernel: 'Linux', os: { family: 'RedHat', architecture: 'x86_64', name: 'CentOS', release: { full: '6.0' } } } }
context 'when Oracle Java SE 6 JDK' do
let(:params) { { ensure: 'present', version: '6', java_se: 'jdk' } }
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 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
let(:params) { { ensure: 'present', version: '7', java_se: 'jdk' } }
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 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
let(:params) { { ensure: 'present', version: '8', java_se: 'jdk' } }
let(:title) { 'jdk8' }
it { is_expected.to contain_archive('/tmp/jdk-8u201-linux-x64.rpm') }
it { is_expected.to contain_exec('Install Oracle java_se jdk 8 8u201 b09').with_command('rpm --force -iv /tmp/jdk-8u201-linux-x64.rpm') }
it { is_expected.to contain_exec('Install Oracle java_se jdk 8 8u201 b09').that_requires('Archive[/tmp/jdk-8u201-linux-x64.rpm]') }
end
context 'when Oracle Java SE 6 JRE' do
let(:params) { { ensure: 'present', version: '6', java_se: 'jre' } }
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 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
let(:params) { { ensure: 'present', version: '7', java_se: 'jre' } }
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 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
let(:params) { { ensure: 'present', version: '8', java_se: 'jre' } }
let(:title) { 'jre8' }
it { is_expected.to contain_archive('/tmp/jre-8u201-linux-x64.rpm') }
it { is_expected.to contain_exec('Install Oracle java_se jre 8 8u201 b09').with_command('rpm --force -iv /tmp/jre-8u201-linux-x64.rpm') }
it { is_expected.to contain_exec('Install Oracle java_se jre 8 8u201 b09').that_requires('Archive[/tmp/jre-8u201-linux-x64.rpm]') }
end
context 'when passing URL to url parameter' do
let(:params) do
{
ensure: 'present',
version_major: '8u201',
version_minor: 'b09',
java_se: 'jdk',
url: 'http://download.oracle.com/otn-pub/java/jdk/8u201-b09/42970487e3af4f5aa5bca3f542482c60/jdk-8u201-linux-x64.rpm',
url_hash: 'ignored',
}
end
let(:title) { 'jdk8' }
it {
is_expected.to contain_archive('/tmp/jdk-8u201-linux-x64.rpm')
.with_source('http://download.oracle.com/otn-pub/java/jdk/8u201-b09/42970487e3af4f5aa5bca3f542482c60/jdk-8u201-linux-x64.rpm')
}
end
context 'when passing a hash to url_hash parameter' do
let(:params) do
{
ensure: 'present',
version_major: '8u201',
version_minor: 'b09',
java_se: 'jdk',
url_hash: '42970487e3af4f5aa5bca3f542482c60',
}
end
let(:title) { 'jdk8' }
it {
is_expected.to contain_archive('/tmp/jdk-8u201-linux-x64.rpm')
.with_source('http://download.oracle.com/otn-pub/java/jdk//8u201-b09/42970487e3af4f5aa5bca3f542482c60/jdk-8u201-linux-x64.rpm')
}
end
context 'when installing multiple versions' do
let(:params) do
{
ensure: 'present',
version_major: '8u201',
version_minor: 'b09',
java_se: 'jdk',
url_hash: '42970487e3af4f5aa5bca3f542482c60',
}
end
let(:title) { 'jdk8' }
let(:pre_condition) do
<<-EOL
java::oracle {
'jdk8121':
ensure => 'present',
version_major => '8u121',
version_minor => 'b13',
java_se => 'jdk',
url_hash => 'abcdef01234567890',
}
EOL
end
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
context 'when specifying package_type tar.gz and basedir' do
let(:params) do
{
ensure: 'present',
version: '6',
java_se: 'jdk',
basedir: '/usr/java',
package_type: 'tar.gz',
}
end
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 6u45 b06').with_command('tar -zxf /tmp/jdk-6u45-linux-x64.tar.gz -C /usr/java') }
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 'when manage_basedir is set to true' do
let(:params) do
{
ensure: 'present',
version: '6',
java_se: 'jdk',
basedir: '/usr/java',
manage_basedir: true,
}
end
let(:title) { 'jdk6' }
it { is_expected.to contain_file('/usr/java') }
end
context 'when manage_symlink is set to true' do
let(:params) do
{
ensure: 'present',
version: '6',
java_se: 'jdk',
basedir: '/usr/java',
manage_symlink: true,
symlink_name: 'java_home',
}
end
let(:title) { 'jdk6' }
it { is_expected.to contain_file('/usr/java/java_home') }
end
end
context 'when on CentOS 32-bit' do
let(:facts) { { kernel: 'Linux', os: { family: 'RedHat', architecture: 'i386', name: 'CentOS', release: { full: '6.6' } } } }
context 'when selecting Oracle Java SE 6 JDK on RedHat family, 32-bit' do
let(:params) { { ensure: 'present', version: '6', java_se: 'jdk' } }
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 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
let(:params) { { ensure: 'present', version: '7', java_se: 'jdk' } }
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 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
let(:params) { { ensure: 'present', version: '8', java_se: 'jdk' } }
let(:title) { 'jdk8' }
it { is_expected.to contain_archive('/tmp/jdk-8u201-linux-i586.rpm') }
it { is_expected.to contain_exec('Install Oracle java_se jdk 8 8u201 b09').with_command('rpm --force -iv /tmp/jdk-8u201-linux-i586.rpm') }
it { is_expected.to contain_exec('Install Oracle java_se jdk 8 8u201 b09').that_requires('Archive[/tmp/jdk-8u201-linux-i586.rpm]') }
end
context 'when selecting Oracle Java SE 6 JRE on RedHat family, 32-bit' do
let(:params) { { ensure: 'present', version: '6', java_se: 'jre' } }
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 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
let(:params) { { ensure: 'present', version: '7', java_se: 'jre' } }
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 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
let(:params) { { ensure: 'present', version: '8', java_se: 'jre' } }
let(:title) { 'jdk8' }
it { is_expected.to contain_archive('/tmp/jre-8u201-linux-i586.rpm') }
it { is_expected.to contain_exec('Install Oracle java_se jre 8 8u201 b09').with_command('rpm --force -iv /tmp/jre-8u201-linux-i586.rpm') }
it { is_expected.to contain_exec('Install Oracle java_se jre 8 8u201 b09').that_requires('Archive[/tmp/jre-8u201-linux-i586.rpm]') }
end
context 'when installing multiple versions' do
let(:params) do
{
ensure: 'present',
version_major: '8u201',
version_minor: 'b09',
java_se: 'jdk',
url_hash: '42970487e3af4f5aa5bca3f542482c60',
}
end
let(:title) { 'jdk8' }
let(:pre_condition) do
<<-EOL
java::oracle {
'jdk8121':
ensure => 'present',
version_major => '8u121',
version_minor => 'b13',
java_se => 'jdk',
url_hash => 'abcdef01234567890',
}
EOL
end
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
let(:facts) { { kernel: 'Linux', os: { family: 'Debian', architecture: 'amd64', name: 'Ubuntu', release: { full: '16.04' } } } }
context 'when Oracle Java SE 6 JDK' do
let(:params) { { ensure: 'present', version: '6', java_se: 'jdk' } }
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 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
let(:params) { { ensure: 'present', version: '7', java_se: 'jdk' } }
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 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
let(:params) { { ensure: 'present', version: '8', java_se: 'jdk' } }
let(:title) { 'jdk8' }
it { is_expected.to contain_archive('/tmp/jdk-8u201-linux-x64.tar.gz') }
it { is_expected.to contain_exec('Install Oracle java_se jdk 8 8u201 b09').with_command('tar -zxf /tmp/jdk-8u201-linux-x64.tar.gz -C /usr/lib/jvm') }
it { is_expected.to contain_exec('Install Oracle java_se jdk 8 8u201 b09').that_requires('Archive[/tmp/jdk-8u201-linux-x64.tar.gz]') }
end
context 'with Oracle Java SE 6 JRE' do
let(:params) { { ensure: 'present', version: '6', java_se: 'jre' } }
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 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
let(:params) { { ensure: 'present', version: '7', java_se: 'jre' } }
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 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
let(:params) { { ensure: 'present', version: '8', java_se: 'jre' } }
let(:title) { 'jre8' }
it { is_expected.to contain_archive('/tmp/jre-8u201-linux-x64.tar.gz') }
it { is_expected.to contain_exec('Install Oracle java_se jre 8 8u201 b09').with_command('tar -zxf /tmp/jre-8u201-linux-x64.tar.gz -C /usr/lib/jvm') }
it { is_expected.to contain_exec('Install Oracle java_se jre 8 8u201 b09').that_requires('Archive[/tmp/jre-8u201-linux-x64.tar.gz]') }
end
context 'when passing URL to url parameter' do
let(:params) { { ensure: 'present', version_major: '8u201', version_minor: 'b09', java_se: 'jdk', url: oracle_url.to_s } }
let(:title) { 'jdk8' }
it { is_expected.to contain_archive('/tmp/jdk-8u201-linux-x64.tar.gz') }
end
context 'when installing multiple versions' do
let(:params) do
{
ensure: 'present',
version_major: '8u201',
version_minor: 'b09',
java_se: 'jdk',
url_hash: '42970487e3af4f5aa5bca3f542482c60',
}
end
let(:title) { 'jdk8' }
let(:pre_condition) do
<<-EOL
java::oracle {
'jdk8121':
ensure => 'present',
version_major => '8u121',
version_minor => 'b13',
java_se => 'jdk',
url_hash => 'abcdef01234567890',
}
EOL
end
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
[
{
kernel: 'Windows',
os: {
family: 'Windows',
name: 'Windows',
release: {
full: '8.1',
},
},
},
{
kernel: 'Darwin',
os: {
family: 'Darwin',
name: 'Darwin',
release: {
full: '13.3.0',
},
},
},
{
kernel: 'AIX',
os: {
family: 'AIX',
name: 'AIX',
release: {
full: '7100-02-00-000',
},
},
},
{
kernel: 'AIX',
os: {
family: 'AIX',
name: 'AIX',
release: {
full: '6100-07-04-1216',
},
},
},
{
kernel: 'AIX',
os: {
family: 'AIX',
name: 'AIX',
release: {
full: '5300-12-01-1016',
},
},
},
].each do |facts|
let(:facts) { facts }
let(:title) { 'jdk' }
it "is_expected.to fail on #{facts[:os][:name]} #{facts[:os][:release][:full]}" do
expect { catalogue }.to raise_error Puppet::Error, %r{unsupported platform}
end
end
end
end