copydomain.pp 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. # == Define: wls::copydomain
  2. #
  3. # copydomain to an other node
  4. ##
  5. #
  6. define wls::copydomain ($version = '1111',
  7. $wlHome = undef,
  8. $mdwHome = undef,
  9. $fullJDKName = undef,
  10. $domain = undef,
  11. $adminListenAdr = "localhost",
  12. $adminListenPort = '7001',
  13. $wlsUser = undef,
  14. $password = undef,
  15. $sshpass = true,
  16. $user = 'oracle',
  17. $userPassword = 'oracle',
  18. $group = 'dba',
  19. $logDir = undef,
  20. $downloadDir = '/install',
  21. ) {
  22. if $::override_weblogic_domain_folder == undef {
  23. $domainPath = "${mdwHome}/user_projects/domains"
  24. $appPath = "${mdwHome}/user_projects/applications"
  25. } else {
  26. $domainPath = "${::override_weblogic_domain_folder}/domains"
  27. $appPath = "${::override_weblogic_domain_folder}/applications"
  28. }
  29. if $version == "1111" {
  30. $nodeMgrHome = "${wlHome}/common/nodemanager"
  31. } elsif $version == "1212" {
  32. if $::override_weblogic_domain_folder == undef {
  33. $nodeMgrHome = "${wlHome}/../user_projects/domains/${domain}/nodemanager"
  34. } else {
  35. $nodeMgrHome = "${::override_weblogic_domain_folder}/domains/${domain}/nodemanager"
  36. }
  37. } else {
  38. $nodeMgrHome = "${wlHome}/common/nodemanager"
  39. }
  40. # check if the domain already exists
  41. $found = domain_exists("${domainPath}/${domain}",$version,$domainPath)
  42. if $found == undef {
  43. $continue = true
  44. } else {
  45. if ( $found ) {
  46. $continue = false
  47. } else {
  48. notify {"wls::wlsdomain ${title} ${domainPath}/${domain} ${version} does not exists":}
  49. $continue = true
  50. }
  51. }
  52. if ( $continue ) {
  53. case $operatingsystem {
  54. CentOS, RedHat, OracleLinux, Ubuntu, Debian, SLES: {
  55. $execPath = "/usr/java/${fullJDKName}/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin"
  56. $path = $downloadDir
  57. $JAVA_HOME = "/usr/java/${fullJDKName}"
  58. Exec { path => $execPath,
  59. user => $user,
  60. group => $group,
  61. logoutput => true,
  62. }
  63. File {
  64. ensure => present,
  65. replace => true,
  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. $JAVA_HOME = "/usr/jdk/${fullJDKName}"
  76. Exec { path => $execPath,
  77. user => $user,
  78. group => $group,
  79. logoutput => true,
  80. }
  81. File {
  82. ensure => present,
  83. replace => true,
  84. mode => 0775,
  85. owner => $user,
  86. group => $group,
  87. backup => false,
  88. }
  89. }
  90. }
  91. if $logDir != undef {
  92. # create all log folders
  93. if !defined(Exec["create ${logDir} directory"]) {
  94. exec { "create ${logDir} directory":
  95. command => "mkdir -p ${logDir}",
  96. unless => "test -d ${logDir}",
  97. user => 'root',
  98. path => $execPath,
  99. }
  100. }
  101. if !defined(File[$logDir]) {
  102. file { $logDir:
  103. ensure => directory,
  104. recurse => false,
  105. replace => false,
  106. require => Exec["create ${logDir} directory"],
  107. mode => 0775,
  108. owner => $user,
  109. group => $group,
  110. }
  111. }
  112. }
  113. if $::override_weblogic_domain_folder == undef {
  114. # make the default domain folders
  115. if !defined(File["weblogic_domain_folder"]) {
  116. # check oracle install folder
  117. file { "weblogic_domain_folder":
  118. path => "${mdwHome}/user_projects",
  119. ensure => directory,
  120. recurse => false,
  121. replace => false,
  122. }
  123. }
  124. } else {
  125. # make override domain folders
  126. if !defined(File["weblogic_domain_folder"]) {
  127. # check oracle install folder
  128. file { "weblogic_domain_folder":
  129. path => $::override_weblogic_domain_folder,
  130. ensure => directory,
  131. recurse => false,
  132. replace => false,
  133. }
  134. }
  135. }
  136. if !defined(File[$domainPath]) {
  137. # check oracle install folder
  138. file { $domainPath:
  139. ensure => directory,
  140. recurse => false,
  141. replace => false,
  142. mode => 0775,
  143. require => File["weblogic_domain_folder"],
  144. }
  145. }
  146. if !defined(File[$appPath]) {
  147. # check oracle install folder
  148. file { $appPath:
  149. ensure => directory,
  150. recurse => false,
  151. replace => false,
  152. require => File["weblogic_domain_folder"],
  153. }
  154. }
  155. if ( $sshpass == false ) {
  156. exec { "copy domain jar ${domain}":
  157. command => "scp -oStrictHostKeyChecking=no -oCheckHostIP=no ${user}@${adminListenAdr}:${path}/domain_${domain}.jar ${path}/domain_${domain}.jar",
  158. }
  159. } else {
  160. exec { "copy domain jar ${domain}":
  161. command => "sshpass -p ${userPassword} scp -oStrictHostKeyChecking=no -oCheckHostIP=no ${user}@${adminListenAdr}:${path}/domain_${domain}.jar ${path}/domain_${domain}.jar",
  162. }
  163. }
  164. $unPackCommand = "-domain=${domainPath}/${domain} -template=${path}/domain_${domain}.jar -app_dir=${appPath} -log=${path}/domain_${domain}.log -log_priority=INFO"
  165. exec { "unpack ${domain}":
  166. command => "${wlHome}/common/bin/unpack.sh ${unPackCommand} -user_name=${wlsUser} -password=${password}",
  167. require => [File[$domainPath],
  168. Exec[ "copy domain jar ${domain}"]],
  169. }
  170. # the enroll domain.py used by the wlst
  171. file { "enroll.py ${domain} ${title}":
  172. path => "${path}/enroll_domain_${domain}.py",
  173. content => template("wls/wlst/enrollDomain.py.erb"),
  174. }
  175. case $operatingsystem {
  176. CentOS, RedHat, OracleLinux, Ubuntu, Debian, SLES, Solaris: {
  177. exec { "execwlst ${domain} ${title}":
  178. command => "${wlHome}/common/bin/wlst.sh ${path}/enroll_domain_${domain}.py",
  179. environment => ["JAVA_HOME=${JAVA_HOME}"],
  180. require => [File["${path}/enroll_domain_${domain}.py"],
  181. Exec["unpack ${domain}"]],
  182. }
  183. case $operatingsystem {
  184. CentOS, RedHat, OracleLinux, Ubuntu, Debian, SLES, Solaris: {
  185. exec { "domain.py ${domain} ${title}":
  186. command => "rm ${path}/enroll_domain_${domain}.py",
  187. require => Exec["execwlst ${domain} ${title}"],
  188. }
  189. }
  190. }
  191. }
  192. }
  193. }
  194. }