Add option to manage symlink

This commit is contained in:
Frank Wall
2019-02-25 14:28:11 +01:00
parent 3d8f80e4d9
commit 343ad7c468
2 changed files with 31 additions and 0 deletions

View File

@@ -99,6 +99,12 @@
# Whether to manage the basedir directory. Defaults to false. # Whether to manage the basedir directory. Defaults to false.
# Note: /usr/lib/jvm is managed for Debian by default, separate from this parameter. # Note: /usr/lib/jvm is managed for Debian by default, separate from this parameter.
# #
# [*manage_symlink*]
# Whether to manage a symlink that points to the installation directory. Defaults to false.
#
# [*symlink_name*]
# The name for the optional symlink in the installation directory.
#
# ### Author # ### Author
# mike@marseglia.org # mike@marseglia.org
# #
@@ -117,6 +123,8 @@ define java::oracle (
$basedir = undef, $basedir = undef,
$manage_basedir = false, $manage_basedir = false,
$package_type = undef, $package_type = undef,
$manage_symlink = false,
$symlink_name = undef,
) { ) {
# archive module is used to download the java package # archive module is used to download the java package
@@ -344,6 +352,14 @@ define java::oracle (
require => $install_requires 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) { if ($jce and $jce_download != undef) {
$jce_path = $java_se ? { $jce_path = $java_se ? {
'jre' => "${creates_path}/lib/security", 'jre' => "${creates_path}/lib/security",

View File

@@ -175,6 +175,21 @@ describe 'java::oracle', type: :define do
it { is_expected.to contain_file('/usr/java') } it { is_expected.to contain_file('/usr/java') }
end end
context 'when manage_symlink is set to true' do
let(:params) do
{
ensure: 'present',
version: '6',
java_se: 'jdk',
basedir: '/usr/java',
manage_symlink: true,
symlink_name: 'java_home',
}
end
let(:title) { 'jdk6' }
it { is_expected.to contain_file('/usr/java/java_home') }
end
end end
context 'when on CentOS 32-bit' do context 'when on CentOS 32-bit' do