wlscontrol.pp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. # == Define: wls::wlscontrol
  2. #
  3. # Weblogic Server control, starts or stops a managed server
  4. #
  5. # action = start|stop
  6. # wlsServerType = admin|managed
  7. # wlsTarget = Server|Cluster
  8. #
  9. define wls::wlscontrol
  10. ( $wlHome = undef,
  11. $fullJDKName = undef,
  12. $wlsDomain = undef,
  13. $wlsDomainPath = undef,
  14. $wlsServerType = 'admin',
  15. $wlsTarget = 'Server',
  16. $wlsServer = 'AdminServer',
  17. $address = 'localhost',
  18. $port = '7001',
  19. $action = 'start',
  20. $wlsUser = undef,
  21. $password = undef,
  22. $user = 'oracle',
  23. $group = 'dba',
  24. $downloadDir = '/install',
  25. $logOutput = false,
  26. ) {
  27. $javaCommand = "java -Dweblogic.security.SSL.ignoreHostnameVerification=true weblogic.WLST -skipWLSModuleScanning "
  28. $path = $downloadDir
  29. case $operatingsystem {
  30. CentOS, RedHat, OracleLinux, Ubuntu, Debian, SLES: {
  31. $execPath = "/usr/java/${fullJDKName}/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:"
  32. $JAVA_HOME = "/usr/java/${fullJDKName}"
  33. $checkCommand = "/bin/ps -ef | grep -v grep | /bin/grep 'weblogic.Name=${wlsServer}' | /bin/grep ${wlsDomain}"
  34. }
  35. Solaris: {
  36. $execPath = "/usr/jdk/${fullJDKName}/bin/amd64:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:"
  37. $JAVA_HOME = "/usr/jdk/${fullJDKName}"
  38. $checkCommand = "/usr/ucb/ps wwxa | grep -v grep | /bin/grep 'weblogic.NodeManager'"
  39. }
  40. windows: {
  41. $execPath = "C:\\oracle\\${fullJDKName}\\bin;C:\\unxutils\\bin;C:\\unxutils\\usr\\local\\wbin;C:\\Windows\\system32;C:\\Windows"
  42. $JAVA_HOME = "c:\\oracle\\${fullJDKName}"
  43. }
  44. }
  45. if $wlsServerType == 'admin' {
  46. if $action == 'start' {
  47. $script = 'startWlsServer2.py'
  48. } elsif $action == 'stop' {
  49. $script = 'stopWlsServer2.py'
  50. } else {
  51. fail("Unknow action")
  52. }
  53. } else {
  54. if $action == 'start' {
  55. $script = 'startWlsManagedServer2.py'
  56. } elsif $action == 'stop' {
  57. $script = 'stopWlsManagedServer2.py'
  58. } else {
  59. fail("Unknow action")
  60. }
  61. }
  62. # the py script used by the wlst
  63. file { "${path}/${title}${script}":
  64. path => "${path}/${title}${script}",
  65. content => template("wls/wlst/${script}.erb"),
  66. ensure => present,
  67. replace => true,
  68. mode => 0775,
  69. owner => $user,
  70. group => $group,
  71. backup => false,
  72. }
  73. case $operatingsystem {
  74. CentOS, RedHat, OracleLinux, Ubuntu, Debian, SLES, Solaris: {
  75. if $action == 'start' {
  76. exec { "execwlst ${title}${script} ":
  77. command => "${javaCommand} ${path}/${title}${script} ${password}",
  78. environment => ["CLASSPATH=${wlHome}/server/lib/weblogic.jar",
  79. "JAVA_HOME=${JAVA_HOME}"],
  80. unless => $checkCommand,
  81. require => File["${path}/${title}${script}"],
  82. path => $execPath,
  83. user => $user,
  84. group => $group,
  85. logoutput => $logOutput,
  86. timeout => 0,
  87. }
  88. } elsif $action == 'stop' {
  89. exec { "execwlst ${title}${script} ":
  90. command => "${javaCommand} ${path}/${title}${script} ${password}",
  91. environment => ["CLASSPATH=${wlHome}/server/lib/weblogic.jar",
  92. "JAVA_HOME=${JAVA_HOME}"],
  93. onlyif => $checkCommand,
  94. require => File["${path}/${title}${script}"],
  95. path => $execPath,
  96. user => $user,
  97. group => $group,
  98. logoutput => $logOutput,
  99. timeout => 0,
  100. }
  101. }
  102. }
  103. windows: {
  104. exec { "execwlst ${title}${script}":
  105. command => "C:\\Windows\\System32\\cmd.exe /c ${javaCommand} ${path}/${title}${script} ${password}",
  106. environment => ["CLASSPATH=${wlHome}\\server\\lib\\weblogic.jar",
  107. "JAVA_HOME=${JAVA_HOME}"],
  108. require => File["${path}/${title}${script}"],
  109. path => $execPath,
  110. logoutput => $logOutput,
  111. timeout => 0,
  112. }
  113. }
  114. }
  115. }