wlscontrol.pp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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 => 'yes',
  68. mode => 0775,
  69. owner => $user,
  70. group => $group,
  71. }
  72. case $operatingsystem {
  73. CentOS, RedHat, OracleLinux, Ubuntu, Debian, SLES, Solaris: {
  74. if $action == 'start' {
  75. exec { "execwlst ${title}${script} ":
  76. command => "${javaCommand} ${path}/${title}${script} ${password}",
  77. environment => ["CLASSPATH=${wlHome}/server/lib/weblogic.jar",
  78. "JAVA_HOME=${JAVA_HOME}"],
  79. unless => $checkCommand,
  80. require => File["${path}/${title}${script}"],
  81. path => $execPath,
  82. user => $user,
  83. group => $group,
  84. logoutput => $logOutput,
  85. timeout => 0,
  86. }
  87. } elsif $action == 'stop' {
  88. exec { "execwlst ${title}${script} ":
  89. command => "${javaCommand} ${path}/${title}${script} ${password}",
  90. environment => ["CLASSPATH=${wlHome}/server/lib/weblogic.jar",
  91. "JAVA_HOME=${JAVA_HOME}"],
  92. onlyif => $checkCommand,
  93. require => File["${path}/${title}${script}"],
  94. path => $execPath,
  95. user => $user,
  96. group => $group,
  97. logoutput => $logOutput,
  98. timeout => 0,
  99. }
  100. }
  101. }
  102. windows: {
  103. exec { "execwlst ${title}${script}":
  104. command => "C:\\Windows\\System32\\cmd.exe /c ${javaCommand} ${path}/${title}${script} ${password}",
  105. environment => ["CLASSPATH=${wlHome}\\server\\lib\\weblogic.jar",
  106. "JAVA_HOME=${JAVA_HOME}"],
  107. require => File["${path}/${title}${script}"],
  108. path => $execPath,
  109. logoutput => $logOutput,
  110. timeout => 0,
  111. }
  112. }
  113. }
  114. }