Merge branch 'preferences' of https://github.com/mediatemple/puppetlabs-java into mediatemple-preferences
Conflicts: CHANGELOG
This commit is contained in:
@@ -8,6 +8,9 @@ Brett Porter <brett@apache.org>
|
||||
Nathan R Valentine <nrvale0@gmail.com>
|
||||
* Add support for Ubuntu quantal and raring
|
||||
|
||||
Sharif Nassar <sharif@mediatemple.net>
|
||||
* Add support for Debian alternatives, and more than one JDK/JRE per platform.
|
||||
|
||||
2013-04-04 Reid Vandewiele <reid@puppetlabs.com> - 0.3.0
|
||||
* Refactor, introduce params pattern
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
name 'puppetlabs-java'
|
||||
version '0.3.0'
|
||||
version '0.4.0'
|
||||
source 'git://github.com/puppetlabs/puppetlabs-java'
|
||||
author 'puppetlabs'
|
||||
license 'Apache'
|
||||
|
||||
17
manifests/config.pp
Normal file
17
manifests/config.pp
Normal file
@@ -0,0 +1,17 @@
|
||||
# On Debian systems, if alternatives are set, manually assign them.
|
||||
class java::config ( ) {
|
||||
case $::osfamily {
|
||||
Debian: {
|
||||
if $java::use_java_alternative != undef and $java::use_java_alternative_path != undef {
|
||||
exec { 'update-java-alternatives':
|
||||
path => '/usr/bin:/usr/sbin:/bin:/sbin',
|
||||
command => "update-java-alternatives --set ${java::use_java_alternative} --jre",
|
||||
unless => "test /etc/alternatives/java -ef '${java::use_java_alternative_path}'",
|
||||
}
|
||||
}
|
||||
}
|
||||
default: {
|
||||
# Do nothing.
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,10 @@
|
||||
# Parameters:
|
||||
#
|
||||
# [*distribution*]
|
||||
# The java distribution to install. Can be one of "jdk" or "jre".
|
||||
# The java distribution to install. Can be one of "jdk" or "jre",
|
||||
# or other platform-specific options where there are multiple
|
||||
# implementations available (eg: OpenJDK vs Oracle JDK).
|
||||
#
|
||||
#
|
||||
# [*version*]
|
||||
# The version of java to install. By default, this module simply ensures
|
||||
@@ -15,6 +18,19 @@
|
||||
# The name of the java package. This is configurable in case a non-standard
|
||||
# java package is desired.
|
||||
#
|
||||
# [*java_alternative*]
|
||||
# The name of the java alternative to use on Debian systems.
|
||||
# "update-java-alternatives -l" will show which choices are available.
|
||||
# If you specify a particular package, you will almost always also
|
||||
# want to specify which java_alternative to choose. If you set
|
||||
# this, you also need to set the path below.
|
||||
#
|
||||
# [*java_alternative_path*]
|
||||
# The path to the "java" command on Debian systems. Since the
|
||||
# alternatives system makes it difficult to verify which
|
||||
# alternative is actually enabled, this is required to ensure the
|
||||
# correct JVM is enabled.
|
||||
#
|
||||
# Actions:
|
||||
#
|
||||
# Requires:
|
||||
@@ -25,19 +41,19 @@ class java(
|
||||
$distribution = 'jdk',
|
||||
$version = 'present',
|
||||
$package = undef,
|
||||
$java_alternative = undef,
|
||||
$java_alternative_path = undef
|
||||
) {
|
||||
include java::params
|
||||
|
||||
validate_re($version, 'present|installed|latest|^[._0-9a-zA-Z:-]+$')
|
||||
|
||||
case $distribution {
|
||||
default: { fail('distribution must be one of jdk, jre') }
|
||||
'jdk': {
|
||||
$default_package_name = $java::params::jdk_package
|
||||
}
|
||||
'jre': {
|
||||
$default_package_name = $java::params::jre_package
|
||||
}
|
||||
if has_key($java::params::java, $distribution) {
|
||||
$default_package_name = $java::params::java[$distribution]['package']
|
||||
$default_alternative = $java::params::java[$distribution]['alternative']
|
||||
$default_alternative_path = $java::params::java[$distribution]['alternative_path']
|
||||
} else {
|
||||
fail("Java distribution ${distribution} is not supported.")
|
||||
}
|
||||
|
||||
$use_java_package_name = $package ? {
|
||||
@@ -45,9 +61,34 @@ class java(
|
||||
undef => $default_package_name,
|
||||
}
|
||||
|
||||
## If $java_alternative is set, use that.
|
||||
## Elsif the DEFAULT package is being used, then use $default_alternative.
|
||||
## Else undef
|
||||
$use_java_alternative = $java_alternative ? {
|
||||
default => $java_alternative,
|
||||
undef => $use_java_package_name ? {
|
||||
$default_package_name => $default_alternative,
|
||||
default => undef,
|
||||
}
|
||||
}
|
||||
|
||||
## Same logic as $java_alternative above.
|
||||
$use_java_alternative_path = $java_alternative_path ? {
|
||||
default => $java_alternative_path,
|
||||
undef => $use_java_package_name ? {
|
||||
$default_package_name => $default_alternative_path,
|
||||
default => undef,
|
||||
}
|
||||
}
|
||||
|
||||
anchor { 'java::begin:': }
|
||||
->
|
||||
package { 'java':
|
||||
ensure => $version,
|
||||
name => $use_java_package_name,
|
||||
}
|
||||
->
|
||||
class { 'java::config': }
|
||||
-> anchor { 'java::end': }
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
# Class: java::params
|
||||
#
|
||||
# This class sets the value of two variables, jdk_package and jre_package,
|
||||
# appropriate for the client system in question.
|
||||
# This class builds a hash of JDK/JRE packages and (for Debian)
|
||||
# alternatives. For wheezy/precise, we provide Oracle JDK/JRE
|
||||
# options, even though those are not in the package repositories.
|
||||
#
|
||||
# For more info on how to package Oracle JDK/JRE, see the Debian wiki:
|
||||
# http://wiki.debian.org/JavaPackage
|
||||
#
|
||||
# Because the alternatives system makes it very difficult to tell
|
||||
# which Java alternative is enabled, we hard code the path to bin/java
|
||||
# for the config class to test if it is enabled.
|
||||
class java::params {
|
||||
|
||||
case $::osfamily {
|
||||
@@ -11,7 +18,11 @@ class java::params {
|
||||
case $::operatingsystem {
|
||||
default: { fail("unsupported os ${::operatingsystem}") }
|
||||
'RedHat', 'CentOS': {
|
||||
if (versioncmp($::operatingsystemrelease, '6.3') < 0) {
|
||||
if (versioncmp($::operatingsystemrelease, '5.0') < 0) {
|
||||
$jdk_package = 'java-1.6.0-sun-devel'
|
||||
$jre_package = 'java-1.6.0-sun'
|
||||
}
|
||||
elsif (versioncmp($::operatingsystemrelease, '6.3') < 0) {
|
||||
$jdk_package = 'java-1.6.0-openjdk-devel'
|
||||
$jre_package = 'java-1.6.0-openjdk'
|
||||
}
|
||||
@@ -25,28 +36,75 @@ class java::params {
|
||||
$jre_package = 'java'
|
||||
}
|
||||
}
|
||||
$java = {
|
||||
'jdk' => { 'package' => $jdk_package, },
|
||||
'jre' => { 'package' => $jre_package, },
|
||||
}
|
||||
}
|
||||
'Debian': {
|
||||
case $::lsbdistcodename {
|
||||
default: { fail("unsupported release ${::lsbdistcodename}") }
|
||||
'squeeze', 'lucid': {
|
||||
$jdk_package = 'openjdk-6-jdk'
|
||||
$jre_package = 'openjdk-6-jre-headless'
|
||||
'lenny', 'squeeze', 'lucid': {
|
||||
$java = {
|
||||
'jdk' => {
|
||||
'package' => 'openjdk-6-jdk',
|
||||
'alternative' => 'java-6-openjdk',
|
||||
'alternative_path' => '/usr/lib/jvm/java-6-openjdk/jre/bin/java',
|
||||
},
|
||||
'jre' => {
|
||||
'package' => 'openjdk-6-jre-headless',
|
||||
'alternative' => 'java-6-openjdk',
|
||||
'alternative_path' => '/usr/lib/jvm/java-6-openjdk/jre/bin/java',
|
||||
},
|
||||
'sun-jre' => {
|
||||
'package' => 'sun-java6-jre',
|
||||
'alternative' => 'java-6-sun',
|
||||
'alternative_path' => '/usr/lib/jvm/java-6-sun/jre/bin/java',
|
||||
},
|
||||
'sun-jdk' => {
|
||||
'package' => 'sun-java6-jdk',
|
||||
'alternative' => 'java-6-sun',
|
||||
'alternative_path' => '/usr/lib/jvm/java-6-sun/jre/bin/java',
|
||||
},
|
||||
}
|
||||
}
|
||||
'wheezy', 'precise','quantal','raring': {
|
||||
$jdk_package = 'openjdk-7-jdk'
|
||||
$jre_package = 'openjdk-7-jre-headless'
|
||||
$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",
|
||||
},
|
||||
'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",
|
||||
},
|
||||
'oracle-jre' => {
|
||||
'package' => 'oracle-j2re1.7',
|
||||
'alternative' => 'j2re1.7-oracle',
|
||||
'alternative_path' => '/usr/lib/jvm/j2re1.7-oracle/bin/java',
|
||||
},
|
||||
'oracle-jdk' => {
|
||||
'package' => 'oracle-j2sdk1.7',
|
||||
'alternative' => 'j2sdk1.7-oracle',
|
||||
'alternative_path' => '/usr/lib/jvm/j2sdk1.7-oracle/jre/bin/java',
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
'Solaris': {
|
||||
$jdk_package = 'developer/java/jdk-7'
|
||||
$jre_package = 'runtime/java/jre-7'
|
||||
$java = {
|
||||
'jdk' => { 'package' => 'developer/java/jdk-7', },
|
||||
'jre' => { 'package' => 'runtime/java/jre-7', },
|
||||
}
|
||||
}
|
||||
'Suse': {
|
||||
$jdk_package = 'java-1_6_0-ibm-devel'
|
||||
$jre_package = 'java-1_6_0-ibm'
|
||||
$java = {
|
||||
'jdk' => { 'package' => 'java-1_6_0-ibm-devel', },
|
||||
'jre' => { 'package' => 'java-1_6_0-ibm', },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,11 +21,46 @@ describe 'java', :type => :class do
|
||||
let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Centos', :operatingsystemrelease => '5.3'} }
|
||||
let(:params) { { 'package' => 'jdk' } }
|
||||
it { should contain_package('java').with_name('jdk') }
|
||||
it { should_not contain_exec('update-java-alternatives') }
|
||||
end
|
||||
|
||||
context 'select default for Centos 5.3' do
|
||||
let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Centos', :operatingsystemrelease => '5.3'} }
|
||||
it { should contain_package('java').with_name('java-1.6.0-openjdk-devel') }
|
||||
it { should_not contain_exec('update-java-alternatives') }
|
||||
end
|
||||
|
||||
context 'select default for Debian Wheezy' do
|
||||
let(:facts) { {:osfamily => 'Debian', :operatingsystem => 'Debian', :lsbdistcodename => 'wheezy', :operatingsystemrelease => '7.1', :architecture => 'amd64',} }
|
||||
it { should contain_package('java').with_name('openjdk-7-jdk') }
|
||||
it { should contain_exec('update-java-alternatives').with_command('update-java-alternatives --set java-1.7.0-openjdk-amd64 --jre') }
|
||||
end
|
||||
|
||||
context 'select Oracle JRE for Debian Wheezy' do
|
||||
let(:facts) { {:osfamily => 'Debian', :operatingsystem => 'Debian', :lsbdistcodename => 'wheezy', :operatingsystemrelease => '7.1', } }
|
||||
let(:params) { { 'distribution' => 'oracle-jre' } }
|
||||
it { should contain_package('java').with_name('oracle-j2re1.7') }
|
||||
it { should contain_exec('update-java-alternatives').with_command('update-java-alternatives --set j2re1.7-oracle --jre') }
|
||||
end
|
||||
|
||||
context 'select default for Debian Squeeze' do
|
||||
let(:facts) { {:osfamily => 'Debian', :operatingsystem => 'Debian', :lsbdistcodename => 'squeeze', :operatingsystemrelease => '6.0.5'} }
|
||||
it { should contain_package('java').with_name('openjdk-6-jdk') }
|
||||
it { should contain_exec('update-java-alternatives').with_command('update-java-alternatives --set java-6-openjdk --jre') }
|
||||
end
|
||||
|
||||
context 'select Oracle JRE for Debian Squeeze' do
|
||||
let(:facts) { {:osfamily => 'Debian', :operatingsystem => 'Debian', :lsbdistcodename => 'squeeze', :operatingsystemrelease => '6.0.5'} }
|
||||
let(:params) { { 'distribution' => 'sun-jre', } }
|
||||
it { should contain_package('java').with_name('sun-java6-jre') }
|
||||
it { should contain_exec('update-java-alternatives').with_command('update-java-alternatives --set java-6-sun --jre') }
|
||||
end
|
||||
|
||||
context 'select random alternative for Debian Wheezy' do
|
||||
let(:facts) { {:osfamily => 'Debian', :operatingsystem => 'Debian', :lsbdistcodename => 'wheezy', :operatingsystemrelease => '7.1'} }
|
||||
let(:params) { { 'java_alternative' => 'bananafish' } }
|
||||
it { should contain_package('java').with_name('openjdk-7-jdk') }
|
||||
it { should contain_exec('update-java-alternatives').with_command('update-java-alternatives --set bananafish --jre') }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user