Question regarding the SERVICE type

227 views
Skip to first unread message

D.N. van der Meijden

unread,
Sep 30, 2010, 9:42:02 AM9/30/10
to Puppet Users
I'm trying to get a service running, but I keep getting the following
error message:
"err: //Node[debiannode]/zabbix/Service[zabbix_agent]/ensure: change
from stopped to running failed: Could not start Service[zabbix_agent]:
Execution of '/etc/init.d/zabbix_agent start' returned 1: at /etc/
puppet/modules/zabbix/manifests/init.pp:62"

The part of the init.pp script:
service { "zabbix_agent":
name => "zabbix_agent",
enable => true,
ensure => running,
hasstatus => true,
subscribe => File["zabbix_agentd.conf"],
require => [ File["/etc/zabbix"],
File["zabbix_agentd.conf"] ],
} # <-- line 62

If I start the daemon manually [as root or normal user zabbix] (i.e. /
etc/init.d/zabbix_agent start), it works.
I checked the permissions, but these are set at 755 so that shouldn't
be a problem.

client:~# /etc/init.d/zabbix_agent start
Starting Zabbix agent: zabbix_agentd
client:~# ps -ef | grep zabbix
zabbix 2116 1 0 15:37 ? 00:00:00 /etc/zabbix/sbin/
zabbix_agentd
zabbix 2117 2116 0 15:37 ? 00:00:00 /etc/zabbix/sbin/
zabbix_agentd
zabbix 2118 2116 0 15:37 ? 00:00:00 /etc/zabbix/sbin/
zabbix_agentd
zabbix 2119 2116 0 15:37 ? 00:00:00 /etc/zabbix/sbin/
zabbix_agentd
zabbix 2120 2116 0 15:37 ? 00:00:00 /etc/zabbix/sbin/
zabbix_agentd
zabbix 2121 2116 0 15:37 ? 00:00:00 /etc/zabbix/sbin/
zabbix_agentd
zabbix 2122 2116 0 15:37 ? 00:00:00 /etc/zabbix/sbin/
zabbix_agentd
root 2124 1890 0 15:37 pts/2 00:00:00 grep zabbix


What am I missing here?

Nigel Kersten

unread,
Sep 30, 2010, 9:57:57 AM9/30/10
to puppet...@googlegroups.com

The exit status of starting the daemon, which is what Puppet is
reporting back to you.

/etc/init.d/zabbix_agent start ; echo $?

It sounds like puppet is actually starting it but thinking the
operation failed because the init script exits non-zero.

>
> --
> You received this message because you are subscribed to the Google Groups "Puppet Users" group.
> To post to this group, send email to puppet...@googlegroups.com.
> To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
>
>

--
nigel

D.N. van der Meijden

unread,
Sep 30, 2010, 10:04:13 AM9/30/10
to Puppet Users
Thanks for the quick reply Nigel.
I understand that the puppet is reporting back the exit status, but
what I don't understand is why it keeps failing when trying to start
via puppet.
All files are available on the client, permissions are ok and starting
the daemon manually works without problems.
> nigel- Tekst uit oorspronkelijk bericht niet weergeven -
>
> - Tekst uit oorspronkelijk bericht weergeven -

luke.bigum

unread,
Sep 30, 2010, 10:28:57 AM9/30/10
to Puppet Users
As Nigel indicated, the exit code for your init script is not what
puppet expects, it is not a file permission problem.

As Nigel suggested, shut down your service then run this:

/etc/init.d/zabbix_agent start ; echo $?

And tell us what number is printed on the screen. If it prints 1, that
would explain your Puppet error message. Not sure what operating
system you use, but init scripts SHOULD return 0 when they run
successfully. If your init script is returning 1 on success, it's
broken.

-Luke

On Sep 30, 3:04 pm, "D.N. van der Meijden" <cybernijn...@gmail.com>

D.N. van der Meijden

unread,
Sep 30, 2010, 10:33:56 AM9/30/10
to Puppet Users
Hi Luke,

As mentioned it works manually:

'client:~# /etc/init.d/zabbix_agent start ; echo $?
Starting Zabbix agent: zabbix_agentd
0


By the way, this specific client is a lenny 5.05
> > > - Tekst uit oorspronkelijk bericht weergeven -- Tekst uit oorspronkelijk bericht niet weergeven -

luke.bigum

unread,
Sep 30, 2010, 10:45:19 AM9/30/10
to Puppet Users
My apologies, I thought you were saying it starts but were unaware of
the exit code.

I'm now unsure... You could try run this:

puppet apply --verbose --debug --trace --summarize test.pp

