copydomain.pp 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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. $user = 'oracle',
  16. $userPassword = 'oracle',
  17. $group = 'dba',
  18. $downloadDir = '/install',
  19. ) {
  20. $domainPath = "${mdwHome}/user_projects/domains"
  21. $appPath = "${mdwHome}/user_projects/applications"
  22. if $version == "1111" {
  23. $nodeMgrHome = "${wlHome}/common/nodemanager"
  24. } elsif $version == "1212" {
  25. $nodeMgrHome = "${wlHome}/../user_projects/domains/${domain}/nodemanager"
  26. } else {
  27. $nodeMgrHome = "${wlHome}/common/nodemanager"
  28. }
  29. # check if the domain already exists
  30. $found = domain_exists("${domainPath}/${domain}",$version)
  31. if $found == undef {
  32. $continue = true
  33. } else {
  34. if ( $found ) {
  35. $continue = false
  36. } else {
  37. notify {"wls::wlsdomain ${title} ${domainPath}/${domain} ${version} does not exists":}
  38. $continue = true
  39. }
  40. }
  41. if ( $continue ) {
  42. case $operatingsystem {
  43. CentOS, RedHat, OracleLinux, Ubuntu, Debian, SLES: {
  44. $execPath = "/usr/java/${fullJDKName}/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin"
  45. $path = $downloadDir
  46. $JAVA_HOME = "/usr/java/${fullJDKName}"
  47. Exec { path => $execPath,
  48. user => $user,
  49. group => $group,
  50. logoutput => true,
  51. }
  52. File {
  53. ensure => present,
  54. replace => 'yes',
  55. mode => 0775,
  56. owner => $user,
  57. group => $group,
  58. }
  59. }
  60. Solaris: {
  61. $execPath = "/usr/jdk/${fullJDKName}/bin/amd64:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin"
  62. $path = $downloadDir
  63. $JAVA_HOME = "/usr/jdk/${fullJDKName}"
  64. Exec { path => $execPath,
  65. user => $user,
  66. group => $group,
  67. logoutput => true,
  68. }
  69. File {
  70. ensure => present,
  71. replace => 'yes',
  72. mode => 0775,
  73. owner => $user,
  74. group => $group,
  75. }
  76. }
  77. }
  78. # make the default domain folders
  79. if ! defined(File["${mdwHome}/user_projects"]) {
  80. # check oracle install folder
  81. file { "${mdwHome}/user_projects" :
  82. ensure => directory,
  83. recurse => false,
  84. replace => false,
  85. }
  86. }
  87. if ! defined(File["${mdwHome}/user_projects/domains"]) {
  88. # check oracle install folder
  89. file { "${mdwHome}/user_projects/domains" :
  90. ensure => directory,
  91. recurse => false,
  92. replace => false,
  93. require => File["${mdwHome}/user_projects"],
  94. }
  95. }
  96. if ! defined(File["${mdwHome}/user_projects/applications"]) {
  97. # check oracle install folder
  98. file { "${mdwHome}/user_projects/applications" :
  99. ensure => directory,
  100. recurse => false,
  101. replace => false,
  102. require => File["${mdwHome}/user_projects"],
  103. }
  104. }
  105. exec { "copy domain jar ${domain}":
  106. command => "sshpass -p ${userPassword} scp -oStrictHostKeyChecking=no -oCheckHostIP=no ${user}@${adminListenAdr}:${path}/domain_${domain}.jar ${path}/domain_${domain}.jar",
  107. }
  108. $unPackCommand = "-domain=${domainPath}/${domain} -template=${path}/domain_${domain}.jar -app_dir=${appPath} -log=${path}/domain_${domain}.log -log_priority=INFO"
  109. exec { "unpack ${domain}":
  110. command => "${wlHome}/common/bin/unpack.sh ${unPackCommand} -user_name=${wlsUser} -password=${password}",
  111. require => [File["${mdwHome}/user_projects/domains"],Exec[ "copy domain jar ${domain}"]],
  112. }
  113. # the enroll domain.py used by the wlst
  114. file { "enroll.py ${domain} ${title}":
  115. path => "${path}/enroll_domain_${domain}.py",
  116. content => template("wls/wlst/enrollDomain.py.erb"),
  117. }
  118. case $operatingsystem {
  119. CentOS, RedHat, OracleLinux, Ubuntu, Debian, SLES, Solaris: {
  120. exec { "execwlst ${domain} ${title}":
  121. command => "${wlHome}/common/bin/wlst.sh ${path}/enroll_domain_${domain}.py",
  122. environment => ["JAVA_HOME=${JAVA_HOME}"],
  123. require => [File["${path}/enroll_domain_${domain}.py"],Exec["unpack ${domain}"]],
  124. }
  125. case $operatingsystem {
  126. CentOS, RedHat, OracleLinux, Ubuntu, Debian, SLES: {
  127. exec { "domain.py ${domain} ${title}":
  128. command => "rm -I ${path}/enroll_domain_${domain}.py",
  129. require => Exec["execwlst ${domain} ${title}"],
  130. }
  131. }
  132. Solaris: {
  133. exec { "domain.py ${domain} ${title}":
  134. command => "rm ${path}/enroll_domain_${domain}.py",
  135. require => Exec["execwlst ${domain} ${title}"],
  136. }
  137. }
  138. }
  139. }
  140. }
  141. }
  142. }