Puppet Class: ojdk7::install

Defined in:
manifests/install.pp

Overview

Parameters:

  • type (Any) (defaults to: 'x64')
  • jdk_INSTALLDIR (Any) (defaults to: '/usr/java/jdk1.7.0_71')
  • fullVersion (Any) (defaults to: '1.7.0_71')
  • alternativesPriority (Any) (defaults to: '17065')


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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'manifests/install.pp', line 1

class ojdk7::install(
  $type                     = 'x64',
  $jdk_INSTALLDIR           = '/usr/java/jdk1.7.0_71',
  $fullVersion              = '1.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   => "ls -l /usr/java/jdk1.7.0_71/bin/java | grep -c java",
          provider => shell
        }
      }
    'CentOS': {
      $installExtension = 'rpm'
      $installerLocation  = "/opt/jdk-7u71-linux-${type}.${installExtension}"
      $installer           = 'yum-installer'
      exec { "yum-localinstall":
          command  => "/usr/bin/yum localinstall $installerLocation",
          onlyif   => "ls -l /usr/java/jdk1.7.0_71/bin/java | grep -c java",
          provider => shell
        }
      }
  }
    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,
      }
      exec { "default set java alternatives ${fullVersion}":
        command   => "alternatives --set java ${jdk_INSTALLDIR}/bin/java",
        require   => Exec["default java alternatives ${fullVersion}"],
        onlyif    => "alternatives --display java | grep -i \"link currently points to\" | grep -i -c ${fullVersion} | grep 0",
        path      => '/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:',
        provider  => shell,
        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,
      }
      exec { "default set javac alternatives ${fullVersion}":
        command   => "alternatives --set javac ${jdk_INSTALLDIR}/bin/javac",
        require   => Exec["default javac alternatives ${fullVersion}"],
        unless    => "alternatives --display javac | grep -i \"link currently points to\" | grep -i -c ${fullVersion} | grep 0",
        path      => '/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:',
        provider  => shell,
        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,
        }
      exec { "default set keytool alternatives ${fullVersion}":
        command   => "alternatives --set keytool ${jdk_INSTALLDIR}/bin/keytool",
        require   => Exec["default keytool alternatives ${fullVersion}"],
        unless    => "alternatives --display keytool | grep -i \"link currently points to\" | grep -i -c ${fullVersion} | grep 0",
        path      => '/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:',
        provider  => shell,
        logoutput => true,
        }
}