1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'manifests/install.pp', line 1
class ojdk7::install(
$type = 'x64',
$jdk_INSTALLDIR = '/usr/java/jdk1.7.0_71',
$fullVersion = 'jdk1.7.0_71',
$alternativesPriority = '17065'
){
case $::osfamily{
'RedHat': {
$installExtension = 'rpm'
$installerLocation = "/opt/jdk-7u71-linux-${type}.${installExtension}"
$installer = 'yum-installer'
exec { "yum-localinstall":
command => "/usr/bin/yum localinstall $installerLocation",
onlyif => "test !-f $jdk_INSTALLDIR/bin/java"
}
}
'CentOS': {
$installExtension = 'rpm'
$installerLocation = "/opt/jdk-7u71-linux-${type}.${installExtension}"
$installer = 'yum-installer'
exec { "yum-localinstall":
command => "/usr/bin/yum localinstall $installerLocation",
onlyif => "test !-f $jdk_INSTALLDIR/bin/java"
}
}
}
file { '/usr/java/latest':
ensure => link,
target => "${jdk_INSTALLDIR}/bin/java",
replace => false,
mode => '0755',
}
# java link to default
file { '/usr/java/default':
ensure => link,
target => '/usr/java/latest',
require => File['/usr/java/latest'],
replace => false,
mode => '0755',
}
exec { "default java alternatives ${fullVersion}":
command => "alternatives --install /usr/bin/java java ${jdk_INSTALLDIR}/bin/java ${alternativesPriority}",
require => File['/usr/java/default'],
unless => "alternatives --display java | /bin/grep ${fullVersion}",
path => '/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:',
logoutput => true,
}
# set the javac default
exec { "default javac alternatives ${fullVersion}":
command => "alternatives --install /usr/bin/javac javac ${jdk_INSTALLDIR}/bin/javac ${alternativesPriority}",
require => File['/usr/java/default'],
unless => "alternatives --display javac | /bin/grep ${fullVersion}",
path => '/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:',
logoutput => true,
}
# set the keytool default
exec { "default keytool alternatives ${fullVersion}":
command => "alternatives --install /usr/bin/keytool keytool ${jdk_INSTALLDIR}/bin/keytool ${alternativesPriority}",
require => File['/usr/java/default'],
unless => "alternatives --display keytool | /bin/grep ${fullVersion}",
path => '/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:',
logoutput => true,
}
}
|