resourceadapter.pp 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  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. }
  106. }
  107. Solaris: {
  108. $execPath = "/usr/jdk/${fullJDKName}/bin/amd64:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:"
  109. $path = $downloadDir
  110. $JAVA_HOME = "/usr/jdk/${fullJDKName}"
  111. Exec { path => $execPath,
  112. user => $user,
  113. group => $group,
  114. logoutput => true,
  115. }
  116. File {
  117. ensure => present,
  118. replace => 'yes',
  119. mode => 0744,
  120. owner => $user,
  121. group => $group,
  122. }
  123. }
  124. windows: {
  125. $execPath = "C:\\oracle\\${fullJDKName}\\bin;C:\\unxutils\\bin;C:\\unxutils\\usr\\local\\wbin;C:\\Windows\\system32;C:\\Windows"
  126. $path = $downloadDir
  127. $JAVA_HOME = "c:\\oracle\\${fullJDKName}"
  128. Exec { path => $execPath,
  129. logoutput => true,
  130. }
  131. File { ensure => present,
  132. mode => 0744,
  133. }
  134. }
  135. }
  136. # are we using credentials or using the WLST userConfig file
  137. if $userConfigFile != undef {
  138. $credentials = " -userconfigfile ${userConfigFile} -userkeyfile ${userKeyFile}"
  139. $useStoreConfig = true
  140. } elsif $wlsUser != undef {
  141. $credentials = " -user ${wlsUser} -password ${password}"
  142. $useStoreConfig = false
  143. } else {
  144. fail("userConfigFile or wlsUser parameter is empty ")
  145. }
  146. # lets make the a new plan for this adapter
  147. if ( $continuePlan ) {
  148. # download the plan and put it on the right place
  149. if $adapterName == 'DbAdapter' {
  150. file { "${adapterPlanDir}/${adapterPlan}":
  151. path => "${adapterPlanDir}/${adapterPlan}",
  152. content => template("wls/adapter_plans/Plan_DB.xml.erb"),
  153. before => Exec["exec deployer adapter plan ${title}"],
  154. }
  155. } elsif $adapterName == 'JmsAdapter' {
  156. file { "${adapterPlanDir}/${adapterPlan}":
  157. path => "${adapterPlanDir}/${adapterPlan}",
  158. content => template("wls/adapter_plans/Plan_JMS.xml.erb"),
  159. before => Exec["exec deployer adapter plan ${title}"],
  160. }
  161. } elsif $adapterName == 'AqAdapter' {
  162. file { "${adapterPlanDir}/${adapterPlan}":
  163. path => "${adapterPlanDir}/${adapterPlan}",
  164. content => template("wls/adapter_plans/Plan_AQ.xml.erb"),
  165. before => Exec["exec deployer adapter plan ${title}"],
  166. }
  167. } else {
  168. fail("adaptername ${adapterName} is unknown, choose for DbAdapter,JmsAdapter or AqAdapter ")
  169. }
  170. $javaCommand = "java weblogic.Deployer"
  171. case $operatingsystem {
  172. CentOS, RedHat, OracleLinux, Ubuntu, Debian, SLES, Solaris: {
  173. # deploy the plan and update the adapter
  174. exec { "exec deployer adapter plan ${title}":
  175. command => "${javaCommand} -adminurl t3://${address}:${port} ${credentials} -update -name ${adapterName} -plan ${adapterPlanDir}/${adapterPlan}",
  176. environment => ["CLASSPATH=${wlHome}/server/lib/weblogic.jar",
  177. "JAVA_HOME=${JAVA_HOME}"],
  178. }
  179. }
  180. windows: {
  181. # deploy the plan and update the adapter
  182. exec { "exec deployer adapter plan ${title}":
  183. command => "C:\\Windows\\System32\\cmd.exe /c ${javaCommand} -adminurl t3://${address}:${port} ${credentials} -update -name ${adapterName} -plan ${adapterPlanDir}/${adapterPlan}",
  184. environment => ["CLASSPATH=${wlHome}\\server\\lib\\weblogic.jar",
  185. "JAVA_HOME=${JAVA_HOME}"],
  186. }
  187. }
  188. }
  189. }
  190. # after deployment of the plan we can add a new entry to the adapter
  191. if ( $continueEntry ) {
  192. if $adapterName == 'DbAdapter' or $adapterName == 'AqAdapter' {
  193. $connectionFactoryInterface='javax.resource.cci.ConnectionFactory'
  194. } elsif $adapterName == 'JmsAdapter' {
  195. $connectionFactoryInterface='oracle.tip.adapter.jms.IJmsConnectionFactory'
  196. }
  197. $javaCommandPlan = "java -Dweblogic.security.SSL.ignoreHostnameVerification=true weblogic.WLST -skipWLSModuleScanning "
  198. file { "${path}/${title}redeployResourceAdapter.py":
  199. path => "${path}/${title}redeployResourceAdapter.py",
  200. content => template("wls/wlst/redeployResourceAdapter.py.erb"),
  201. before => Exec["exec redeploy adapter plan ${title}"],
  202. }
  203. file { "${path}/${title}createResourceAdapterEntry.py":
  204. path => "${path}/${title}createResourceAdapterEntry.py",
  205. content => template("wls/wlst/createResourceAdapterEntry.py.erb"),
  206. before => Exec["exec create resource adapter entry ${title}"],
  207. }
  208. case $operatingsystem {
  209. CentOS, RedHat, OracleLinux, Ubuntu, Debian, SLES, Solaris: {
  210. # deploy the plan and update the adapter
  211. exec { "exec create resource adapter entry ${title}":
  212. command => "${javaCommandPlan} ${path}/${title}createResourceAdapterEntry.py",
  213. environment => ["CLASSPATH=${wlHome}/server/lib/weblogic.jar",
  214. "JAVA_HOME=${JAVA_HOME}"],
  215. }
  216. # deploy the plan and update the adapter
  217. exec { "exec redeploy adapter plan ${title}":
  218. command => "${javaCommandPlan} ${path}/${title}redeployResourceAdapter.py",
  219. environment => ["CLASSPATH=${wlHome}/server/lib/weblogic.jar",
  220. "JAVA_HOME=${JAVA_HOME}"],
  221. require => Exec["exec create resource adapter entry ${title}"],
  222. }
  223. case $operatingsystem {
  224. CentOS, RedHat, OracleLinux, Ubuntu, Debian, SLES: {
  225. exec { "rm ${path}/${title}createResourceAdapterEntry.py":
  226. command => "rm -I ${path}/${title}createResourceAdapterEntry.py",
  227. require => Exec["exec create resource adapter entry ${title}"],
  228. }
  229. exec { "rm ${path}/${title}redeployResourceAdapter.py":
  230. command => "rm -I ${path}/${title}redeployResourceAdapter.py",
  231. require => Exec["exec redeploy adapter plan ${title}"],
  232. }
  233. }
  234. Solaris: {
  235. exec { "rm ${path}/${title}createResourceAdapterEntry.py":
  236. command => "rm ${path}/${title}createResourceAdapterEntry.py",
  237. require => Exec["exec create resource adapter entry ${title}"],
  238. }
  239. exec { "rm ${path}/${title}redeployResourceAdapter.py":
  240. command => "rm ${path}/${title}redeployResourceAdapter.py",
  241. require => Exec["exec redeploy adapter plan ${title}"],
  242. }
  243. }
  244. }
  245. }
  246. windows: {
  247. # deploy the plan and update the adapter
  248. exec { "exec create resource adapter entry ${title}":
  249. command => "C:\\Windows\\System32\\cmd.exe /c ${javaCommandPlan} ${path}/${title}createResourceAdapterEntry.py",
  250. environment => ["CLASSPATH=${wlHome}\\server\\lib\\weblogic.jar",
  251. "JAVA_HOME=${JAVA_HOME}"],
  252. }
  253. # deploy the plan and update the adapter
  254. exec { "exec redeploy adapter plan ${title}":
  255. command => "C:\\Windows\\System32\\cmd.exe /c ${javaCommandPlan} ${path}/${title}redeployResourceAdapter.py",
  256. environment => ["CLASSPATH=${wlHome}\\server\\lib\\weblogic.jar",
  257. "JAVA_HOME=${JAVA_HOME}"],
  258. require => Exec["exec create resource adapter entry ${title}"],
  259. }
  260. exec { "rm ${path}/${title}createResourceAdapterEntry.py":
  261. command => "C:\\Windows\\System32\\cmd.exe /c rm ${path}/${title}createResourceAdapterEntry.py",
  262. require => Exec["exec create resource adapter entry ${title}"],
  263. }
  264. exec { "rm ${path}/${title}redeployResourceAdapter.py":
  265. command => "C:\\Windows\\System32\\cmd.exe /c rm ${path}/${title}redeployResourceAdapter.py",
  266. require => Exec["exec redeploy adapter plan ${title}"],
  267. }
  268. }
  269. }
  270. }
  271. }