Hey all,

I've created a number of puppet modules that control services in the form
of init scripts on the hosts it controls.

However I recently created a logstash init script and a puppet module to
control it. It also should push out a config file.


And the logstash module cannot control the logstash init script, even tho
the module was created in the same way as the other modules I've done. So
my thinking is that there may be a problem with the init script.

Here's my class definition:

class logstash {

  service { logstash:
         ensure => running,
  }

   file { "/usr/local/logstash/indexer.conf":
      notify  => Service["logstash"],
      owner => "root",
      group => "root",
      mode => 0440,
      #require => File["/usr/local/logstash/logstash-1.3.2-flatjar.jar"],
      source => "puppet:///modules/logstash/indexer.conf",
     }
}


And my node definition looks like this:

node 'logs.mydomain.com' {
    include sudo, logstash, puppet, apache, bacula-client
}


And this is the init script that puppet can't seem to control. It might be
worth knowing that on it's own, the init script I'm about to show you does
successfully stop start and restart (or refresh if you prefer) the logstash
application.



#! /bin/bash
#
# /etc/rc.d/init.d/logstash
#
# Starts Logstash as a daemon
#
# chkconfig: 2345 20 80
# description: Starts Logstash as a daemon
# pidfile: /var/run/logstash-agent.pid

### BEGIN INIT INFO
# Provides: logstash
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: S 0 1 6
# Short-Description: Logstash
# Description: Starts Logstash as a daemon.
# Author: christian.pare...@sbri.org, modified by https://github.com/paul-at

### END INIT INFO

# Amount of memory for Java
JAVAMEM=256M

# Location of logstash files
LOCATION='/usr/local/logstash'

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
DESC="Logstash Daemon"
NAME=java
DAEMON=$(which java)
CONFIG_DIR='/etc/logstash/logstash.conf'
LOGFILE="/var/log/logstash/logstash-indexer.log"
PATTERNSPATH="/usr/local/logstash/patterns"
JARNAME='logstash.jar'
ARGS="-Xmx$JAVAMEM -Xms$JAVAMEM -jar ${JARNAME} agent --config
${CONFIG_DIR} --log ${LOGFILE}"
SCRIPTNAME=/etc/init.d/logstash
base=logstash

# Exit if the package is not installed
if [ ! -x "$DAEMON" ]; then
{
echo "Couldn't find $DAEMON"
exit 99
}
fi

. /etc/init.d/functions

#
# Function that starts the daemon/service
#
do_start()
{
cd $LOCATION && \
($DAEMON $ARGS &) \
&& success || failure
}

#
# Function that stops the daemon/service
#
do_stop()
{
pid=$(ps auxwww | grep -e logstash -e indexer  | grep -i -v -e grep -e
screen -e vim -e forwarder -e start)
if checkpid $pid 2>&1; then
# TERM first, then KILL if not dead
kill -TERM $pid >/dev/null 2>&1
usleep 100000
if checkpid $pid && sleep 1 &&
checkpid $pid && sleep $delay &&
checkpid $pid ; then
kill -KILL $pid >/dev/null 2>&1
usleep 100000
fi
fi
checkpid $pid
RC=$?
[ "$RC" -eq 0 ] && failure $"$base shutdown" || success $"$base shutdown"

}

case "$1" in
start)
echo -n "Starting $DESC: "
do_start
touch /var/lock/subsys/$JARNAME
;;
stop)
echo -n "Stopping $DESC: "
do_stop
rm /var/lock/subsys/$JARNAME
;;
restart|reload)
echo -n "Restarting $DESC: "
do_stop
do_start
;;
status)
status -p $PID
;;

 It's just that if I stop the service and do a manual puppet run,
everything goes fine, but nothing at all happens with the logstash service.

Allow me to demonstrate:

Step 1, stop services and remove files that puppet is meant to control:

root@logs:~] #service httpd stop
Stopping httpd:                                            [  OK  ]
[root@logs:~] #service bacula-fd stop
Shutting down bacula-fd:                                   [  OK  ]
[root@logs:~] #service logstash stop
Stopping Logstash Daemon: Terminated
[root@logs:~] #rm /etc/sudoers

The manual puppet run:

[root@logs:~] #puppet agent --test --server puppet.mydomain.com
Info: Retrieving plugin
Info: Caching catalog for logs.jokefire.com
Info: Applying configuration version '1389442074'
Notice: /Stage[main]/Apache/Service[httpd]/ensure: ensure changed 'stopped'
to 'running'
Info: /Stage[main]/Apache/Service[httpd]: Unscheduling refresh on
Service[httpd]
Notice: /Stage[main]/Sudo/File[/etc/sudoers]/ensure: defined content as
'{md5}4682d5ac1b693284dd615a4366a2e8ce'
Notice: /Stage[main]/Bacula-client/Service[bacula-fd]/ensure: ensure
changed 'stopped' to 'running'
Info: /Stage[main]/Bacula-client/Service[bacula-fd]: Unscheduling refresh
on Service[bacula-fd]
Notice: Finished catalog run in 1.18 seconds

And a grep for logstash (filtering out non-relevant items) turns up nothing

[root@logs:~] #ps -ef | grep logstash | grep -i -v -e grep -e screen -e
forwarder


But puppet returns the file that I removed:

-r--r----- 1 root root 3469 Jan 11 07:50 /etc/sudoers


Starting the daemon usign the init script I show above:

[root@logs:~] #service logstash start
Starting Logstash Daemon:                                  [  OK  ]

And doing the same grep as before now shows a happy, running logstash:

[root@logs:~] #ps -ef | grep logstash | grep -i -v -e grep -e screen -e
forwarder
root     19915     1 91 07:54 pts/0    00:00:26 /usr/bin/java -Xmx256M
-Xms256M -jar logstash.jar agent --config /etc/logstash/logstash.conf --log
/var/log/logstash/logstash-indexer.log


So what am I missing here? Any clues or ideas? I'd really appreciate the
list's input on this one.

Thanks!
Tim







-- 
GPG me!!

gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CAOZy0ekY19GGFx0pvAPKCtkWg3uQyGk6g%3DEQKWu-UgsZYC%3Dg8A%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to