opatch.pp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. # == Define: oradb::opatch
  2. #
  3. # installs oracle patches for Oracle products
  4. #
  5. #
  6. # === Examples
  7. # oradb::opatch{'14727310_db_patch':
  8. # oracleProductHome => '/oracle/product/11.2/db',
  9. # patchId => '14727310',
  10. # patchFile => 'p14727310_112030_Linux-x86-64.zip',
  11. # user => 'oracle',
  12. # group => 'dba',
  13. # downloadDir => '/install',
  14. # ocmrf => 'true',
  15. # require => Class['oradb::installdb'],
  16. # }
  17. #
  18. #
  19. define oradb::opatch( $oracleProductHome = undef,
  20. $patchId = undef,
  21. $patchFile = undef,
  22. $user = 'oracle',
  23. $group = 'dba',
  24. $downloadDir = '/install',
  25. $ocmrf = false,
  26. $puppetDownloadMntPoint = undef,
  27. $remoteFile = true,
  28. )
  29. {
  30. case $::kernel {
  31. 'Linux', 'SunOS': {
  32. $execPath = '/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:'
  33. $path = $downloadDir
  34. Exec { path => $execPath,
  35. user => $user,
  36. group => $group,
  37. logoutput => true,
  38. }
  39. File {
  40. ensure => present,
  41. mode => 0775,
  42. owner => $user,
  43. group => $group,
  44. }
  45. }
  46. default: {
  47. fail("Unrecognized operating system")
  48. }
  49. }
  50. case $::kernel {
  51. 'Linux': {
  52. $oraInstPath = "/etc"
  53. }
  54. 'SunOS': {
  55. $oraInstPath = "/var/opt"
  56. }
  57. default: {
  58. fail("Unrecognized operating system ${::kernel}, please use it on a Linux host")
  59. }
  60. }
  61. if $puppetDownloadMntPoint == undef {
  62. $mountPoint = "puppet:///modules/oradb/"
  63. } else {
  64. $mountPoint = $puppetDownloadMntPoint
  65. }
  66. if $remoteFile == true {
  67. # the patch used by the opatch
  68. if ! defined(File["${path}/${patchFile}"]) {
  69. file { "${path}/${patchFile}":
  70. source => "${mountPoint}/${patchFile}",
  71. }
  72. }
  73. }
  74. case $::kernel {
  75. 'Linux', 'SunOS': {
  76. if $remoteFile == true {
  77. exec { "extract opatch ${patchFile} ${title}":
  78. command => "unzip -n ${path}/${patchFile} -d ${path}",
  79. require => File ["${path}/${patchFile}"],
  80. creates => "${path}/${patchId}",
  81. }
  82. } else {
  83. exec { "extract opatch ${patchFile} ${title}":
  84. command => "unzip -n ${mountPoint}/${patchFile} -d ${path}",
  85. creates => "${path}/${patchId}",
  86. }
  87. }
  88. if $ocmrf == true {
  89. db_opatch{ $patchId:
  90. ensure => present,
  91. os_user => $user,
  92. oracle_product_home_dir => $oracleProductHome,
  93. orainst_dir => $oraInstPath,
  94. extracted_patch_dir => "${path}/${patchId}",
  95. ocmrf_file => "${oracleProductHome}/OPatch/ocm.rsp",
  96. require => Exec["extract opatch ${patchFile} ${title}"],
  97. }
  98. } else {
  99. db_opatch{ $patchId:
  100. ensure => present,
  101. os_user => $user,
  102. oracle_product_home_dir => $oracleProductHome,
  103. orainst_dir => $oraInstPath,
  104. extracted_patch_dir => "${path}/${patchId}",
  105. require => Exec["extract opatch ${patchFile} ${title}"],
  106. }
  107. }
  108. }
  109. default: {
  110. fail("Unrecognized operating system")
  111. }
  112. }
  113. }