Puppet can't start service (dropbox) but init.d command works manually

1,639 views
Skip to first unread message

Richard K. Miller

unread,
Jan 30, 2012, 6:05:10 PM1/30/12
to Puppet Users
I'm using Dropbox's command-line daemon on one of our machines and
want to use Puppet to keep it running. The dropbox service is already
installed and allows me to successfully execute /etc/init.d/dropbox
[start/stop/restart/service]. Here's my code:

class dropbox::service {
service { "dropbox":
ensure => running,
}
}

I get the following syslog error when this runs:
(/Stage[main]/Dropbox::Service/Service[dropbox]/ensure) change from
stopped to running failed: Could not start Service[dropbox]: Execution
of '/etc/init.d/dropbox start' returned 1: at /etc/puppet/modules/
dropbox/manifests/init.pp:14

However, if I run the above command manually, it works fine and
returns 0:

root@webhost:~# /etc/init.d/dropbox start ; echo $?
Starting dropbox...
0

Any ideas why puppet can't start the dropbox daemon?

Richard


Felix Frank

unread,
Jan 31, 2012, 12:19:13 PM1/31/12
to puppet...@googlegroups.com
Hi,

On 01/31/2012 12:05 AM, Richard K. Miller wrote:
> I get the following syslog error when this runs:
> (/Stage[main]/Dropbox::Service/Service[dropbox]/ensure) change from
> stopped to running failed: Could not start Service[dropbox]: Execution
> of '/etc/init.d/dropbox start' returned 1: at /etc/puppet/modules/
> dropbox/manifests/init.pp:14
>
> However, if I run the above command manually, it works fine and
> returns 0:
>
> root@webhost:~# /etc/init.d/dropbox start ; echo $?
> Starting dropbox...
> 0

it's a long shot, but there might be a problem related to the
environment when puppet runs the initscript.

Try the "start" command with a clean environment.

Side question: When you're trying that, is the service actually stopped?
Is puppet deducing that much correctly?

Cheers,
Felix

Nan Liu

unread,
Jan 31, 2012, 12:19:04 PM1/31/12
to puppet...@googlegroups.com

Try this on the command line:
puppet resource service dropbox ensure=running -d

Nan

Aaron Grewell

unread,
Jan 31, 2012, 12:25:04 PM1/31/12
to puppet...@googlegroups.com
> However, if I run the above command manually, it works fine and
> returns 0:
>
> root@webhost:~# /etc/init.d/dropbox start ; echo $?
> Starting dropbox...
> 0
>
> Any ideas why puppet can't start the dropbox daemon?

I had the same problem when running ssh-keygen via an exec. It ran fine
from the CLI but not via Puppet. In my case it turned out that SELinux
had been left enabled, so that's one thing to check.

Ryan Bowlby

unread,
Jan 31, 2012, 5:25:51 PM1/31/12
to Puppet Users
I second checking for required environment variables. Attempt to run
in a shell that hasn't sourced your .bash_profile and related login-
time config files. Also, try it with an exec with "/bin/bash -x /etc/
init.d/dropbox start" to further troubleshoot.


On Jan 30, 3:05 pm, "Richard K. Miller" <richardkmil...@gmail.com>
wrote:

Richard K. Miller

unread,
Jan 31, 2012, 8:01:52 PM1/31/12
to Puppet Users
Felix & Ryan: Good thought to try a clean environment. I tried "bash --
no-profile" and then ran the CLI command again, but it still worked.
My perusal of the script itself didn't seem to show any environment
variable dependencies. Felix, yes, puppet is correctly deducing that
the service is stopped, and it is indeed not running after puppet
runs.

Aaron: This is running on Ubuntu 11.04, so no SELinux, but AppArmor is
on. Could that be a factor?

Nan, here is the output from "puppet resource service dropbox
ensure=running -d":
debug: Puppet::Type::Service::ProviderGentoo: file /sbin/rc-update
does not exist
debug: Puppet::Type::Service::ProviderDaemontools: file /usr/bin/
svstat does not exist
debug: Puppet::Type::Service::ProviderRedhat: file /sbin/service does
not exist
debug: Puppet::Type::Service::ProviderRunit: file /usr/bin/sv does not
exist
debug: Puppet::Type::Service::ProviderLaunchd: file /bin/launchctl
does not exist
debug: Loaded state in 0.00 seconds
debug: Service[dropbox](provider=debian): Executing 'ps -ef'
debug: Service[dropbox](provider=debian): PID is 28233
debug: Finishing transaction 70128500285900
debug: Storing state
debug: Stored state in 0.02 seconds
debug: Service[dropbox](provider=debian): Executing 'ps -ef'
debug: Service[dropbox](provider=debian): PID is 28233
service { 'dropbox':
ensure => 'running'
}

Thanks, everyone, for your responses.

Richard

Felix Frank

unread,
Feb 3, 2012, 4:24:24 AM2/3/12
to puppet...@googlegroups.com
Hi,

On 02/01/2012 02:01 AM, Richard K. Miller wrote:
> AppArmor is
> on. Could that be a factor?

I certainly believe so. It should be investigated.

Regards

Ashley Baumann

unread,
Jul 2, 2012, 12:10:29 AM7/2/12
to puppet...@googlegroups.com
This was failing for me because the init.d script needed a #!/bin/sh at the top
of it. Puppet was getting an "Exec Format Error" when it tried to run it.


11008 execve("/etc/init.d/dropbox", ["/etc/init.d/dropbox", "status"], [/* 23
vars */]) = -1 ENOEXEC (Exec format error)

Ashleyb


Jon Jaroker

unread,
Sep 14, 2013, 5:48:01 PM9/14/13
to puppet...@googlegroups.com, ash...@vwiz.co.uk
Ashley,

Thanks for reporting the solution. I was just struggling with the same odd behavior. My setup automatically inserts "puppet managed" comments at the top of all templates, but this breaks init scripts (at least in Debian).

Jon

=============
Jon Jaroker
Reply all
Reply to author
Forward
0 new messages