wlstexec.pp 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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. # override if config and key files are provided
  103. if($userConfigFile != undef and $userKeyFile != undef) {
  104. $useStoreConfig = true
  105. }
  106. else {
  107. $useStoreConfig = false
  108. }
  109. }
  110. if ( $continue ) {
  111. $javaCommand = "java -Dweblogic.security.SSL.ignoreHostnameVerification=true weblogic.WLST -skipWLSModuleScanning "
  112. case $operatingsystem {
  113. CentOS, RedHat, OracleLinux, Ubuntu, Debian, SLES: {
  114. $execPath = "/usr/java/${fullJDKName}/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:"
  115. $path = $downloadDir
  116. $JAVA_HOME = "/usr/java/${fullJDKName}"
  117. Exec { path => $execPath,
  118. user => $user,
  119. group => $group,
  120. logoutput => $logOutput,
  121. }
  122. File {
  123. ensure => present,
  124. replace => true,
  125. mode => 0555,
  126. owner => $user,
  127. group => $group,
  128. backup => false,
  129. }
  130. }
  131. Solaris: {
  132. $execPath = "/usr/jdk/${fullJDKName}/bin/amd64:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:"
  133. $path = $downloadDir
  134. $JAVA_HOME = "/usr/jdk/${fullJDKName}"
  135. Exec { path => $execPath,
  136. user => $user,
  137. group => $group,
  138. logoutput => $logOutput,
  139. }
  140. File {
  141. ensure => present,
  142. replace => true,
  143. mode => 0775,
  144. owner => $user,
  145. group => $group,
  146. backup => false,
  147. }
  148. }
  149. windows: {
  150. $execPath = "C:\\oracle\\${fullJDKName}\\bin;C:\\unxutils\\bin;C:\\unxutils\\usr\\local\\wbin;C:\\Windows\\system32;C:\\Windows"
  151. $path = $downloadDir
  152. $JAVA_HOME = "c:\\oracle\\${fullJDKName}"
  153. Exec { path => $execPath,
  154. logoutput => $logOutput,
  155. }
  156. File { ensure => present,
  157. replace => true,
  158. mode => 0777,
  159. backup => false,
  160. }
  161. }
  162. }
  163. # the py script used by the wlst
  164. file { "${path}/${title}${script}":
  165. path => "${path}/${title}${script}",
  166. content => template("wls/wlst/${script}.erb"),
  167. }
  168. case $operatingsystem {
  169. CentOS, RedHat, OracleLinux, Ubuntu, Debian, SLES, Solaris: {
  170. exec { "execwlst ${title}${script}":
  171. command => "${javaCommand} ${path}/${title}${script}",
  172. environment => ["CLASSPATH=${wlHome}/server/lib/weblogic.jar",
  173. "JAVA_HOME=${JAVA_HOME}"],
  174. require => File["${path}/${title}${script}"],
  175. }
  176. case $operatingsystem {
  177. CentOS, RedHat, OracleLinux, Ubuntu, Debian, SLES, Solaris: {
  178. exec { "rm ${path}/${title}${script}":
  179. command => "rm ${path}/${title}${script}",
  180. require => Exec["execwlst ${title}${script}"],
  181. }
  182. }
  183. }
  184. }
  185. windows: {
  186. exec { "execwlst ${title}${script}":
  187. command => "C:\\Windows\\System32\\cmd.exe /c ${javaCommand} ${path}/${title}${script}",
  188. environment => ["CLASSPATH=${wlHome}\\server\\lib\\weblogic.jar",
  189. "JAVA_HOME=${JAVA_HOME}"],
  190. require => File["${path}/${title}${script}"],
  191. }
  192. exec { "rm ${path}/${title}${script}":
  193. command => "C:\\Windows\\System32\\cmd.exe /c rm ${path}/${title}${script}",
  194. require => Exec["execwlst ${title}${script}"],
  195. }
  196. }
  197. }
  198. }
  199. }