傀儡服务不会开始

时间:2013-08-07 06:31:37

标签: puppet puppetlabs-apache

我为Tomcat的小类提供了以下代码,该类运行正常,但脚本末尾的服务无法启动。任何指导都会很棒。我不知道为什么服务不会开始。

Tomcat6类的内容

# Class: tomcat6
#
# This module manages tomcat6
#
# Parameters: none
#
# Actions:
#
# Requires: see Modulefile
#
# Sample Usage:
#
class tomcat6 ( $parentdir               = '/usr/share',
                $tomcat_version          = '6.0.37',
                $tomcat_major_version    = '6',
                $digest_string           = '171d255cd60894b29a41684ce0ff93a8',
                $tomcat_exe              = 'tomcat6/tomcat.erb',
                $java_home               = '/usr/java/latest',
                $jvm_route               = 'jvm1',
                $shutdown_password       = 'SHUTDOWN',
                $admin_port              = 8005,
                $http_port               = 8080,
                $tomcat_user             = 'root',
                $tomcat_group            = 'root',
                $admin_user              = 'tomcat',
                $admin_password          = 'tomcat'
             ) {

  $basedir     = "${parentdir}/apache-tomcat-6.0.37"

  file {'/installs':
    ensure  => 'directory',
    source  => 'puppet:///modules/tomcat6/',
    recurse => 'remote',
    owner   => 'root',
    group   => 'root',
    mode    => '0755',
  }

  exec { 'tomcat_untar':
    command => 'tar -zxvf /installs/apache-tomcat-6.0.37.tar.gz -C /usr/share/',
    cwd     => '/usr/share/',
    creates => "/usr/share/apache-tomcat-6.0.37",
    path    => ["/bin"],
    require =>  [File["/installs"]]
  }

  file { "/etc/init.d/tomcat":
        ensure => present,
        owner  => root,
        group  => root,
        mode   => 0755,
        content => template($tomcat_exe),
        require => Exec["tomcat_untar"]
  }

    service { "tomcat":
        ensure  => "running",
        enable  => "true",
        require => File["/etc/init.d/tomcat"]
    } 
}

tomcat.erb的内容

#!/bin/bash
# description: Tomcat Start Stop Restart
# processname: tomcat
# chkconfig: 234 20 80
JAVA_HOME=/usr/java/jdk1.6.0_26
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
CATALINA_HOME=/usr/share/apache-tomcat-6.0.37

case $1 in
start)
sh $CATALINA_HOME/bin/startup.sh
;;
stop)
sh $CATALINA_HOME/bin/shutdown.sh
;;
restart)
sh $CATALINA_HOME/bin/shutdown.sh
sh $CATALINA_HOME/bin/startup.sh
;;
esac
exit 0

1 个答案:

答案 0 :(得分:0)

Puppet执行/etc/init.d/tomcat状态以查看该服务是否正在运行。如果服务停止时没有正确的返回状态,则不会尝试启动它。

http://docs.puppetlabs.com/references/latest/type.html#service

查看hasstatus。

另一种方法是使用'pattern'和'hasstatus'设置为false来使Puppet grep通过进程表。