opatch.pp 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. # == Define: wls::opatch
  2. #
  3. # installs oracle patches for Oracle products
  4. #
  5. #
  6. # === Examples
  7. #
  8. # $jdkWls11gJDK = 'jdk1.7.0_09'
  9. #
  10. # case $operatingsystem {
  11. # CentOS, RedHat, OracleLinux, Ubuntu, Debian: {
  12. # $oracleHome = "/opt/oracle/wls/wls11g/Oracle_OSB1"
  13. # $user = "oracle"
  14. # $group = "dba"
  15. # }
  16. # windows: {
  17. # $oracleHome = "c:/oracle/wls/wls11g/Oracle_OSB1"
  18. # $user = "Administrator"
  19. # $group = "Administrators"
  20. # }
  21. # }
  22. #
  23. # wls::opatch{'14389126_osb_patch':
  24. # oracleProductHome => $oracleHome ,
  25. # fullJDKName => $defaultFullJDK,
  26. # patchId => '14389126',
  27. # patchFile => 'p14389126_111160_Generic.zip',
  28. # user => $user,
  29. # group => $group,
  30. # }
  31. ##
  32. define wls::opatch( $oracleProductHome = undef,
  33. $fullJDKName = undef,
  34. $patchId = undef,
  35. $patchFile = undef,
  36. $user = 'oracle',
  37. $group = 'dba',
  38. $downloadDir = '/install',
  39. $puppetDownloadMntPoint = undef,
  40. ) {
  41. case $operatingsystem {
  42. CentOS, RedHat, OracleLinux, Ubuntu, Debian, SLES: {
  43. $execPath = '/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:'
  44. $path = $downloadDir
  45. $JAVA_HOME = "/usr/java/${fullJDKName}"
  46. Exec { path => $execPath,
  47. user => $user,
  48. group => $group,
  49. logoutput => true,
  50. }
  51. File {
  52. ensure => present,
  53. mode => 0775,
  54. owner => $user,
  55. group => $group,
  56. }
  57. }
  58. Solaris: {
  59. $execPath = '/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:'
  60. $path = $downloadDir
  61. $JAVA_HOME = "/usr/jdk/${fullJDKName}"
  62. Exec { path => $execPath,
  63. user => $user,
  64. group => $group,
  65. logoutput => true,
  66. }
  67. File {
  68. ensure => present,
  69. mode => 0775,
  70. owner => $user,
  71. group => $group,
  72. }
  73. }
  74. windows: {
  75. $execPath = "C:\\oracle\\${fullJDKName}\\bin;C:\\unxutils\\bin;C:\\unxutils\\usr\\local\\wbin;C:\\Windows\\system32;C:\\Windows"
  76. $checkCommand = "C:\\Windows\\System32\\cmd.exe /c"
  77. $path = $downloadDir
  78. $JAVA_HOME = "c:\\oracle\\${fullJDKName}"
  79. $oracleHomeWin = slash_replace($oracleProductHome)
  80. Exec { path => $execPath,
  81. logoutput => true,
  82. }
  83. File { ensure => present,
  84. mode => 0555,
  85. }
  86. }
  87. }
  88. # check if the opatch already is installed
  89. $found = opatch_exists($oracleProductHome,$patchId)
  90. if $found == undef {
  91. $continue = true
  92. } else {
  93. if ( $found ) {
  94. $continue = false
  95. } else {
  96. notify {"wls::opatch ${title} ${oracleProductHome} does not exists":}
  97. $continue = true
  98. }
  99. }
  100. if ( $continue ) {
  101. if $puppetDownloadMntPoint == undef {
  102. $mountPoint = "puppet:///modules/wls/"
  103. } else {
  104. $mountPoint = $puppetDownloadMntPoint
  105. }
  106. # the patch used by the opatch
  107. if ! defined(File["${path}/${patchFile}"]) {
  108. file { "${path}/${patchFile}":
  109. source => "${mountPoint}/${patchFile}",
  110. }
  111. }
  112. # opatch apply -silent -jdk %JDK_HOME% -jre %JDK_HOME%\jre -oh C:\oracle\MiddlewarePS5\Oracle_OSB1 C:\temp\14389126
  113. $oPatchCommand = "opatch apply -silent -jre"
  114. case $operatingsystem {
  115. CentOS, RedHat, OracleLinux, Ubuntu, Debian, SLES, Solaris: {
  116. exec { "extract opatch ${patchFile} ${title}":
  117. command => "unzip -n ${path}/${patchFile} -d ${path}",
  118. require => File ["${path}/${patchFile}"],
  119. creates => "${path}/${patchId}",
  120. }
  121. exec { "exec opatch ux ${title}":
  122. command => "${oracleProductHome}/OPatch/${oPatchCommand} ${JAVA_HOME}/jre -oh ${oracleProductHome} ${path}/${patchId}",
  123. require => Exec["extract opatch ${patchFile} ${title}"],
  124. }
  125. }
  126. windows: {
  127. exec { "extract opatch ${patchFile} ${title}":
  128. command => "jar.exe xf ${path}/${patchFile}",
  129. creates => "${path}/${patchId}",
  130. cwd => $path,
  131. require => File ["${path}/${patchFile}"],
  132. }
  133. #notify {"wls::opatch win exec ${title} ${checkCommand} ${oracleProductHome}/OPatch/${oPatchCommand} ${JAVA_HOME}\\jre -oh ${oracleHomeWin} ${path}/${patchId}":}
  134. exec { "exec opatch win ${title}":
  135. command => "${checkCommand} ${oracleProductHome}/OPatch/${oPatchCommand} ${JAVA_HOME}\\jre -oh ${oracleHomeWin} ${path}/${patchId}",
  136. logoutput => true,
  137. require => Exec["extract opatch ${patchFile} ${title}"],
  138. }
  139. }
  140. }
  141. }
  142. }