Merge pull request #89 from brdude/master
Add Java alternatives for RHEL based distros.
This commit is contained in:
@@ -46,7 +46,7 @@ class { 'java':
|
|||||||
|
|
||||||
* `java::params`: Builds a hash of jdk/jre packages for all compatible operating systems.
|
* `java::params`: Builds a hash of jdk/jre packages for all compatible operating systems.
|
||||||
|
|
||||||
* `java::config`: Configures the Java alternatives on Debian systems.
|
* `java::config`: Configures the Java alternatives.
|
||||||
|
|
||||||
###Parameters:
|
###Parameters:
|
||||||
|
|
||||||
@@ -58,9 +58,9 @@ The following parameters are available in the java module:
|
|||||||
|
|
||||||
* `package`: The name of the Java package. This is configurable in case you want to install a non-standard Java package. If not set, the module will install the appropriate package for the `distribution` parameter and target platform. If you set `package`, the `distribution` parameter will do nothing.
|
* `package`: The name of the Java package. This is configurable in case you want to install a non-standard Java package. If not set, the module will install the appropriate package for the `distribution` parameter and target platform. If you set `package`, the `distribution` parameter will do nothing.
|
||||||
|
|
||||||
* `java_alternative`: The name of the Java alternative to use on Debian systems. The command 'update-java-alternatives -l' will show which choices are available. If you specify a particular package, you will usually want to specify which Java alternative to use. If you set this parameter, you also need to set the `java_alternative_path`.
|
* `java_alternative`: The name of the Java alternative to use. The command 'update-java-alternatives -l' will show which choices are available. If you specify a particular package, you will usually want to specify which Java alternative to use. If you set this parameter, you also need to set the `java_alternative_path`.
|
||||||
|
|
||||||
* `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.
|
* `java_alternative_path`: The path to the 'java' command. Since the alternatives system makes it difficult to verify which alternative is actually enabled, this is required to ensure the correct JVM is enabled.
|
||||||
|
|
||||||
##Limitations
|
##Limitations
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,26 @@ class java::config ( ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
'RedHat': {
|
||||||
|
if $java::use_java_alternative != undef and $java::use_java_alternative_path != undef {
|
||||||
|
# The standard packages install alternatives, custom packages do not
|
||||||
|
# For the stanard packages java::params needs these added.
|
||||||
|
if $java::use_java_package_name != $java::default_package_name {
|
||||||
|
exec { 'create-java-alternatives':
|
||||||
|
path => '/usr/bin:/usr/sbin:/bin:/sbin',
|
||||||
|
command => "alternatives --install ${java::use_java_alternative} java ${$java::use_java_alternative_path} 20000" ,
|
||||||
|
unless => "alternatives --display java | grep -q ${$java::use_java_alternative_path}",
|
||||||
|
before => Exec['update-java-alternatives']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
exec { 'update-java-alternatives':
|
||||||
|
path => '/usr/bin:/usr/sbin',
|
||||||
|
command => "alternatives --set java ${$java::use_java_alternative_path}" ,
|
||||||
|
unless => "test /etc/alternatives/java -ef '${java::use_java_alternative_path}'",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
default: {
|
default: {
|
||||||
# Do nothing.
|
# Do nothing.
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ class java::params {
|
|||||||
$jre_package = 'java-1_6_0-ibm'
|
$jre_package = 'java-1_6_0-ibm'
|
||||||
}
|
}
|
||||||
|
|
||||||
"SLES": {
|
'SLES': {
|
||||||
case $::operatingsystemmajrelease{
|
case $::operatingsystemmajrelease{
|
||||||
default: {
|
default: {
|
||||||
$jdk_package = 'java-1_6_0-ibm-devel'
|
$jdk_package = 'java-1_6_0-ibm-devel'
|
||||||
|
|||||||
@@ -15,6 +15,15 @@ describe 'java', :type => :class do
|
|||||||
context 'select openjdk for Centos 6.2' do
|
context 'select openjdk for Centos 6.2' do
|
||||||
let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Centos', :operatingsystemrelease => '6.2'} }
|
let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Centos', :operatingsystemrelease => '6.2'} }
|
||||||
it { should contain_package('java').with_name('java-1.6.0-openjdk-devel') }
|
it { should contain_package('java').with_name('java-1.6.0-openjdk-devel') }
|
||||||
|
it { should_not contain_exec('update-java-alternatives') }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'select Oracle JRE with alternatives for Centos 6.3' do
|
||||||
|
let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Centos', :operatingsystemrelease => '6.3'} }
|
||||||
|
let(:params) { { 'package' => 'jre', 'java_alternative' => '/usr/bin/java', 'java_alternative_path' => '/usr/java/jre1.7.0_67/bin/java'} }
|
||||||
|
it { should contain_package('java').with_name('jre') }
|
||||||
|
it { should contain_exec('create-java-alternatives').with_command('alternatives --install /usr/bin/java java /usr/java/jre1.7.0_67/bin/java 20000') }
|
||||||
|
it { should contain_exec('update-java-alternatives').with_command('alternatives --set java /usr/java/jre1.7.0_67/bin/java') }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'select openjdk for Fedora' do
|
context 'select openjdk for Fedora' do
|
||||||
@@ -48,7 +57,7 @@ describe 'java', :type => :class do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'select Oracle JRE for Debian Wheezy' do
|
context 'select Oracle JRE for Debian Wheezy' do
|
||||||
let(:facts) { {:osfamily => 'Debian', :operatingsystem => 'Debian', :lsbdistcodename => 'wheezy', :operatingsystemrelease => '7.1', } }
|
let(:facts) { {:osfamily => 'Debian', :operatingsystem => 'Debian', :lsbdistcodename => 'wheezy', :operatingsystemrelease => '7.1', :architecture => 'amd64',} }
|
||||||
let(:params) { { 'distribution' => 'oracle-jre' } }
|
let(:params) { { 'distribution' => 'oracle-jre' } }
|
||||||
it { should contain_package('java').with_name('oracle-j2re1.7') }
|
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') }
|
it { should contain_exec('update-java-alternatives').with_command('update-java-alternatives --set j2re1.7-oracle --jre') }
|
||||||
@@ -61,14 +70,14 @@ describe 'java', :type => :class do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'select Oracle JRE for Debian Squeeze' do
|
context 'select Oracle JRE for Debian Squeeze' do
|
||||||
let(:facts) { {:osfamily => 'Debian', :operatingsystem => 'Debian', :lsbdistcodename => 'squeeze', :operatingsystemrelease => '6.0.5'} }
|
let(:facts) { {:osfamily => 'Debian', :operatingsystem => 'Debian', :lsbdistcodename => 'squeeze', :operatingsystemrelease => '6.0.5', :architecture => 'amd64',} }
|
||||||
let(:params) { { 'distribution' => 'sun-jre', } }
|
let(:params) { { 'distribution' => 'sun-jre', } }
|
||||||
it { should contain_package('java').with_name('sun-java6-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') }
|
it { should contain_exec('update-java-alternatives').with_command('update-java-alternatives --set java-6-sun --jre') }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'select random alternative for Debian Wheezy' do
|
context 'select random alternative for Debian Wheezy' do
|
||||||
let(:facts) { {:osfamily => 'Debian', :operatingsystem => 'Debian', :lsbdistcodename => 'wheezy', :operatingsystemrelease => '7.1'} }
|
let(:facts) { {:osfamily => 'Debian', :operatingsystem => 'Debian', :lsbdistcodename => 'wheezy', :operatingsystemrelease => '7.1', :architecture => 'amd64',} }
|
||||||
let(:params) { { 'java_alternative' => 'bananafish' } }
|
let(:params) { { 'java_alternative' => 'bananafish' } }
|
||||||
it { should contain_package('java').with_name('openjdk-7-jdk') }
|
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') }
|
it { should contain_exec('update-java-alternatives').with_command('update-java-alternatives --set bananafish --jre') }
|
||||||
|
|||||||
5
tests/alternative.pp
Normal file
5
tests/alternative.pp
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
class { 'java':
|
||||||
|
package => 'jdk-8u25-linux-x64',
|
||||||
|
java_alternative => 'jdk1.8.0_25',
|
||||||
|
java_alternative_path => '/usr/java/jdk1.8.0_25/jre/bin/java'
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user