where test.pp is the simplest form of your service as possible, and
see if you get anything useful, although I've just done that on a
CentOS system and it wasn't as helpful as I imagined (didn't blatantly
tell me the exit code as I hoped).

On Sep 30, 3:33 pm, "D.N. van der Meijden" <cybernijn...@gmail.com>

D.N. van der Meijden

unread,
Sep 30, 2010, 11:03:23 AM9/30/10
to Puppet Users
No problem Luke, thanks for helping me out here.
Since I'm still a puppet n00b, where should I place the test.pp? On
the host I presume (I tried /etc/puppet/manifests/test.pp) ?

test.pp:
class test {
service { "rsyslog":
name => "rsyslog",
enable => true,
ensure => running,
hasstatus => true,
subscribe => File["/etc/rsyslog.conf"],
}
}

If I start the command on the client, I get some weird output:

client:/etc/init.d# puppet apply --verbose --debug --trace --summarize
test.pp
/usr/lib/ruby/1.8/puppet/parser/parser_support.rb:95:in `file='
/usr/lib/ruby/1.8/puppet/parser/interpreter.rb:69:in `create_parser'
/usr/lib/ruby/1.8/puppet/parser/interpreter.rb:54:in `parser'
/usr/lib/ruby/1.8/puppet/parser/interpreter.rb:27:in `compile'
/usr/lib/ruby/1.8/puppet/indirector/catalog/compiler.rb:68:in
`compile'
/usr/lib/ruby/1.8/puppet/util.rb:217:in `benchmark'
/usr/lib/ruby/1.8/puppet/indirector/catalog/compiler.rb:66:in
`compile'
/usr/lib/ruby/1.8/puppet/indirector/catalog/compiler.rb:21:in `find'
/usr/lib/ruby/1.8/puppet/indirector/indirection.rb:210:in `find'
/usr/lib/ruby/1.8/puppet/indirector.rb:49:in `find'
/usr/bin/puppet:210
Could not parse for environment production: Could not find file /etc/
init.d/apply.pp
Message has been deleted

D.N. van der Meijden

unread,
Sep 30, 2010, 11:15:35 AM9/30/10
to Puppet Users
My bad! Just checked out the puppet command :-s

