opatchupgrade.pp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. # == Define: oradb::opatchupgrade
  2. #
  3. # upgrades oracle opatch
  4. #
  5. #
  6. # === Examples
  7. #
  8. # oradb::opatchupgrade{'112000_opatch_upgrade':
  9. # oracleHome => '/oracle/product/11.2/db',
  10. # patchFile => '112030',
  11. # csiNumber => '9999999',
  12. # supportId => 'me@mycompany.com',
  13. # opversion => '11.2.0.3.4',
  14. # user => 'oracle',
  15. # group => 'dba',
  16. # downloadDir => '/install',
  17. # require => Class['oradb::installdb'],
  18. # }
  19. #
  20. #
  21. define oradb::opatchupgrade( $oracleHome = undef,
  22. $patchFile = undef,
  23. $csiNumber = undef,
  24. $supportId = undef,
  25. $opversion = undef,
  26. $user = 'oracle',
  27. $group = 'dba',
  28. $downloadDir = '/install',
  29. $puppetDownloadMntPoint = undef,
  30. )
  31. {
  32. case $::kernel {
  33. Linux, SunOS: {
  34. $execPath = '/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:'
  35. $patchDir = "${oracleHome}/OPatch"
  36. Exec { path => $execPath,
  37. user => $user,
  38. group => $group,
  39. logoutput => true,
  40. }
  41. File { ensure => present,
  42. mode => 0775,
  43. owner => $user,
  44. group => $group,
  45. }
  46. }
  47. }
  48. # if a mount was not specified then get the install media from the puppet master
  49. if $puppetDownloadMntPoint == undef {
  50. $mountDir = "puppet:///modules/oradb"
  51. } else {
  52. $mountDir = $puppetDownloadMntPoint
  53. }
  54. # check the opatch version
  55. $installedVersion = opatch_version($oracleHome)
  56. if $installedVersion == $opversion {
  57. $continue = false
  58. } else {
  59. notify {"oradb::opatchupgrade ${installedVersion} installed - performing upgrade":}
  60. $continue = true
  61. }
  62. if ( $continue ) {
  63. if ! defined(File["${downloadDir}/${patchFile}"]) {
  64. file {"${downloadDir}/${patchFile}":
  65. ensure => present,
  66. path => "${downloadDir}/${patchFile}",
  67. source => "${mountDir}/${patchFile}",
  68. require => File[$downloadDir],
  69. mode => '0777',
  70. }
  71. }
  72. case $::kernel {
  73. Linux, SunOS: {
  74. file { "remove_old":
  75. ensure => absent,
  76. recurse => true,
  77. path => $patchDir,
  78. force => true,
  79. } ->
  80. exec { "extract opatch ${patchFile}":
  81. command => "unzip -n ${downloadDir}/${patchFile} -d ${oracleHome}",
  82. require => File ["${downloadDir}/${patchFile}"],
  83. }
  84. if $csiNumber != undef and supportId != undef {
  85. exec { "exec emocmrsp ${opversion}":
  86. cwd => $patchDir,
  87. command => "${patchDir}/ocm/bin/emocmrsp -repeater NONE ${csiNumber} ${supportId}",
  88. require => Exec["extract opatch ${patchFile}"],
  89. }
  90. }
  91. }
  92. default: {
  93. fail("Unrecognized operating system")
  94. }
  95. }
  96. }
  97. }