bsupatch.pp 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. # == Define: wls::bsupatch
  2. #
  3. # installs bsu patch for weblogic
  4. #
  5. #
  6. # === Examples
  7. #
  8. # $jdkWls11gJDK = 'jdk1.7.0_09'
  9. # $wls11gVersion = "1036"
  10. #
  11. # case $operatingsystem {
  12. # centos, redhat, OracleLinux, Ubuntu, Debian: {
  13. # $osMdwHome = "/opt/oracle/wls/wls11g"
  14. # $osWlHome = "/opt/oracle/wls/wls11g/wlserver_10.3"
  15. # $user = "oracle"
  16. # $group = "dba"
  17. # }
  18. # windows: {
  19. # $osMdwHome = "c:/oracle/wls/wls11g"
  20. # $osWlHome = "c:/oracle/wls/wls11g/wlserver_10.3"
  21. # $user = "Administrator"
  22. # $group = "Administrators"
  23. # }
  24. # }
  25. #
  26. # wls::bsupatch{'p13573621':
  27. # mdwHome => $osMdwHome ,
  28. # wlHome => $osWlHome,
  29. # fullJDKName => $defaultFullJDK,
  30. # patchId => 'KZKQ',
  31. # patchFile => 'p13573621_1036_Generic.zip',
  32. # user => $user,
  33. # group => $group,
  34. # }
  35. ##
  36. define wls::bsupatch($mdwHome = undef,
  37. $wlHome = undef,
  38. $fullJDKName = undef,
  39. $patchId = undef,
  40. $patchFile = undef,
  41. $user = 'oracle',
  42. $group = 'dba',
  43. $downloadDir = '/install',
  44. $puppetDownloadMntPoint = undef,
  45. $remoteFile = true,
  46. ) {
  47. case $operatingsystem {
  48. CentOS, RedHat, OracleLinux, Ubuntu, Debian, SLES: {
  49. $execPath = "/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/java/${fullJDKName}/bin"
  50. $path = $downloadDir
  51. Exec { path => $execPath,
  52. user => $user,
  53. group => $group,
  54. logoutput => true,
  55. }
  56. File {
  57. ensure => present,
  58. mode => 0775,
  59. owner => $user,
  60. group => $group,
  61. backup => false,
  62. }
  63. }
  64. Solaris: {
  65. $execPath = '/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/jdk/${fullJDKName}/bin/amd64'
  66. $path = $downloadDir
  67. Exec { path => $execPath,
  68. user => $user,
  69. group => $group,
  70. logoutput => true,
  71. }
  72. File {
  73. ensure => present,
  74. mode => 0775,
  75. owner => $user,
  76. group => $group,
  77. backup => false,
  78. }
  79. }
  80. windows: {
  81. $execPath = "C:\\oracle\\${fullJDKName}\\bin;C:\\unxutils\\bin;C:\\unxutils\\usr\\local\\wbin;C:\\Windows\\system32;C:\\Windows"
  82. $checkCommand = "C:\\Windows\\System32\\cmd.exe /c"
  83. $path = $downloadDir
  84. Exec { path => $execPath,
  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. if ! defined(File["${mdwHome}/utils/bsu/cache_dir"]) {
  98. file { "${mdwHome}/utils/bsu/cache_dir":
  99. ensure => directory,
  100. recurse => false,
  101. }
  102. }
  103. if $remoteFile == true {
  104. # the patch used by the bsu
  105. file { "${path}/${patchFile}":
  106. source => "${mountPoint}/${patchFile}",
  107. require => File ["${mdwHome}/utils/bsu/cache_dir"],
  108. }
  109. }
  110. case $operatingsystem {
  111. CentOS, RedHat, OracleLinux, Ubuntu, Debian, SLES, Solaris: {
  112. if $remoteFile == true {
  113. exec { "extract ${patchFile}":
  114. command => "unzip -n ${path}/${patchFile} -d ${mdwHome}/utils/bsu/cache_dir",
  115. require => File ["${path}/${patchFile}"],
  116. creates => "${mdwHome}/utils/bsu/cache_dir/${patchId}.jar",
  117. }
  118. } else {
  119. exec { "extract ${patchFile}":
  120. command => "unzip -n ${puppetDownloadMntPoint}/${patchFile} -d ${mdwHome}/utils/bsu/cache_dir",
  121. creates => "${mdwHome}/utils/bsu/cache_dir/${patchId}.jar",
  122. }
  123. }
  124. bsu_patch{ $patchId:
  125. ensure => present,
  126. os_user => $user,
  127. middleware_home_dir => $mdwHome,
  128. weblogic_home_dir => $wlHome,
  129. jdk_home_dir => "/usr/java/${fullJDKName}",
  130. require => Exec["extract ${patchFile}"],
  131. }
  132. }
  133. windows: {
  134. exec {"icacls win patchfile ${title}":
  135. command => "${checkCommand} icacls ${mdwHome}/utils/bsu/cache_dir /T /C /grant Administrator:F Administrators:F",
  136. logoutput => false,
  137. require => File ["${mdwHome}/utils/bsu/cache_dir"],
  138. }
  139. if $remoteFile == true {
  140. exec { "extract ${patchFile} ${title}":
  141. command => "${checkCommand} unzip ${path}/${patchFile} -d ${mdwHome}/utils/bsu/cache_dir",
  142. creates => "${mdwHome}/utils/bsu/cache_dir/${patchId}.jar",
  143. require => [Exec["icacls win patchfile ${title}"],File["${path}/${patchFile}"]],
  144. }
  145. } else {
  146. exec { "extract ${patchFile} ${title}":
  147. command => "${checkCommand} unzip ${puppetDownloadMntPoint}/${patchFile} -d ${mdwHome}/utils/bsu/cache_dir",
  148. creates => "${mdwHome}/utils/bsu/cache_dir/${patchId}.jar",
  149. require => Exec["icacls win patchfile ${title}"],
  150. }
  151. }
  152. $bsuCommand = "-install -patchlist=${patchId} -prod_dir=${wlHome} -verbose"
  153. exec { "exec bsu win ${title}":
  154. command => "${checkCommand} bsu.cmd ${bsuCommand}",
  155. logoutput => true,
  156. require => Exec["extract ${patchFile} ${title}"],
  157. cwd => "${mdwHome}\\utils\\bsu",
  158. }
  159. }
  160. }
  161. }