resourceadapter.pp 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. # == Define: wls::resourceadapter
  2. #
  3. # generic resourceadapter wlst script
  4. # adds a new plan to the jca resource adapter
  5. # adds a new entry to the plan
  6. #
  7. # === Examples
  8. #
  9. #
  10. # wls::resourceadapter{
  11. # 'DbAdapter_hr':
  12. # wlHome => "/opt/oracle/wls/wls11g/wlserver_10.3",
  13. # fullJDKName => $jdkWls11gJDK,
  14. # domain => 'osbSoaDomain',
  15. # adapterName => 'DbAdapter' , or 'AqAdapter' or 'JmsAdapter'
  16. # adapterPath => '/opt/wls/Middleware11gR1/Oracle_SOA1/soa/connectors/DbAdapter.rar'
  17. # adapterPlanDir => '/opt/wls/Middleware11gR1/Oracle_SOA1/soa/connectors' ,
  18. # adapterPlan => 'Plan_DB.xml' ,
  19. # adapterEntry => 'eis/DB/initial',
  20. # adapterEntryProperty => 'xADataSourceName', or 'dataSourceName' or 'ConnectionFactoryLocation' (jms)
  21. # adapterEntryValue => 'jdbc/hrDS',
  22. # address => "localhost",
  23. # port => "7001",
  24. # wlsUser => "weblogic",
  25. # password => "weblogic1",
  26. # user => 'oracle',
  27. # group => 'dba',
  28. # downloadDir => "/install/",
  29. # }
  30. #
  31. #
  32. #
  33. define wls::resourceadapter( $version = '1111',
  34. $wlHome = undef,
  35. $fullJDKName = undef,
  36. $domain = undef,
  37. $adapterName = undef,
  38. $adapterPath = undef,
  39. $adapterPlanDir = undef,
  40. $adapterPlan = undef,
  41. $adapterEntry = undef,
  42. $adapterEntryProperty = undef,
  43. $adapterEntryValue = undef,
  44. $address = "localhost",
  45. $port = '7001',
  46. $wlsUser = "weblogic",
  47. $password = "weblogic1",
  48. $userConfigFile = undef,
  49. $userKeyFile = undef,
  50. $user = 'oracle',
  51. $group = 'dba',
  52. $downloadDir = '/install',
  53. ) {
  54. # if these params are empty always continue
  55. if $domain == undef or $adapterName == undef or $adapterPlanDir == undef or $adapterPlan == undef {
  56. fail("domain, adaptername,adapterPlanDir or adapterplan is nill")
  57. } else {
  58. # check if the object already exists on the weblogic domain
  59. $found = artifact_exists($domain ,"resource",$adapterName,"${adapterPlanDir}/${adapterPlan}",$version )
  60. if $found == undef {
  61. $continuePlan = true
  62. notify {"wls::resourceadapter ${title} ${version} continue cause nill":}
  63. } else {
  64. if ( $found ) {
  65. $continuePlan = false
  66. } else {
  67. notify {"wls::resourceadapter ${title} ${version} continue, does not exists":}
  68. $continuePlan = true
  69. }
  70. }
  71. }
  72. # if these params are empty always continue
  73. if $domain == undef or $adapterName == undef or $adapterEntry == undef {
  74. fail("domain, adaptername or adapterEntry is nill")
  75. } else {
  76. # check if the object already exists on the weblogic domain
  77. $foundEntry = artifact_exists($domain ,"resource_entry",$adapterName,$adapterEntry,$version )
  78. if $foundEntry == undef {
  79. $continueEntry = true
  80. notify {"wls::resourceadapter entry ${adapterEntry} ${title} ${version} continue cause nill":}
  81. } else {
  82. if ( $foundEntry ) {
  83. $continueEntry = false
  84. } else {
  85. notify {"wls::resourceadapter entry ${adapterEntry} ${title} ${version} continue, does not exists":}
  86. $continueEntry = true
  87. }
  88. }
  89. }
  90. case $operatingsystem {
  91. CentOS, RedHat, OracleLinux, Ubuntu, Debian, SLES: {
  92. $execPath = "/usr/java/${fullJDKName}/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:"
  93. $path = $downloadDir
  94. $JAVA_HOME = "/usr/java/${fullJDKName}"
  95. Exec { path => $execPath,
  96. user => $user,
  97. group => $group,
  98. logoutput => true,
  99. }
  100. File {
  101. ensure => present,
  102. mode => 0744,
  103. owner => $user,
  104. group => $group,
  105. backup => false,
  106. }
  107. }
  108. Solaris: {
  109. $execPath = "/usr/jdk/${fullJDKName}/bin/amd64:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:"
  110. $path = $downloadDir
  111. $JAVA_HOME = "/usr/jdk/${fullJDKName}"
  112. Exec { path => $execPath,
  113. user => $user,
  114. group => $group,
  115. logoutput => true,
  116. }
  117. File {
  118. ensure => present,
  119. replace => 'yes',
  120. mode => 0744,
  121. owner => $user,
  122. group => $group,
  123. backup => false,
  124. }
  125. }
  126. windows: {
  127. $execPath = "C:\\oracle\\${fullJDKName}\\bin;C:\\unxutils\\bin;C:\\unxutils\\usr\\local\\wbin;C:\\Windows\\system32;C:\\Windows"
  128. $path = $downloadDir
  129. $JAVA_HOME = "c:\\oracle\\${fullJDKName}"
  130. Exec { path => $execPath,
  131. logoutput => true,
  132. }
  133. File { ensure => present,
  134. mode => 0744,
  135. backup => false,
  136. }
  137. }
  138. }
  139. # are we using credentials or using the WLST userConfig file
  140. if $userConfigFile != undef {
  141. $credentials = " -userconfigfile ${userConfigFile} -userkeyfile ${userKeyFile}"
  142. $useStoreConfig = true
  143. } elsif $wlsUser != undef {
  144. $credentials = " -user ${wlsUser} -password ${password}"
  145. $useStoreConfig = false
  146. } else {
  147. fail("userConfigFile or wlsUser parameter is empty ")
  148. }
  149. # lets make the a new plan for this adapter
  150. if ( $continuePlan ) {
  151. # download the plan and put it on the right place
  152. if $adapterName == 'DbAdapter' {
  153. file { "${adapterPlanDir}/${adapterPlan}":
  154. path => "${adapterPlanDir}/${adapterPlan}",
  155. content => template("wls/adapter_plans/Plan_DB.xml.erb"),
  156. before => Exec["exec deployer adapter plan ${title}"],
  157. }
  158. } elsif $adapterName == 'JmsAdapter' {
  159. file { "${adapterPlanDir}/${adapterPlan}":
  160. path => "${adapterPlanDir}/${adapterPlan}",
  161. content => template("wls/adapter_plans/Plan_JMS.xml.erb"),
  162. before => Exec["exec deployer adapter plan ${title}"],
  163. }
  164. } elsif $adapterName == 'AqAdapter' {
  165. file { "${adapterPlanDir}/${adapterPlan}":
  166. path => "${adapterPlanDir}/${adapterPlan}",
  167. content => template("wls/adapter_plans/Plan_AQ.xml.erb"),
  168. before => Exec["exec deployer adapter plan ${title}"],
  169. }
  170. } else {
  171. fail("adaptername ${adapterName} is unknown, choose for DbAdapter,JmsAdapter or AqAdapter ")
  172. }
  173. $javaCommand = "java weblogic.Deployer"
  174. case $operatingsystem {
  175. CentOS, RedHat, OracleLinux, Ubuntu, Debian, SLES, Solaris: {
  176. # deploy the plan and update the adapter
  177. exec { "exec deployer adapter plan ${title}":
  178. command => "${javaCommand} -adminurl t3://${address}:${port} ${credentials} -update -name ${adapterName} -plan ${adapterPlanDir}/${adapterPlan}",
  179. environment => ["CLASSPATH=${wlHome}/server/lib/weblogic.jar",
  180. "JAVA_HOME=${JAVA_HOME}"],
  181. }
  182. }
  183. windows: {
  184. # deploy the plan and update the adapter
  185. exec { "exec deployer adapter plan ${title}":
  186. command => "C:\\Windows\\System32\\cmd.exe /c ${javaCommand} -adminurl t3://${address}:${port} ${credentials} -update -name ${adapterName} -plan ${adapterPlanDir}/${adapterPlan}",
  187. environment => ["CLASSPATH=${wlHome}\\server\\lib\\weblogic.jar",
  188. "JAVA_HOME=${JAVA_HOME}"],
  189. }
  190. }
  191. }
  192. }
  193. # after deployment of the plan we can add a new entry to the adapter
  194. if ( $continueEntry ) {
  195. if $adapterName == 'DbAdapter' or $adapterName == 'AqAdapter' {
  196. $connectionFactoryInterface='javax.resource.cci.ConnectionFactory'
  197. } elsif $adapterName == 'JmsAdapter' {
  198. $connectionFactoryInterface='oracle.tip.adapter.jms.IJmsConnectionFactory'
  199. }
  200. $javaCommandPlan = "java -Dweblogic.security.SSL.ignoreHostnameVerification=true weblogic.WLST -skipWLSModuleScanning "
  201. file { "${path}/${title}redeployResourceAdapter.py":
  202. path => "${path}/${title}redeployResourceAdapter.py",
  203. content => template("wls/wlst/redeployResourceAdapter.py.erb"),
  204. before => Exec["exec redeploy adapter plan ${title}"],
  205. }
  206. file { "${path}/${title}createResourceAdapterEntry.py":
  207. path => "${path}/${title}createResourceAdapterEntry.py",
  208. content => template("wls/wlst/createResourceAdapterEntry.py.erb"),
  209. before => Exec["exec create resource adapter entry ${title}"],
  210. }
  211. case $operatingsystem {
  212. CentOS, RedHat, OracleLinux, Ubuntu, Debian, SLES, Solaris: {
  213. # deploy the plan and update the adapter
  214. exec { "exec create resource adapter entry ${title}":
  215. command => "${javaCommandPlan} ${path}/${title}createResourceAdapterEntry.py",
  216. environment => ["CLASSPATH=${wlHome}/server/lib/weblogic.jar",
  217. "JAVA_HOME=${JAVA_HOME}"],
  218. }
  219. # deploy the plan and update the adapter
  220. exec { "exec redeploy adapter plan ${title}":
  221. command => "${javaCommandPlan} ${path}/${title}redeployResourceAdapter.py",
  222. environment => ["CLASSPATH=${wlHome}/server/lib/weblogic.jar",
  223. "JAVA_HOME=${JAVA_HOME}"],
  224. require => Exec["exec create resource adapter entry ${title}"],
  225. }
  226. case $operatingsystem {
  227. CentOS, RedHat, OracleLinux, Ubuntu, Debian, SLES, Solaris: {
  228. exec { "rm ${path}/${title}createResourceAdapterEntry.py":
  229. command => "rm ${path}/${title}createResourceAdapterEntry.py",
  230. require => Exec["exec create resource adapter entry ${title}"],
  231. }
  232. exec { "rm ${path}/${title}redeployResourceAdapter.py":
  233. command => "rm ${path}/${title}redeployResourceAdapter.py",
  234. require => Exec["exec redeploy adapter plan ${title}"],
  235. }
  236. }
  237. }
  238. }
  239. windows: {
  240. # deploy the plan and update the adapter
  241. exec { "exec create resource adapter entry ${title}":
  242. command => "C:\\Windows\\System32\\cmd.exe /c ${javaCommandPlan} ${path}/${title}createResourceAdapterEntry.py",
  243. environment => ["CLASSPATH=${wlHome}\\server\\lib\\weblogic.jar",
  244. "JAVA_HOME=${JAVA_HOME}"],
  245. }
  246. # deploy the plan and update the adapter
  247. exec { "exec redeploy adapter plan ${title}":
  248. command => "C:\\Windows\\System32\\cmd.exe /c ${javaCommandPlan} ${path}/${title}redeployResourceAdapter.py",
  249. environment => ["CLASSPATH=${wlHome}\\server\\lib\\weblogic.jar",
  250. "JAVA_HOME=${JAVA_HOME}"],
  251. require => Exec["exec create resource adapter entry ${title}"],
  252. }
  253. exec { "rm ${path}/${title}createResourceAdapterEntry.py":
  254. command => "C:\\Windows\\System32\\cmd.exe /c rm ${path}/${title}createResourceAdapterEntry.py",
  255. require => Exec["exec create resource adapter entry ${title}"],
  256. }
  257. exec { "rm ${path}/${title}redeployResourceAdapter.py":
  258. command => "C:\\Windows\\System32\\cmd.exe /c rm ${path}/${title}redeployResourceAdapter.py",
  259. require => Exec["exec redeploy adapter plan ${title}"],
  260. }
  261. }
  262. }
  263. }
  264. }