Ok, output on my client is now:
client:/tmp# puppet --verbose --debug --trace test.pp
debug: file /sbin/chkconfig does not exist
debug: file /usr/sbin/svcadm does not exist
debug: file /sbin/rc-update does not exist
debug: Creating default schedules
debug: Service[zabbix_agent](provider=debian): Executing '/etc/init.d/
zabbix_agent status'
debug: Puppet::Type::Service::ProviderDebian: Executing '/usr/sbin/
update-rc.d -n -f zabbix_agent remove'
debug: //Service[zabbix_agent]: Changing ensure
debug: //Service[zabbix_agent]: 1 change(s)
debug: Service[zabbix_agent](provider=debian): Executing '/etc/init.d/
zabbix_agent start'
/usr/lib/ruby/1.8/puppet/util/errors.rb:51:in `fail'
/usr/lib/ruby/1.8/puppet/provider/service/base.rb:122:in `texecute'
/usr/lib/ruby/1.8/puppet/provider/service/base.rb:134:in `ucommand'
/usr/lib/ruby/1.8/puppet/provider/service/base.rb:78:in `start'
/usr/lib/ruby/1.8/puppet/type/service.rb:61:in `set_running'
/usr/lib/ruby/1.8/puppet/property.rb:163:in `send'
/usr/lib/ruby/1.8/puppet/property.rb:163:in `call_valuemethod'
/usr/lib/ruby/1.8/puppet/property.rb:349:in `set'
/usr/lib/ruby/1.8/puppet/property.rb:421:in `sync'
/usr/lib/ruby/1.8/puppet/type/service.rb:72:in `sync'
/usr/lib/ruby/1.8/puppet/transaction/change.rb:54:in `go'
/usr/lib/ruby/1.8/puppet/transaction/change.rb:74:in `forward'
/usr/lib/ruby/1.8/puppet/transaction.rb:118:in `apply_changes'
/usr/lib/ruby/1.8/puppet/transaction.rb:111:in `collect'
/usr/lib/ruby/1.8/puppet/transaction.rb:111:in `apply_changes'
/usr/lib/ruby/1.8/puppet/transaction.rb:83:in `apply'
/usr/lib/ruby/1.8/puppet/transaction.rb:239:in `eval_resource'
/usr/lib/ruby/1.8/puppet/util.rb:445:in `thinmark'
/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
/usr/lib/ruby/1.8/puppet/util.rb:444:in `thinmark'
/usr/lib/ruby/1.8/puppet/transaction.rb:238:in `eval_resource'
/usr/lib/ruby/1.8/puppet/transaction.rb:310:in `evaluate'
/usr/lib/ruby/1.8/puppet/util.rb:445:in `thinmark'
/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
/usr/lib/ruby/1.8/puppet/util.rb:444:in `thinmark'
/usr/lib/ruby/1.8/puppet/transaction.rb:309:in `evaluate'
/usr/lib/ruby/1.8/puppet/transaction.rb:303:in `collect'
/usr/lib/ruby/1.8/puppet/transaction.rb:303:in `evaluate'
/usr/lib/ruby/1.8/puppet/node/catalog.rb:124:in `apply'
/usr/bin/puppet:220
err: //Service[zabbix_agent]/ensure: change from stopped to running
failed: Could not start Service[zabbix_agent]: Execution of '/etc/
init.d/zabbix_agent start' returned 1: at /tmp/test.pp:6
debug: Finishing transaction 69992700590000 with 1 changes


On 30 sep, 17:03, "D.N. van der Meijden" <cybernijn...@gmail.com>

luke.bigum

unread,
Sep 30, 2010, 11:15:02 AM9/30/10
to Puppet Users
From what I understand using "puppet apply" will make no attempt to
contact the puppet master and so is useful for testing, but all your
Puppet config files must be local. The file you are applying should be
in CWD, or you can just:

puppet apply [options] /wherever/test.pp

As for your error output below, I'm not sure why it would be trying to
look for "apply.pp", has it parsed the "apply" sub command as if it's
expecting a file I wonder. It doesn't look like my output if I give it
the wrong location for test.pp, but I am using Puppet 2.6.1 and can't
help you with any other version. Run "puppet help" ?

On Sep 30, 4:03 pm, "D.N. van der Meijden" <cybernijn...@gmail.com>

Nigel Kersten

unread,
Sep 30, 2010, 11:24:10 AM9/30/10
to puppet...@googlegroups.com
Can you post the init script?

Is it possible it's a PATH problem inside the script? Something that
works under your environment, but not under the user puppet is running
as?

On Thu, Sep 30, 2010 at 8:16 AM, D.N. van der Meijden
<cybern...@gmail.com> wrote:
> My bad!! I understand the puppet command now...

> err: //Service[zabbix_agent]/ensure: change from stopped to running


> failed: Could not start Service[zabbix_agent]: Execution of '/etc/
> init.d/zabbix_agent start' returned 1:  at /tmp/test.pp:6
> debug: Finishing transaction 69992700590000 with 1 changes
>
>

> On 30 sep, 17:03, "D.N. van der Meijden" <cybernijn...@gmail.com>

James Lucas

unread,
Sep 30, 2010, 10:44:03 AM9/30/10
to puppet...@googlegroups.com
Hi,

I previously had a similar problem trying to start a ruby app using
bundler that I eventually found to be caused by the non existence of the
$HOME environment variable, adding this using:
environment => "HOME=/home/user" to the exec command fixed it.

Could there be an environment difference between running via puppet and
manually that could cause it not to run?

Regards

James

D.N. van der Meijden

unread,
Sep 30, 2010, 11:46:52 AM9/30/10
to Puppet Users
Here's the init script:

(by the way, I changed the service to rsyslog [in the zabbix manifest
file] and this works like a charm. So the service action works in
puppet...)

#! /bin/sh
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/etc/zabbix:/etc/zabbix/bin:/etc/
zabbix/sbin
DAEMON=/etc/zabbix/sbin/zabbix_agentd
NAME=zabbix_agentd
DESC="Zabbix agent"
PID=/var/tmp/$NAME.pid

test -f $DAEMON || exit 0
set -e
case "$1" in
start)
echo "Starting $DESC: $NAME"
start-stop-daemon --oknodo --start --pidfile $PID \
--exec $DAEMON
;;
stop)
echo "Stopping $DESC: $NAME"
start-stop-daemon --oknodo --stop --pidfile $PID \
--exec $DAEMON
;;
restart|force-reload)
$0 stop
$0 start
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0
> ...
>
> meer lezen »- Tekst uit oorspronkelijk bericht niet weergeven -

Nan Liu

unread,
Sep 30, 2010, 12:26:09 PM9/30/10
to puppet...@googlegroups.com

The script does not provide status, so when hasstatus is set to true,
puppet is querying service state via an invalid command:
/etc/init.d/zabbix status

This will always fail, which makes puppet think the service is always stopped.

I would look at:
http://www.nowvox.com/contrib/zabbix/zabbix_agentd

Thanks,

Nan

D.N. van der Meijden

unread,
Oct 5, 2010, 7:11:32 AM10/5/10
to Puppet Users
Thanks for the extra info Nan.
I've changed the init script to support the status option, but to no
avail...

+ . /lib/lsb/init-functions
+
+ status)
+ status_of_proc -p $PID && exit 0 || exit $?
+ ;;

after this the status option works, but puppet still cannot start the
daemon...
as a workaround I can reboot the client (since the daemon does start
after a reboot because of the rc2.d symlink created by the mantifest
file), but this is not really an option...

The only thing I can think of right now is that the zabbix_agent
daemon needs to run as user zabbix, and puppet can't get it to run
that way (I know really far fetched, but I'm getting out of options
here..)
> Nan- Tekst uit oorspronkelijk bericht niet weergeven -

D.N. van der Meijden

unread,
Oct 5, 2010, 7:22:20 AM10/5/10
to Puppet Users
By the way I tried the 'puppet' command to get some more info:

client:/tmp# puppet -d -v jadda
debug: file /sbin/chkconfig does not exist
debug: file /usr/sbin/svcadm does not exist
debug: file /sbin/rc-update does not exist
debug: Creating default schedules
debug: Service[zabbix_agent](provider=debian): Executing '/etc/init.d/
zabbix_agent status'
debug: Puppet::Type::Service::ProviderDebian: Executing '/usr/sbin/
update-rc.d -n -f zabbix_agent remove'
debug: //Service[zabbix_agent]: Changing ensure
debug: //Service[zabbix_agent]: 1 change(s)
debug: Service[zabbix_agent](provider=debian): Executing '/etc/init.d/
zabbix_agent start'
err: //Service[zabbix_agent]/ensure: change from stopped to running
failed: Could not start Service[zabbix_agent]: Execution of '/etc/
init.d/zabbix_agent start' returned 1: at /tmp/jadda.pp:6
debug: Finishing transaction 70189522224900 with 1 changes

client:/tmp# cat jadda.pp
service { "zabbix_agent":
name => "zabbix_agent",
enable => true,
ensure => running,
hasstatus => true,
}


On 5 okt, 13:11, "D.N. van der Meijden" <cybernijn...@gmail.com>
wrote:
> Thanks for the extra info Nan.
> I've changed the init script to support the status option, but to no
> avail...
>
> +  . /lib/lsb/init-functions
> +
> +  status)
> +     status_of_proc -p $PID && exit 0 || exit $?
> +     ;;
>
> after this the status option works, but puppet still cannot start the
> daemon...
> as a workaround I can reboot the client (since the daemon does start
> after a reboot because of the rc2.d symlink created by the mantifest
> file), but this is not really an option...
>
> The only thing I can think of right now is that the zabbix_agent
> daemon needs to run as userzabbix, and puppet can't get it to run
> > - Tekst uit oorspronkelijk bericht weergeven -- Tekst uit oorspronkelijk bericht niet weergeven -

D.N. van der Meijden

unread,
Oct 5, 2010, 8:53:40 AM10/5/10
to Puppet Users
I hope I'm not spamming this group, but just trying to share
everything :-)

I tried using a new puppet client (v2.6.1), but same results:
...
debug: Loaded state in 0.00 seconds
info: Applying configuration version '1286282327'
debug: Service[JADDA](provider=debian): Executing '/etc/init.d/
zabbix_agent status'
debug: Service[JADDA](provider=debian): Executing '/etc/init.d/
zabbix_agent start'
err: /Stage[main]//Service[JADDA]/ensure: change from stopped to
running failed: Could not start Service[JADDA]: Execution of '/etc/
init.d/zabbix_agent start' returned 1: at /tmp/jadda.pp:6
debug: Finishing transaction 70131490329360
debug: Storing state
debug: Stored state in 0.01 seconds


Also tried the zabbix manifest file (http://projects.puppetlabs.com/
projects/1/wiki/Zabbix_Agent_Patterns), but this one fails as well....

this is getting ridiculous, as all other daemons work perfectly...


On 5 okt, 13:22, "D.N. van der Meijden" <cybernijn...@gmail.com>

D.N. van der Meijden

unread,
Oct 5, 2010, 9:32:16 AM10/5/10
to Puppet Users
*ahem* ...found it....

PATH settings:
export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"

works... (with /usr/sbin/zabbix_agentd)
Can't seem to get it working with /etc/zabbix/sbin/zabbix_agentd
though??



On 5 okt, 14:53, "D.N. van der Meijden" <cybernijn...@gmail.com>
Reply all
Reply to author
Forward
0 new messages