treydock
2011-Aug-12 17:55 UTC
[Puppet Users] Service resource throws error for "ups" but service starts
I have a puppet module to manage Network UPS Tools, but am having
trouble getting Puppet to be able to start the "ups" service without
error. What''s strange is the service starts just fine, but Puppet
returns an error.
Here''s the service resource I defined...
package { ''nut-client'': ensure => installed,
}
service { ''ups'':
ensure => running,
enable => true,
hasrestart => true,
require => Package[''nut-client''],
}
The error when I run puppet is as follows...
debug: Service[ups](provider=redhat): Executing ''/sbin/service ups
start''
err: /Stage[main]/Nut::Slave/Service[ups]/ensure: change from stopped
to running failed: Could not start Service[ups]: Execution of ''/sbin/
service ups start'' returned 1: at /etc/puppet/modules/nut/manifests/
classes/slave.pp:12
I do not know if this is the fault of a bad return code in the init
script...here''s the init script used...
### BEGIN INIT INFO
# Provides: ups
# Required-Start: $syslog $network $named
# Required-Stop: $local_fs
# Default-Stop: 0 1 6
# Short-Description: Starts the Network UPS tools
# Description: Network UPS Tools is a collection of programs which
provide a common \
# interface for monitoring and administering UPS hardware.
### END INIT INFO
# Source function library.
if [ -f /etc/init.d/functions ]; then
. /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
else
exit 0
fi
# Get config.
if [ -f /etc/sysconfig/ups ]; then
. /etc/sysconfig/ups
else
SERVER="no"
fi
start() {
if [ "$SERVER" = "yes" ]; then
echo -n $"Starting UPS driver controller: "
daemon /sbin/upsdrvctl start > /dev/null 2>&1 && success ||
failure
RETVAL=$?
echo
prog="upsd"
echo -n $"Starting $prog: "
daemon /usr/sbin/upsd $UPSD_OPTIONS > /dev/null 2>&1 &&
success ||
failure
if [ "$RETVAL" = 0 ]; then
RETVAL=$?
fi
echo
echo -n $"Starting UPS monitor (master): "
daemon /usr/sbin/upsmon > /dev/null 2>&1 && success ||
failure
if [ "$RETVAL" = 0 ]; then
RETVAL=$?
fi
echo
else
echo -n $"Starting UPS monitor (slave): "
daemon /usr/sbin/upsmon > /dev/null 2>&1 && success ||
failure
echo
fi
[ "$RETVAL" = 0 ] && touch /var/lock/subsys/ups
}
stop() {
echo -n $"Stopping UPS monitor: "
killproc upsmon
echo
if [ "$SERVER" = "yes" ]; then
prog="upsd"
echo -n $"Stopping $prog: "
killproc upsd > /dev/null 2>&1 && success || failure
RETVAL=$?
echo
echo -n $"Shutting down upsdrvctl: "
/sbin/upsdrvctl stop > /dev/null 2>&1 && success || failure
if [ "$RETVAL" = 0 ]; then
RETVAL=$?
fi
echo
fi
[ "$RETVAL" = 0 ] && rm -f /var/lock/subsys/ups
}
restart() {
stop
start
}
reload() {
# FIXME: upsd and upsmon always return 0
# => can''t tell if reload was successful
if [ "$SERVER" = "yes" ]; then
action "Reloading upsd:" /usr/sbin/upsd -c reload
RETVAL=$?
fi
action "Reloading upsmon:" /usr/sbin/upsmon -c reload
if [ "$RETVAL" = 0 ]; then
RETVAL=$?
fi
}
# See how we are called.
case "$1" in
start)
start ;;
stop)
stop ;;
restart)
restart ;;
try-restart)
[ -f /var/lock/subsys/ups ] && restart || :
;;
reload)
reload ;;
force-reload)
restart ;;
status)
if [ "$SERVER" = "yes" ]; then
status upsd
fi
status upsmon
;;
*)
echo $"Usage: $0 {start|stop|restart|try-restart|reload|force-reload|
status}"
RETVAL=3
esac
exit $RETVAL
Thanks
- Trey
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to
puppet-users+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.
Daniel Pittman
2011-Aug-12 18:17 UTC
Re: [Puppet Users] Service resource throws error for "ups" but service starts
On Fri, Aug 12, 2011 at 13:55, treydock <treydock@gmail.com> wrote:> I have a puppet module to manage Network UPS Tools, but am having > trouble getting Puppet to be able to start the "ups" service without > error. What''s strange is the service starts just fine, but Puppet > returns an error.> I do not know if this is the fault of a bad return code in the init > script...here''s the init script used...It smells like one, but I can''t see it obviously from that script. Can you try stopping NUT, then running the service command puppet does, and checking what ''echo $?'' is? If that isn''t 0, your init script isn''t returning correctly. Daniel -- ⎋ Puppet Labs Developer – http://puppetlabs.com ♲ Made with 100 percent post-consumer electrons -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.