Files
puppetlabs-java/manifests/config.pp
Nate Potter dd8f85a2fa (MODULES-2971) Add java_home to all operating systems
This patch adds the java_home variable to all supported
operating systemd, and gives the user the option to
set it themselves. It also updates config.pp to
ensure that the JAVA_HOME variable is set to
the desired java_home.
2016-07-16 21:32:26 -07:00

76 lines
2.6 KiB
Puppet

# 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} ${java::jre_flag}",
unless => "test /etc/alternatives/java -ef '${java::use_java_alternative_path}'",
}
}
if $java::use_java_home != undef {
file { '/etc/environment':
content => inline_template("JAVA_HOME=${$java::use_java_home}"),
}
}
}
'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 /usr/bin/java 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}'",
}
}
if $java::use_java_home != undef {
file { '/etc/environment':
content => inline_template("JAVA_HOME=${$java::use_java_home}"),
}
}
}
'OpenBSD': {
if $java::use_java_home != undef {
file { '/etc/environment':
content => inline_template("JAVA_HOME=${$java::use_java_home}"),
}
}
}
'FreeBSD': {
if $java::use_java_home != undef {
file { '/etc/environment':
content => inline_template("JAVA_HOME=${$java::use_java_home}"),
}
}
}
'Suse': {
if $java::use_java_home != undef {
file { '/etc/environment':
content => inline_template("JAVA_HOME=${$java::use_java_home}"),
}
}
}
'Solaris': {
if $java::use_java_home != undef {
file { '/etc/environment':
content => inline_template("JAVA_HOME=${$java::use_java_home}"),
}
}
}
default: {
# Do nothing.
}
}
}