Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,28 @@ Valid options: 'present', 'installed', 'latest', or a string matching `/^[.+_0-9

The following parameters are available in `java::oracle`:

#####`ensure`
Install or remove the package.

######`version`
Version of Java Standard Edition (SE) to install. 6, 7 or 8.

#####`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.

#####`release_major`
Major version release number for java_se. Used to construct download URL.

#####`release_minor`
Minor version release number for java_se. Used to construct download URL.

#####`install_path`
Base install path for specified version of java_se. Used to determine if java_se
has already been installed.

###Facts

The java module includes a few facts to describe the version of Java installed on the system:
Expand Down
76 changes: 42 additions & 34 deletions manifests/oracle.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,18 @@
# "http://download.oracle.com/otn-pub/java/jdk/8u25-b17/jre-8u25-linux-x64.tar.gz"
#
# Parameters
# [*ensure*]
# Install or remove the package.
#
# [*version*]
# Version of Java to install
#
# [*java_se*]
# Type of Java Standard Edition to install, jdk or jre.
#
# [*ensure*]
# Install or remove the package.
#
# [*oracle_url*]
# Official Oracle URL to download binaries from.
#
# Variables
# [*release_major*]
# Major version release number for java_se. Used to construct download URL.
#
Expand All @@ -36,6 +35,8 @@
# Base install path for specified version of java_se. Used to determine if java_se
# has already been installed.
#
#
# Variables
# [*package_type*]
# Type of installation package for specified version of java_se. java_se 6 comes
# in a few installation package flavors and we need to account for them.
Expand Down Expand Up @@ -71,10 +72,13 @@
# mike@marseglia.org
#
define java::oracle (
$ensure = 'present',
$version = '8',
$java_se = 'jdk',
$oracle_url = 'http://download.oracle.com/otn-pub/java/jdk/',
$ensure = 'present',
$version = '8',
$java_se = 'jdk',
$oracle_url = 'http://download.oracle.com/otn-pub/java/jdk/',
$release_major = undef,
$release_minor = undef,
$install_path = undef,
) {

# archive module is used to download the java package
Expand All @@ -88,26 +92,30 @@
}

# determine oracle Java major and minor version, and installation path
case $version {
'6' : {
$release_major = '6u45'
$release_minor = 'b06'
$install_path = "${java_se}1.6.0_45"
}
'7' : {
$release_major = '7u80'
$release_minor = 'b15'
$install_path = "${java_se}1.7.0_80"
}
'8' : {
$release_major = '8u51'
$release_minor = 'b16'
$install_path = "${java_se}1.8.0_51"
}
default : {
$release_major = '8u51'
$release_minor = 'b16'
$install_path = "${java_se}1.8.0_51"
if $release_major or $release_minor or $install_path {
unless $release_major and $release_minor and $install_path {
fail('release_major, release_minor and install_path must be specified!')
}
$_release_major = $release_major
$_release_minor = $release_minor
$_install_path = $install_path
} else {
case $version {
'6' : {
$_release_major = '6u45'
$_release_minor = 'b06'
$_install_path = "${java_se}1.6.0_45"
}
'7' : {
$_release_major = '7u80'
$_release_minor = 'b15'
$_install_path = "${java_se}1.7.0_80"
}
default : {
$_release_major = '8u102'
$_release_minor = 'b14'
$_install_path = "${java_se}1.8.0_102"
}
}
}

Expand All @@ -129,7 +137,7 @@

$os = 'linux'
$destination_dir = '/tmp/'
$creates_path = "/usr/java/${install_path}"
$creates_path = "/usr/java/${_install_path}"
}
default : {
fail ( "unsupported platform ${::kernel}" ) }
Expand All @@ -153,16 +161,16 @@
# package name to download from Oracle's website
case $package_type {
'bin' : {
$package_name = "${java_se}-${release_major}-${os}-${arch}.bin"
$package_name = "${java_se}-${_release_major}-${os}-${arch}.bin"
}
'rpmbin' : {
$package_name = "${java_se}-${release_major}-${os}-${arch}-rpm.bin"
$package_name = "${java_se}-${_release_major}-${os}-${arch}-rpm.bin"
}
'rpm' : {
$package_name = "${java_se}-${release_major}-${os}-${arch}.rpm"
$package_name = "${java_se}-${_release_major}-${os}-${arch}.rpm"
}
default : {
$package_name = "${java_se}-${release_major}-${os}-${arch}.rpm"
$package_name = "${java_se}-${_release_major}-${os}-${arch}.rpm"
}
}

Expand All @@ -189,7 +197,7 @@
'present' : {
archive { $destination :
ensure => present,
source => "${oracle_url}${release_major}-${release_minor}/${package_name}",
source => "${oracle_url}${_release_major}-${_release_minor}/${package_name}",
cleanup => false,
extract_path => '/tmp',
cookie => 'gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie',
Expand Down
16 changes: 8 additions & 8 deletions spec/defines/oracle_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
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_archive('/tmp/jdk-8u102-linux-x64.rpm')}
it { is_expected.to contain_exec('Install Oracle java_se jdk 8').with_command('rpm --force -iv /tmp/jdk-8u102-linux-x64.rpm') }
end

context 'Oracle Java SE 6 JRE' do
Expand All @@ -42,8 +42,8 @@
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_archive('/tmp/jre-8u102-linux-x64.rpm')}
it { is_expected.to contain_exec('Install Oracle java_se jre 8').with_command('rpm --force -iv /tmp/jre-8u102-linux-x64.rpm') }
end

end
Expand All @@ -68,8 +68,8 @@
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_archive('/tmp/jdk-8u102-linux-i586.rpm')}
it { is_expected.to contain_exec('Install Oracle java_se jdk 8').with_command('rpm --force -iv /tmp/jdk-8u102-linux-i586.rpm') }
end

context 'select Oracle Java SE 6 JRE on RedHat family, 32-bit' do
Expand All @@ -89,8 +89,8 @@
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_archive('/tmp/jre-8u102-linux-i586.rpm')}
it { is_expected.to contain_exec('Install Oracle java_se jre 8').with_command('rpm --force -iv /tmp/jre-8u102-linux-i586.rpm') }
end
end

Expand Down