installasm.pp 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. # == Class: oradb::installasm
  2. #
  3. #
  4. define oradb::installasm(
  5. $version = undef,
  6. $file = undef,
  7. $gridType = 'HA_CONFIG',
  8. $gridBase = undef,
  9. $gridHome = undef,
  10. $oraInventoryDir = undef,
  11. $user = 'grid',
  12. $userBaseDir = '/home',
  13. $group = 'asmdba',
  14. $group_install = 'oinstall',
  15. $group_oper = 'asmoper',
  16. $group_asm = 'asmadmin',
  17. $sys_asm_password = 'Welcome01',
  18. $asm_monitor_password = 'Welcome01',
  19. $asm_diskgroup = 'DATA',
  20. $disk_discovery_string = undef,
  21. $disk_redundancy = 'NORMAL',
  22. $disks = undef,
  23. $downloadDir = '/install',
  24. $zipExtract = true,
  25. $puppetDownloadMntPoint = undef,
  26. $remoteFile = true,
  27. )
  28. {
  29. # check if the oracle software already exists
  30. $found = oracle_exists( $gridHome )
  31. if $found == undef {
  32. $continue = true
  33. } else {
  34. if ( $found ) {
  35. $continue = false
  36. } else {
  37. notify {"oradb::installasm ${gridHome} does not exists":}
  38. $continue = true
  39. }
  40. }
  41. if ( $continue ) {
  42. $execPath = "/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:"
  43. if $oraInventoryDir == undef {
  44. $oraInventory = "${gridBase}/oraInventory"
  45. } else {
  46. $oraInventory = "${oraInventoryDir}/oraInventory"
  47. }
  48. if $puppetDownloadMntPoint == undef {
  49. $mountPoint = "puppet:///modules/oradb/"
  50. } else {
  51. $mountPoint = $puppetDownloadMntPoint
  52. }
  53. oradb::utils::structure{"grid structure ${version}":
  54. oracle_base_home_dir => $gridBase,
  55. ora_inventory_dir => $oraInventory,
  56. os_user => $user,
  57. os_group => $group,
  58. os_group_install => $group_install,
  59. os_group_oper => $group_oper,
  60. download_dir => $downloadDir,
  61. log_output => true,
  62. user_base_dir => $userBaseDir,
  63. create_user => false,
  64. }
  65. if ( $zipExtract ) {
  66. # In $downloadDir, will Puppet extract the ZIP files or is this a pre-extracted directory structure.
  67. if $remoteFile == true {
  68. file { "${downloadDir}/${file}":
  69. ensure => present,
  70. source => "${mountPoint}/${file}",
  71. mode => '0775',
  72. owner => $user,
  73. group => $group,
  74. require => Oradb::Utils::Structure["grid structure ${version}"],
  75. before => Exec["extract ${downloadDir}/${file}"],
  76. }
  77. $source = $downloadDir
  78. } else {
  79. $source = $mountPoint
  80. }
  81. exec { "extract ${downloadDir}/${file}":
  82. command => "unzip -o ${source}/${file} -d ${downloadDir}/grid_${version}",
  83. timeout => 0,
  84. logoutput => false,
  85. path => $execPath,
  86. user => $user,
  87. group => $group,
  88. creates => "${downloadDir}/grid_${version}",
  89. require => Oradb::Utils::Structure["grid structure ${version}"],
  90. before => Exec["install oracle grid ${title}"],
  91. }
  92. }
  93. oradb::utils::orainst{"grid orainst ${version}":
  94. ora_inventory_dir => $oraInventory,
  95. os_group => $group_install,
  96. }
  97. if ! defined(File["${downloadDir}/grid_install_${version}.rsp"]) {
  98. file { "${downloadDir}/grid_install_${version}.rsp":
  99. ensure => present,
  100. content => template("oradb/grid_install_${version}.rsp.erb"),
  101. mode => '0775',
  102. owner => $user,
  103. group => $group,
  104. require => Oradb::Utils::Orainst["grid orainst ${version}"],
  105. }
  106. }
  107. exec { "install oracle grid ${title}":
  108. command => "/bin/sh -c 'unset DISPLAY;${downloadDir}/grid_${version}/grid/runInstaller -silent -waitforcompletion -ignoreSysPrereqs -ignorePrereq -responseFile ${downloadDir}/grid_install_${version}.rsp'",
  109. creates => $gridHome,
  110. timeout => 0,
  111. returns => [6,0],
  112. path => $execPath,
  113. user => $user,
  114. group => $group_install,
  115. logoutput => true,
  116. require => [Oradb::Utils::Orainst["grid orainst ${version}"],
  117. File["${downloadDir}/grid_install_${version}.rsp"]],
  118. }
  119. file { $gridHome:
  120. ensure => directory,
  121. recurse => false,
  122. replace => false,
  123. mode => '0775',
  124. owner => $user,
  125. group => $group_install,
  126. require => Exec["install oracle grid ${title}"],
  127. }
  128. if ! defined(File["${userBaseDir}/${user}/.bash_profile"]) {
  129. file { "${userBaseDir}/${user}/.bash_profile":
  130. ensure => present,
  131. content => template("oradb/grid_bash_profile.erb"),
  132. mode => '0775',
  133. owner => $user,
  134. group => $group,
  135. require => Oradb::Utils::Structure["grid structure ${version}"],
  136. }
  137. }
  138. exec { "run root.sh grid script ${title}":
  139. command => "${gridHome}/root.sh",
  140. user => 'root',
  141. group => 'root',
  142. path => $execPath,
  143. logoutput => true,
  144. require => Exec["install oracle grid ${title}"],
  145. }
  146. file { "${downloadDir}/cfgrsp.properties":
  147. ensure => present,
  148. content => template("oradb/grid_password.properties.erb"),
  149. mode => '0600',
  150. owner => $user,
  151. group => $group,
  152. require => Exec["run root.sh grid script ${title}"],
  153. }
  154. exec { "run configToolAllCommands grid tool ${title}":
  155. command => "${gridHome}/cfgtoollogs/configToolAllCommands RESPONSE_FILE=${downloadDir}/cfgrsp.properties",
  156. user => $user,
  157. group => $group_install,
  158. path => $execPath,
  159. provider => 'shell',
  160. cwd => "${gridHome}/cfgtoollogs",
  161. logoutput => true,
  162. require => [File["${downloadDir}/cfgrsp.properties"],
  163. Exec["run root.sh grid script ${title}"],
  164. Exec["install oracle grid ${title}"],
  165. ],
  166. }
  167. }
  168. }