Merge branch 'master' into jce_link
This commit is contained in:
@@ -1,114 +1,95 @@
|
||||
# Defined Type java::oracle
|
||||
#
|
||||
# Description
|
||||
# Installs Oracle Java. By using this module you agree to the Oracle licensing
|
||||
# agreement.
|
||||
# @summary
|
||||
# Installs Oracle Java. By using this module you agree to the Oracle licensing
|
||||
# agreement.
|
||||
#
|
||||
# Install one or more versions of Oracle Java.
|
||||
#
|
||||
# uses the following to download the package and automatically accept
|
||||
# the licensing terms.
|
||||
# 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"
|
||||
#```
|
||||
#
|
||||
# Parameters
|
||||
# [*version*]
|
||||
# Version of Java to install, e.g. '7' or '8'. Default values for major and minor
|
||||
# versions will be used.
|
||||
# @param ensure
|
||||
# Install or remove the package.
|
||||
#
|
||||
# [*version_major*]
|
||||
# Major version which should be installed, e.g. '8u101'. Must be used together with
|
||||
# version_minor.
|
||||
# @param version
|
||||
# Version of Java to install, e.g. '7' or '8'. Default values for major and minor versions will be used.
|
||||
#
|
||||
# [*version_minor*]
|
||||
# Minor version which should be installed, e.g. 'b12'. Must be used together with
|
||||
# version_major.
|
||||
# @param version_major
|
||||
# Major version which should be installed, e.g. '8u101'. Must be used together with version_minor.
|
||||
#
|
||||
# [*java_se*]
|
||||
# Type of Java Standard Edition to install, jdk or jre.
|
||||
# @param version_minor
|
||||
# Minor version which should be installed, e.g. 'b12'. Must be used together with version_major.
|
||||
#
|
||||
# [*ensure*]
|
||||
# Install or remove the package.
|
||||
# @param java_se
|
||||
# Type of Java Standard Edition to install, jdk or jre.
|
||||
#
|
||||
# [*oracle_url*]
|
||||
# Official Oracle URL to download binaries from.
|
||||
# @param oracle_url
|
||||
# Official Oracle URL to download binaries from.
|
||||
#
|
||||
# [*proxy_server*]
|
||||
# Specify a proxy server, with port number if needed. ie: https://example.com:8080. (passed to archive)
|
||||
# @param 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)
|
||||
# @param proxy_type
|
||||
# Proxy server type (none|http|https|ftp). (passed to archive)
|
||||
#
|
||||
# Variables
|
||||
# [*release_major*]
|
||||
# Major version release number for java_se. Used to construct download URL.
|
||||
# @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.
|
||||
#
|
||||
# [*release_minor*]
|
||||
# Minor version release number for java_se. Used to construct download URL.
|
||||
# @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.
|
||||
#
|
||||
# [*install_path*]
|
||||
# Base install path for specified version of java_se. Used to determine if java_se
|
||||
# has already been installed.
|
||||
# @param jce
|
||||
# Install Oracles Java Cryptographic Extensions into the JRE or JDK
|
||||
#
|
||||
# [*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.
|
||||
# @param jce_url
|
||||
# Full URL to the jce zip file
|
||||
#
|
||||
# [*os*]
|
||||
# Oracle java_se OS type.
|
||||
# @param basedir
|
||||
# Directory under which the installation will occur. If not set, defaults to
|
||||
# /usr/lib/jvm for Debian and /usr/java for RedHat.
|
||||
#
|
||||
# [*destination*]
|
||||
# Destination directory to save java_se installer to. Usually /tmp on Linux and
|
||||
# C:\TEMP on Windows.
|
||||
# @param manage_basedir
|
||||
# Whether to manage the basedir directory. Defaults to false.
|
||||
# Note: /usr/lib/jvm is managed for Debian by default, separate from this parameter.
|
||||
#
|
||||
# [*creates_path*]
|
||||
# Fully qualified path to java_se after it is installed. Used to determine if
|
||||
# java_se is already installed.
|
||||
# @param 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.
|
||||
# Optional forced package types: rpm, rpmbin, tar.gz
|
||||
#
|
||||
# [*arch*]
|
||||
# Oracle java_se architecture type.
|
||||
# @param manage_symlink
|
||||
# Whether to manage a symlink that points to the installation directory. Defaults to false.
|
||||
#
|
||||
# [*package_name*]
|
||||
# Name of the java_se installation package to download from Oracle's website.
|
||||
#
|
||||
# [*install_command*]
|
||||
# Installation command used to install Oracle java_se. Installation commands
|
||||
# differ by package_type. 'bin' types are installed via shell command. 'rpmbin'
|
||||
# types have the rpms extracted and then forcibly installed. 'rpm' types are
|
||||
# forcibly installed.
|
||||
#
|
||||
# [*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
|
||||
#
|
||||
# [*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.
|
||||
#
|
||||
# [*jce*]
|
||||
# Install Oracles Java Cryptographic Extensions into the JRE or JDK
|
||||
#
|
||||
# [*jce_url*]
|
||||
# Full URL to the jce zip file
|
||||
#
|
||||
# ### Author
|
||||
# mike@marseglia.org
|
||||
# @param symlink_name
|
||||
# The name for the optional symlink in the installation directory.
|
||||
#
|
||||
define java::oracle (
|
||||
$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,
|
||||
$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,
|
||||
$manage_basedir = false,
|
||||
$package_type = undef,
|
||||
$manage_symlink = false,
|
||||
$symlink_name = undef,
|
||||
) {
|
||||
|
||||
# archive module is used to download the java package
|
||||
@@ -137,14 +118,16 @@ define java::oracle (
|
||||
# determine Oracle 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
|
||||
# the package is visible to Puppet
|
||||
if $facts['os']['family'] == 'RedHat' and $2 >= '171' {
|
||||
# the package is visible to Puppet. This is only true for installations that
|
||||
# don't use the tar.gz package type.
|
||||
if $facts['os']['family'] == 'RedHat' and $2 >= '171' and $package_type != 'tar.gz' {
|
||||
$install_path = "${java_se}1.${1}.0_${2}-amd64"
|
||||
} else {
|
||||
$install_path = "${java_se}1.${1}.0_${2}"
|
||||
@@ -154,6 +137,7 @@ define java::oracle (
|
||||
}
|
||||
} else {
|
||||
# use default versions if no specific major and minor version parameters are provided
|
||||
$label = $version
|
||||
case $version {
|
||||
'6' : {
|
||||
$release_major = '6u45'
|
||||
@@ -168,16 +152,16 @@ define java::oracle (
|
||||
$release_hash = undef
|
||||
}
|
||||
'8' : {
|
||||
$release_major = '8u192'
|
||||
$release_minor = 'b12'
|
||||
$install_path = "${java_se}1.8.0_192"
|
||||
$release_hash = '750e1c8617c5452694857ad95c3ee230'
|
||||
$release_major = '8u201'
|
||||
$release_minor = 'b09'
|
||||
$install_path = "${java_se}1.8.0_201"
|
||||
$release_hash = '42970487e3af4f5aa5bca3f542482c60'
|
||||
}
|
||||
default : {
|
||||
$release_major = '8u192'
|
||||
$release_minor = 'b12'
|
||||
$install_path = "${java_se}1.8.0_192"
|
||||
$release_hash = '750e1c8617c5452694857ad95c3ee230'
|
||||
$release_major = '8u201'
|
||||
$release_minor = 'b09'
|
||||
$install_path = "${java_se}1.8.0_201"
|
||||
$release_hash = '42970487e3af4f5aa5bca3f542482c60'
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -188,21 +172,36 @@ define java::oracle (
|
||||
case $facts['os']['family'] {
|
||||
'RedHat', 'Amazon' : {
|
||||
# Oracle Java 6 comes in a special rpmbin format
|
||||
if $version == '6' {
|
||||
$package_type = 'rpmbin'
|
||||
if $package_type {
|
||||
$_package_type = $package_type
|
||||
} elsif $version == '6' {
|
||||
$_package_type = 'rpmbin'
|
||||
} else {
|
||||
$package_type = 'rpm'
|
||||
$_package_type = 'rpm'
|
||||
}
|
||||
if $basedir {
|
||||
$_basedir = $basedir
|
||||
} else {
|
||||
$_basedir = '/usr/java'
|
||||
}
|
||||
$creates_path = "/usr/java/${install_path}"
|
||||
}
|
||||
'Debian' : {
|
||||
$package_type = 'tar.gz'
|
||||
$creates_path = "/usr/lib/jvm/${install_path}"
|
||||
if $package_type {
|
||||
$_package_type = $package_type
|
||||
} else {
|
||||
$_package_type = 'tar.gz'
|
||||
}
|
||||
if $basedir {
|
||||
$_basedir = $basedir
|
||||
} else {
|
||||
$_basedir = '/usr/lib/jvm'
|
||||
}
|
||||
}
|
||||
default : {
|
||||
fail ("unsupported platform ${$facts['os']['name']}") }
|
||||
}
|
||||
|
||||
$creates_path = "${_basedir}/${install_path}"
|
||||
$os = 'linux'
|
||||
$destination_dir = '/tmp/'
|
||||
}
|
||||
@@ -237,7 +236,7 @@ define java::oracle (
|
||||
# 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 {
|
||||
case $_package_type {
|
||||
'bin' : {
|
||||
$package_name = "${java_se}-${release_major}-${os}-${arch}.bin"
|
||||
}
|
||||
@@ -270,7 +269,7 @@ define java::oracle (
|
||||
$destination = "${destination_dir}${package_name}"
|
||||
notice ("Destination is ${destination}")
|
||||
|
||||
case $package_type {
|
||||
case $_package_type {
|
||||
'bin' : {
|
||||
$install_command = "sh ${destination}"
|
||||
}
|
||||
@@ -281,7 +280,7 @@ define java::oracle (
|
||||
$install_command = "rpm --force -iv ${destination}"
|
||||
}
|
||||
'tar.gz' : {
|
||||
$install_command = "tar -zxf ${destination} -C /usr/lib/jvm"
|
||||
$install_command = "tar -zxf ${destination} -C ${_basedir}"
|
||||
}
|
||||
default : {
|
||||
$install_command = "rpm -iv ${destination}"
|
||||
@@ -304,15 +303,20 @@ define java::oracle (
|
||||
'Linux' : {
|
||||
case $facts['os']['family'] {
|
||||
'Debian' : {
|
||||
ensure_resource('file', '/usr/lib/jvm', {
|
||||
ensure_resource('file', $_basedir, {
|
||||
ensure => directory,
|
||||
})
|
||||
$install_requires = [Archive[$destination], File['/usr/lib/jvm']]
|
||||
$install_requires = [Archive[$destination], File[$_basedir]]
|
||||
}
|
||||
default : {
|
||||
$install_requires = [Archive[$destination]]
|
||||
}
|
||||
}
|
||||
|
||||
if $manage_basedir {
|
||||
ensure_resource('file', $_basedir, {'ensure' => 'directory', 'before' => Exec["Install Oracle java_se ${java_se} ${version} ${release_major} ${release_minor}"]})
|
||||
}
|
||||
|
||||
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,
|
||||
@@ -320,6 +324,14 @@ define java::oracle (
|
||||
require => $install_requires
|
||||
}
|
||||
|
||||
if ($manage_symlink and $symlink_name) {
|
||||
file { "${_basedir}/${symlink_name}":
|
||||
ensure => link,
|
||||
target => $creates_path,
|
||||
require => Exec["Install Oracle java_se ${java_se} ${version} ${release_major} ${release_minor}"]
|
||||
}
|
||||
}
|
||||
|
||||
if ($jce and $jce_download != undef) {
|
||||
$jce_path = $java_se ? {
|
||||
'jre' => "${creates_path}/lib/security",
|
||||
@@ -351,5 +363,4 @@ define java::oracle (
|
||||
notice ("Action ${ensure} not supported.")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user