installwls.pp 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. # == Define: wls::installwls
  2. #
  3. # Downloads from file folder and install weblogic with a silent install on linux and windows servers
  4. #
  5. # === Examples
  6. #
  7. #
  8. # $jdkWls12cJDK = 'jdk1.7.0_25'
  9. # $wls12cVersion = "1212"
  10. #
  11. # $user = "oracle"
  12. # $group = "dba"
  13. # $osOracleHome = "/opt/wls"
  14. # $osMdwHome = "/opt/wls/Middleware11gR1"
  15. #
  16. # # set the defaults
  17. # Wls::Installwls {
  18. # version => $wls12cVersion,
  19. # fullJDKName => $jdkWls12cJDK,
  20. # oracleHome => $osOracleHome,
  21. # mdwHome => $osMdwHome,
  22. # user => $user,
  23. # group => $group,
  24. # }
  25. #
  26. #
  27. # # install
  28. # wls::installwls{'wls12c':
  29. # }
  30. #
  31. #
  32. define wls::installwls( $version = undef,
  33. $fullJDKName = undef,
  34. $oracleHome = undef,
  35. $mdwHome = undef,
  36. $createUser = true,
  37. $user = 'oracle',
  38. $group = 'dba',
  39. $downloadDir = '/install',
  40. $puppetDownloadMntPoint = undef,
  41. ) {
  42. $wls1212Parameter = "1212"
  43. $wlsFile1212 = "wls_121200.jar"
  44. $wls1211Parameter = "1211"
  45. $wlsFile1211 = "wls1211_generic.jar"
  46. $wls1036Parameter = "1036"
  47. $wlsFile1036 = "wls1036_generic.jar"
  48. $wlsFileDefault = $wlsFile1036
  49. case $operatingsystem {
  50. CentOS, RedHat, OracleLinux, Ubuntu, Debian, SLES: {
  51. $execPath = "/usr/java/${fullJDKName}/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:"
  52. $path = $downloadDir
  53. $beaHome = $mdwHome
  54. $oraInventory = "${oracleHome}/oraInventory"
  55. Exec { path => $execPath,
  56. user => $user,
  57. group => $group,
  58. logoutput => true,
  59. }
  60. File {
  61. ensure => present,
  62. mode => 0775,
  63. owner => $user,
  64. group => $group,
  65. }
  66. }
  67. Solaris: {
  68. $execPath = "/usr/jdk/${fullJDKName}/bin/amd64:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:"
  69. $path = $downloadDir
  70. $beaHome = $mdwHome
  71. $oraInventory = "${oracleHome}/oraInventory"
  72. Exec { path => $execPath,
  73. user => $user,
  74. group => $group,
  75. logoutput => true,
  76. }
  77. File {
  78. ensure => present,
  79. mode => 0775,
  80. owner => $user,
  81. group => $group,
  82. }
  83. }
  84. windows: {
  85. $path = $downloadDir
  86. $beaHome = $mdwHome
  87. $execPath = "C:\\oracle\\${fullJDKName}\\bin;C:\\unxutils\\bin;C:\\unxutils\\usr\\local\\wbin;C:\\Windows\\system32;C:\\Windows"
  88. $checkCommand = "C:\\Windows\\System32\\cmd.exe /c"
  89. Exec { path => $execPath,
  90. }
  91. File { ensure => present,
  92. mode => 0555,
  93. }
  94. }
  95. default: {
  96. fail("Unrecognized operating system")
  97. }
  98. }
  99. # check weblogic version like 12c
  100. if $version == undef {
  101. $wlsFile = $wlsFileDefault
  102. }
  103. elsif $version == $wls1211Parameter {
  104. $wlsFile = $wlsFile1211
  105. }
  106. elsif $version == $wls1212Parameter {
  107. $wlsFile = $wlsFile1212
  108. }
  109. elsif $version == $wls1036Parameter {
  110. $wlsFile = $wlsFile1036
  111. }
  112. else {
  113. $wlsFile = $wlsFileDefault
  114. }
  115. # check if the wls already exists
  116. $found = wls_exists($mdwHome)
  117. if $found == undef {
  118. $continue = true
  119. } else {
  120. if ( $found ) {
  121. $continue = false
  122. } else {
  123. notify {"wls::installwls ${title} ${mdwHome} does not exists":}
  124. $continue = true
  125. }
  126. }
  127. if ( $continue ) {
  128. if $puppetDownloadMntPoint == undef {
  129. $mountPoint = "puppet:///modules/wls/"
  130. } else {
  131. $mountPoint = $puppetDownloadMntPoint
  132. }
  133. wls::utils::defaultusersfolders{'create wls home':
  134. oracleHome => $oracleHome,
  135. oraInventory => $oraInventory,
  136. createUser => $createUser,
  137. user => $user,
  138. group => $group,
  139. downloadDir => $path,
  140. }
  141. # put weblogic generic jar
  142. file { "wls.jar ${version}":
  143. path => "${path}/${wlsFile}",
  144. ensure => file,
  145. source => "${mountPoint}/${wlsFile}",
  146. require => Wls::Utils::Defaultusersfolders['create wls home'],
  147. replace => false,
  148. backup => false,
  149. }
  150. if $version == $wls1212Parameter {
  151. wls::utils::orainst{'create wls oraInst':
  152. oraInventory => $oraInventory,
  153. group => $group,
  154. }
  155. # de xml used by the wls installer
  156. file { "silent.xml ${version}":
  157. path => "${path}/silent${version}.xml",
  158. ensure => present,
  159. replace => 'yes',
  160. content => template("wls/silent_${wls1212Parameter}.xml.erb"),
  161. require => [ Wls::Utils::Orainst ['create wls oraInst']],
  162. }
  163. $command = "-silent -responseFile ${path}/silent${version}.xml "
  164. case $operatingsystem {
  165. CentOS, RedHat, OracleLinux, Ubuntu, Debian, SLES: {
  166. exec { "install wls ${title}":
  167. command => "java -jar ${path}/${wlsFile} ${command} -invPtrLoc /etc/oraInst.loc -ignoreSysPrereqs",
  168. require => [Wls::Utils::Defaultusersfolders['create wls home'],File ["silent.xml ${version}"]],
  169. timeout => 0,
  170. }
  171. }
  172. Solaris: {
  173. exec { "install wls ${title}":
  174. command => "java -jar ${path}/${wlsFile} ${command} -invPtrLoc /var/opt/oraInst.loc -ignoreSysPrereqs",
  175. require => [Wls::Utils::Defaultusersfolders['create wls home'],File ["silent.xml ${version}"]],
  176. timeout => 0,
  177. }
  178. }
  179. windows: {
  180. exec {"icacls wls disk ${title}":
  181. command => "${checkCommand} icacls ${path}\\${wlsFile} /T /C /grant Administrator:F Administrators:F",
  182. logoutput => false,
  183. require => File["wls.jar ${version}"],
  184. }
  185. exec { "install wls ${title}":
  186. command => "${checkCommand} java -jar ${path}/${wlsFile} ${command} -ignoreSysPrereqs",
  187. logoutput => true,
  188. require => [Wls::Utils::Defaultusersfolders['create wls home'],Exec["icacls wls disk ${title}"],File ["silent.xml ${version}"]],
  189. timeout => 0,
  190. }
  191. }
  192. }
  193. }
  194. else {
  195. # de xml used by the wls installer
  196. file { "silent.xml ${version}":
  197. path => "${path}/silent${version}.xml",
  198. ensure => present,
  199. replace => 'yes',
  200. content => template("wls/silent.xml.erb"),
  201. require => Wls::Utils::Defaultusersfolders['create wls home'],
  202. }
  203. $javaCommand = "java -Xmx1024m -jar"
  204. # install weblogic
  205. case $operatingsystem {
  206. CentOS, RedHat, OracleLinux, Ubuntu, Debian, SLES: {
  207. exec { "installwls ${path}/${wlsFile}":
  208. command => "${javaCommand} ${path}/${wlsFile} -mode=silent -silent_xml=${path}/silent${version}.xml",
  209. environment => ["JAVA_VENDOR=Sun",
  210. "JAVA_HOME=/usr/java/${fullJDKName}"],
  211. logoutput => true,
  212. require => [Wls::Utils::Defaultusersfolders['create wls home'],File ["wls.jar ${version}"],File ["silent.xml ${version}"]],
  213. }
  214. }
  215. Solaris: {
  216. exec { "installwls ${path}/${wlsFile}":
  217. command => "${javaCommand} ${path}/${wlsFile} -mode=silent -silent_xml=${path}/silent${version}.xml",
  218. environment => ["JAVA_VENDOR=Sun",
  219. "JAVA_HOME=/usr/jdk/${fullJDKName}"],
  220. require => [Wls::Utils::Defaultusersfolders['create wls home'],File ["wls.jar ${version}"],File ["silent.xml ${version}"]],
  221. }
  222. }
  223. windows: {
  224. exec { "installwls ${path}/${wlsFile}":
  225. command => "${checkCommand} /c ${javaCommand} ${path}/${wlsFile} -mode=silent -silent_xml=${path}/silent${version}.xml",
  226. environment => ["JAVA_VENDOR=Sun",
  227. "JAVA_HOME=C:\\oracle\\${fullJDKName}"],
  228. require => [Wls::Utils::Defaultusersfolders['create wls home'],File ["wls.jar ${version}"],File ["silent.xml ${version}"]],
  229. }
  230. }
  231. }
  232. }
  233. }
  234. }