installwls.pp 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  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. $remoteFile = true,
  41. $javaParameters = '', # '-Dspace.detection=false'
  42. $puppetDownloadMntPoint = undef,
  43. ) {
  44. $wls1212Parameter = "1212"
  45. $wlsFile1212 = "wls_121200.jar"
  46. $wls1211Parameter = "1211"
  47. $wlsFile1211 = "wls1211_generic.jar"
  48. $wls1036Parameter = "1036"
  49. $wlsFile1036 = "wls1036_generic.jar"
  50. $wlsFileDefault = $wlsFile1036
  51. case $operatingsystem {
  52. CentOS, RedHat, OracleLinux, Ubuntu, Debian, SLES: {
  53. $execPath = "/usr/java/${fullJDKName}/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:"
  54. $path = $downloadDir
  55. $beaHome = $mdwHome
  56. $oraInventory = "${oracleHome}/oraInventory"
  57. $oraInstPath = "/etc"
  58. $java_statement = "java ${javaParameters}"
  59. Exec { path => $execPath,
  60. user => $user,
  61. group => $group,
  62. logoutput => true,
  63. }
  64. File {
  65. ensure => present,
  66. mode => 0775,
  67. owner => $user,
  68. group => $group,
  69. backup => false,
  70. }
  71. }
  72. Solaris: {
  73. $execPath = "/usr/jdk/${fullJDKName}/bin/amd64:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:"
  74. $path = $downloadDir
  75. $beaHome = $mdwHome
  76. $oraInventory = "${oracleHome}/oraInventory"
  77. $oraInstPath = "/var/opt"
  78. $java_statement = "java -d64 ${javaParameters}"
  79. Exec { path => $execPath,
  80. user => $user,
  81. group => $group,
  82. logoutput => true,
  83. }
  84. File {
  85. ensure => present,
  86. mode => 0775,
  87. owner => $user,
  88. group => $group,
  89. backup => false,
  90. }
  91. }
  92. windows: {
  93. $path = $downloadDir
  94. $beaHome = $mdwHome
  95. $execPath = "C:\\oracle\\${fullJDKName}\\bin;C:\\unxutils\\bin;C:\\unxutils\\usr\\local\\wbin;C:\\Windows\\system32;C:\\Windows"
  96. $checkCommand = "C:\\Windows\\System32\\cmd.exe /c"
  97. Exec { path => $execPath,
  98. }
  99. File { ensure => present,
  100. mode => 0555,
  101. backup => false,
  102. }
  103. }
  104. default: {
  105. fail("Unrecognized operating system")
  106. }
  107. }
  108. # check weblogic version like 12c
  109. if $version == undef {
  110. $wlsFile = $wlsFileDefault
  111. }
  112. elsif $version == $wls1211Parameter {
  113. $wlsFile = $wlsFile1211
  114. }
  115. elsif $version == $wls1212Parameter {
  116. $wlsFile = $wlsFile1212
  117. }
  118. elsif $version == $wls1036Parameter {
  119. $wlsFile = $wlsFile1036
  120. }
  121. else {
  122. $wlsFile = $wlsFileDefault
  123. }
  124. # check if the wls already exists
  125. $found = wls_exists($mdwHome)
  126. if $found == undef {
  127. $continue = true
  128. } else {
  129. if ( $found ) {
  130. $continue = false
  131. } else {
  132. notify {"wls::installwls ${title} ${mdwHome} does not exists":}
  133. $continue = true
  134. }
  135. }
  136. if ( $continue ) {
  137. if $puppetDownloadMntPoint == undef {
  138. $mountPoint = "puppet:///modules/wls/"
  139. } else {
  140. $mountPoint = $puppetDownloadMntPoint
  141. }
  142. wls::utils::defaultusersfolders{'create wls home':
  143. oracleHome => $oracleHome,
  144. oraInventory => $oraInventory,
  145. createUser => $createUser,
  146. user => $user,
  147. group => $group,
  148. downloadDir => $path,
  149. }
  150. # for performance reasons, download and install or just install it
  151. if $remoteFile == true {
  152. file { "wls.jar ${version}":
  153. path => "${path}/${wlsFile}",
  154. ensure => file,
  155. source => "${mountPoint}/${wlsFile}",
  156. require => Wls::Utils::Defaultusersfolders['create wls home'],
  157. replace => false,
  158. backup => false,
  159. }
  160. }
  161. if $version == $wls1212Parameter {
  162. wls::utils::orainst{'create wls oraInst':
  163. oraInventory => $oraInventory,
  164. group => $group,
  165. }
  166. # de xml used by the wls installer
  167. file { "silent.xml ${version}":
  168. path => "${path}/silent${version}.xml",
  169. ensure => present,
  170. replace => 'yes',
  171. content => template("wls/silent_${wls1212Parameter}.xml.erb"),
  172. require => [ Wls::Utils::Orainst ['create wls oraInst']],
  173. }
  174. $command = "-silent -responseFile ${path}/silent${version}.xml "
  175. case $operatingsystem {
  176. CentOS, RedHat, OracleLinux, Ubuntu, Debian, SLES, Solaris: {
  177. if $remoteFile == true {
  178. exec { "install wls ${title}":
  179. command => "${java_statement} -Xmx1024m -jar ${path}/${wlsFile} ${command} -invPtrLoc ${oraInstPath}/oraInst.loc -ignoreSysPrereqs",
  180. require => [Wls::Utils::Defaultusersfolders['create wls home'],
  181. File["silent.xml ${version}"],
  182. File["wls.jar ${version}"],
  183. ],
  184. timeout => 0,
  185. }
  186. } else {
  187. exec { "install wls ${title}":
  188. command => "${java_statement} -Xmx1024m -jar ${puppetDownloadMntPoint}/${wlsFile} ${command} -invPtrLoc ${oraInstPath}/oraInst.loc -ignoreSysPrereqs",
  189. require => [Wls::Utils::Defaultusersfolders['create wls home'],
  190. File ["silent.xml ${version}"],
  191. ],
  192. timeout => 0,
  193. }
  194. }
  195. }
  196. windows: {
  197. exec {"icacls wls disk ${title}":
  198. command => "${checkCommand} icacls ${path}\\${wlsFile} /T /C /grant Administrator:F Administrators:F",
  199. timeout => 0,
  200. logoutput => false,
  201. require => File["wls.jar ${version}"],
  202. }
  203. exec { "install wls ${title}":
  204. command => "${checkCommand} java -jar ${path}/${wlsFile} ${command} -ignoreSysPrereqs",
  205. logoutput => true,
  206. require => [Wls::Utils::Defaultusersfolders['create wls home'],
  207. Exec["icacls wls disk ${title}"],
  208. File ["silent.xml ${version}"]
  209. ],
  210. timeout => 0,
  211. }
  212. }
  213. }
  214. }
  215. else {
  216. # de xml used by the wls installer
  217. file { "silent.xml ${version}":
  218. path => "${path}/silent${version}.xml",
  219. ensure => present,
  220. replace => 'yes',
  221. content => template("wls/silent.xml.erb"),
  222. require => Wls::Utils::Defaultusersfolders['create wls home'],
  223. }
  224. # install weblogic
  225. case $operatingsystem {
  226. CentOS, RedHat, OracleLinux, Ubuntu, Debian, SLES, Solaris: {
  227. if $remoteFile == true {
  228. exec { "install wls ${title}":
  229. command => "${java_statement} -Xmx1024m -jar ${path}/${wlsFile} -mode=silent -silent_xml=${path}/silent${version}.xml",
  230. logoutput => true,
  231. timeout => 0,
  232. require => [Wls::Utils::Defaultusersfolders['create wls home'],
  233. File ["wls.jar ${version}"],
  234. File ["silent.xml ${version}"],
  235. ],
  236. }
  237. } else {
  238. exec { "install wls ${title}":
  239. command => "${java_statement} -Xmx1024m -jar ${puppetDownloadMntPoint}/${wlsFile} -mode=silent -silent_xml=${path}/silent${version}.xml",
  240. logoutput => true,
  241. timeout => 0,
  242. require => [Wls::Utils::Defaultusersfolders['create wls home'],
  243. File ["silent.xml ${version}"],
  244. ],
  245. }
  246. }
  247. }
  248. windows: {
  249. exec { "install wls ${title}":
  250. command => "${checkCommand} /c java -Xmx1024m -jar ${path}/${wlsFile} -mode=silent -silent_xml=${path}/silent${version}.xml",
  251. timeout => 0,
  252. environment => ["JAVA_VENDOR=Sun",
  253. "JAVA_HOME=C:\\oracle\\${fullJDKName}"],
  254. require => [Wls::Utils::Defaultusersfolders['create wls home'],File ["wls.jar ${version}"],File ["silent.xml ${version}"]],
  255. }
  256. }
  257. }
  258. }
  259. }
  260. }