Files
puppetlabs-java/manifests/config.pp
Nate Potter eb587a433e Change file resource to exec
This commit changes the way the JAVA_HOME variable is added to
/etc/environment from using a file resource to using an exec
resource. This way we can avoid resource conflicts with the
file.

Signed-off-by: Nate Potter <ntpttr@gmail.com>
2016-09-17 11:58:58 -07:00

88 lines
3.0 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 {
exec { 'java-home-environment':
path => '/bin',
user => 'root',
command => "echo JAVA_HOME=${$java::use_java_home} >> /etc/environment",
}
}
}
'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 {
exec { 'java-home-environment':
path => '/bin',
user => 'root',
command => "echo JAVA_HOME=${$java::use_java_home} >> /etc/environment",
}
}
}
'OpenBSD': {
if $java::use_java_home != undef {
exec { 'java-home-environment':
path => '/bin',
user => 'root',
command => "echo JAVA_HOME=${$java::use_java_home} >> /etc/environment",
}
}
}
'FreeBSD': {
if $java::use_java_home != undef {
exec { 'java-home-environment':
path => '/bin',
user => 'root',
command => "echo JAVA_HOME=${$java::use_java_home} >> /etc/environment",
}
}
}
'Suse': {
if $java::use_java_home != undef {
exec { 'java-home-environment':
path => '/bin',
user => 'root',
command => "echo JAVA_HOME=${$java::use_java_home} >> /etc/environment",
}
}
}
'Solaris': {
if $java::use_java_home != undef {
exec { 'java-home-environment':
path => '/bin',
user => 'root',
command => "echo JAVA_HOME=${$java::use_java_home} >> /etc/environment",
}
}
}
default: {
# Do nothing.
}
}
}