opatch.pp 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. $remoteFile = true,
  41. ) {
  42. case $operatingsystem {
  43. CentOS, RedHat, OracleLinux, Ubuntu, Debian, SLES: {
  44. $execPath = '/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:'
  45. $path = $downloadDir
  46. $JAVA_HOME = "/usr/java/${fullJDKName}"
  47. Exec { path => $execPath,
  48. user => $user,
  49. group => $group,
  50. logoutput => true,
  51. }
  52. File {
  53. ensure => present,
  54. mode => 0775,
  55. owner => $user,
  56. group => $group,
  57. backup => false,
  58. }
  59. }
  60. Solaris: {
  61. $execPath = '/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:'
  62. $path = $downloadDir
  63. $JAVA_HOME = "/usr/jdk/${fullJDKName}"
  64. Exec { path => $execPath,
  65. user => $user,
  66. group => $group,
  67. logoutput => true,
  68. }
  69. File {
  70. ensure => present,
  71. mode => 0775,
  72. owner => $user,
  73. group => $group,
  74. backup => false,
  75. }
  76. }
  77. windows: {
  78. $execPath = "C:\\oracle\\${fullJDKName}\\bin;C:\\unxutils\\bin;C:\\unxutils\\usr\\local\\wbin;C:\\Windows\\system32;C:\\Windows"
  79. $checkCommand = "C:\\Windows\\System32\\cmd.exe /c"
  80. $path = $downloadDir
  81. $JAVA_HOME = "c:\\oracle\\${fullJDKName}"
  82. $oracleHomeWin = slash_replace($oracleProductHome)
  83. Exec { path => $execPath,
  84. logoutput => true,
  85. }
  86. File { ensure => present,
  87. mode => 0555,
  88. backup => false,
  89. }
  90. }
  91. }
  92. if $puppetDownloadMntPoint == undef {
  93. $mountPoint = "puppet:///modules/wls/"
  94. } else {
  95. $mountPoint = $puppetDownloadMntPoint
  96. }
  97. # the patch used by the opatch
  98. if $remoteFile == true {
  99. file { "${path}/${patchFile}":
  100. source => "${mountPoint}/${patchFile}",
  101. }
  102. }
  103. case $operatingsystem {
  104. CentOS, RedHat, OracleLinux, Ubuntu, Debian, SLES, Solaris: {
  105. if $remoteFile == true {
  106. exec { "extract opatch ${patchFile} ${title}":
  107. command => "unzip -n ${path}/${patchFile} -d ${path}",
  108. require => File ["${path}/${patchFile}"],
  109. creates => "${path}/${patchId}",
  110. }
  111. } else {
  112. exec { "extract opatch ${patchFile} ${title}":
  113. command => "unzip -n ${puppetDownloadMntPoint}/${patchFile} -d ${path}",
  114. creates => "${path}/${patchId}",
  115. }
  116. }
  117. case $::kernel {
  118. 'Linux': {
  119. $oraInstPath = "/etc"
  120. }
  121. 'SunOS': {
  122. $oraInstPath = "/var/opt"
  123. }
  124. default: {
  125. fail("Unrecognized operating system ${::kernel}, please use it on a Linux host")
  126. }
  127. }
  128. opatch{ $patchId:
  129. ensure => present,
  130. os_user => $user,
  131. oracle_product_home_dir => $oracleProductHome,
  132. orainst_dir => $oraInstPath,
  133. jdk_home_dir => $JAVA_HOME,
  134. extracted_patch_dir => "${path}/${patchId}",
  135. require => Exec["extract opatch ${patchFile} ${title}"],
  136. }
  137. }
  138. windows: {
  139. # opatch apply -silent -jdk %JDK_HOME% -jre %JDK_HOME%\jre -oh C:\oracle\MiddlewarePS5\Oracle_OSB1 C:\temp\14389126
  140. $oPatchCommand = "opatch apply -silent -jre"
  141. if $remoteFile == true {
  142. exec { "extract opatch ${patchFile} ${title}":
  143. command => "jar.exe xf ${path}/${patchFile}",
  144. creates => "${path}/${patchId}",
  145. cwd => $path,
  146. require => File ["${path}/${patchFile}"],
  147. }
  148. } else {
  149. exec { "extract opatch ${patchFile} ${title}":
  150. command => "jar.exe xf ${puppetDownloadMntPoint}/${patchFile}",
  151. creates => "${path}/${patchId}",
  152. cwd => $path,
  153. }
  154. }
  155. #notify {"wls::opatch win exec ${title} ${checkCommand} ${oracleProductHome}/OPatch/${oPatchCommand} ${JAVA_HOME}\\jre -oh ${oracleHomeWin} ${path}/${patchId}":}
  156. exec { "exec opatch win ${title}":
  157. command => "${checkCommand} ${oracleProductHome}/OPatch/${oPatchCommand} ${JAVA_HOME}\\jre -oh ${oracleHomeWin} ${path}/${patchId}",
  158. logoutput => true,
  159. require => Exec["extract opatch ${patchFile} ${title}"],
  160. }
  161. }
  162. }
  163. }