wlstexec.pp 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. # == Define: wls::wlstexec
  2. #
  3. # generic wlst script
  4. #
  5. # pass on the weblogic username or password
  6. # or provide userConfigFile and userKeyFile file locations
  7. #
  8. # === Examples
  9. #
  10. # case $operatingsystem {
  11. # centos, redhat, OracleLinux, Ubuntu, debian: {
  12. # $osMdwHome = "/opt/oracle/wls/wls11g"
  13. # $osWlHome = "/opt/oracle/wls/wls11g/wlserver_10.3"
  14. # $osDomainPath = "/opt/oracle/wls/wls11g/admin"
  15. # $user = "oracle"
  16. # $group = "dba"
  17. # }
  18. # windows: {
  19. # $osMdwHome = "c:/oracle/wls/wls11g"
  20. # $osWlHome = "c:/oracle/wls/wls11g/wlserver_10.3"
  21. # $osDomainPath = "c:/oracle/wls/wls11g/admin"
  22. # $user = "Administrator"
  23. # $group = "Administrators"
  24. # $serviceName = "C_oracle_wls_wls11g_wlserver_10.3"
  25. # }
  26. # }
  27. #
  28. # # default parameters for the wlst scripts
  29. # Wls::Wlstexec {
  30. # wlsDomain => "${osDomainPath}/osbDomain",
  31. # wlHome => $osWlHome,
  32. # fullJDKName => $jdkWls11gJDK,
  33. # user => $user,
  34. # group => $group,
  35. # address => "localhost",
  36. # wlsUser => "weblogic",
  37. # password => "weblogic1",
  38. # port => "5556",
  39. # }
  40. #
  41. # # create jdbc datasource for osb_server1
  42. # wls::wlstexec {
  43. #
  44. # 'createJdbcDatasourceHr':
  45. # wlstype => "jdbc",
  46. # wlsObjectName => "hrDS",
  47. # script => 'createJdbcDatasource.py',
  48. # params => ["dsName = 'hrDS'",
  49. # "jdbcDatasourceTargets = 'AdminServer,osb_server1'",
  50. # "dsJNDIName = 'jdbc/hrDS'",
  51. # "dsDriverName = 'oracle.jdbc.xa.client.OracleXADataSource'",
  52. # "dsURL = 'jdbc:oracle:thin:@master.alfa.local:1521/XE'",
  53. # "dsUserName = 'hr'",
  54. # "dsPassword = 'hr'",
  55. # "datasourceTargetType = 'Server'",
  56. # "globalTransactionsProtocol = 'xxxx'"
  57. # ],
  58. # }
  59. #
  60. #
  61. define wls::wlstexec ($version = '1111',
  62. $wlsDomain = undef,
  63. $wlstype = undef,
  64. $wlsObjectName = undef,
  65. $wlHome = undef,
  66. $fullJDKName = undef,
  67. $script = undef,
  68. $address = "localhost",
  69. $port = '7001',
  70. $wlsUser = undef,
  71. $password = undef,
  72. $userConfigFile = undef,
  73. $userKeyFile = undef,
  74. $user = 'oracle',
  75. $group = 'dba',
  76. $params = undef,
  77. $downloadDir = '/install',
  78. $logOutput = false,
  79. ) {
  80. # if these params are empty always continue
  81. if $wlsDomain == undef or $wlstype == undef or wlsObjectName == undef {
  82. $continue = true
  83. } else {
  84. # check if the object already exists on the weblogic domain
  85. $found = artifact_exists($wlsDomain ,$wlstype,$wlsObjectName ,$version)
  86. if $found == undef {
  87. $continue = true
  88. notify {"wls::wlstexec ${title} ${version} continue true cause nill":}
  89. } else {
  90. if ( $found ) {
  91. $continue = false
  92. } else {
  93. notify {"wls::wlstexec ${title} ${version} continue true cause not exists":}
  94. $continue = true
  95. }
  96. }
  97. }
  98. # use userConfigStore for the connect
  99. if $password == undef {
  100. $useStoreConfig = true
  101. } else {
  102. $useStoreConfig = false
  103. }
  104. if ( $continue ) {
  105. $javaCommand = "java -Dweblogic.security.SSL.ignoreHostnameVerification=true weblogic.WLST -skipWLSModuleScanning "
  106. case $operatingsystem {
  107. CentOS, RedHat, OracleLinux, Ubuntu, Debian, SLES: {
  108. $execPath = "/usr/java/${fullJDKName}/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:"
  109. $path = $downloadDir
  110. $JAVA_HOME = "/usr/java/${fullJDKName}"
  111. Exec { path => $execPath,
  112. user => $user,
  113. group => $group,
  114. logoutput => $logOutput,
  115. }
  116. File {
  117. ensure => present,
  118. replace => 'yes',
  119. mode => 0555,
  120. owner => $user,
  121. group => $group,
  122. }
  123. }
  124. Solaris: {
  125. $execPath = "/usr/jdk/${fullJDKName}/bin/amd64:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:"
  126. $path = $downloadDir
  127. $JAVA_HOME = "/usr/jdk/${fullJDKName}"
  128. Exec { path => $execPath,
  129. user => $user,
  130. group => $group,
  131. logoutput => $logOutput,
  132. }
  133. File {
  134. ensure => present,
  135. replace => 'yes',
  136. mode => 0775,
  137. owner => $user,
  138. group => $group,
  139. }
  140. }
  141. windows: {
  142. $execPath = "C:\\oracle\\${fullJDKName}\\bin;C:\\unxutils\\bin;C:\\unxutils\\usr\\local\\wbin;C:\\Windows\\system32;C:\\Windows"
  143. $path = $downloadDir
  144. $JAVA_HOME = "c:\\oracle\\${fullJDKName}"
  145. Exec { path => $execPath,
  146. logoutput => $logOutput,
  147. }
  148. File { ensure => present,
  149. replace => 'yes',
  150. mode => 0777,
  151. }
  152. }
  153. }
  154. # the py script used by the wlst
  155. file { "${path}/${title}${script}":
  156. path => "${path}/${title}${script}",
  157. content => template("wls/wlst/${script}.erb"),
  158. }
  159. case $operatingsystem {
  160. CentOS, RedHat, OracleLinux, Ubuntu, Debian, SLES, Solaris: {
  161. exec { "execwlst ${title}${script}":
  162. command => "${javaCommand} ${path}/${title}${script}",
  163. environment => ["CLASSPATH=${wlHome}/server/lib/weblogic.jar",
  164. "JAVA_HOME=${JAVA_HOME}"],
  165. require => File["${path}/${title}${script}"],
  166. }
  167. case $operatingsystem {
  168. CentOS, RedHat, OracleLinux, Ubuntu, Debian, SLES: {
  169. exec { "rm ${path}/${title}${script}":
  170. command => "rm -I ${path}/${title}${script}",
  171. require => Exec["execwlst ${title}${script}"],
  172. }
  173. }
  174. Solaris: {
  175. exec { "rm ${path}/${title}${script}":
  176. command => "rm ${path}/${title}${script}",
  177. require => Exec["execwlst ${title}${script}"],
  178. }
  179. }
  180. }
  181. }
  182. windows: {
  183. exec { "execwlst ${title}${script}":
  184. command => "C:\\Windows\\System32\\cmd.exe /c ${javaCommand} ${path}/${title}${script}",
  185. environment => ["CLASSPATH=${wlHome}\\server\\lib\\weblogic.jar",
  186. "JAVA_HOME=${JAVA_HOME}"],
  187. require => File["${path}/${title}${script}"],
  188. }
  189. exec { "rm ${path}/${title}${script}":
  190. command => "C:\\Windows\\System32\\cmd.exe /c rm ${path}/${title}${script}",
  191. require => Exec["execwlst ${title}${script}"],
  192. }
  193. }
  194. }
  195. }
  196. }